9699 lines
726 KiB
HTML
9699 lines
726 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
|
<title>soundmanager2.js</title>
|
|
<meta name="robots" content="noindex" />
|
|
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
|
</head>
|
|
<body>
|
|
<div id='container'>
|
|
<div id="background"></div>
|
|
<div id="jump_to">
|
|
Jump To …
|
|
<div id="jump_wrapper">
|
|
<div id="jump_page">
|
|
<a class="source" href="../demo/360-player/script/360player.html">360player.js</a>
|
|
<a class="source" href="../demo/flashblock/flashblock.html">flashblock.css</a>
|
|
<a class="source" href="../demo/mp3-player-button/script/mp3-player-button.html">mp3-player-button.js</a>
|
|
<a class="source" href="../demo/mpc/script/mpc.html">mpc.js</a>
|
|
<a class="source" href="../demo/page-player/script/page-player.html">page-player.js</a>
|
|
<a class="source" href="../demo/play-mp3-links/script/inlineplayer.html">inlineplayer.js</a>
|
|
<a class="source" href="soundmanager2.html">soundmanager2.js</a>
|
|
<a class="source" href="../src/SoundManager2.html">SoundManager2.as</a>
|
|
<a class="source" href="../src/SoundManager2_AS3.html">SoundManager2_AS3.as</a>
|
|
<a class="source" href="../src/SoundManager2_SMSound_AS3.html">SoundManager2_SMSound_AS3.as</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<table cellspacing=0 cellpadding=0>
|
|
<thead>
|
|
<tr>
|
|
<th class=docs><h1>soundmanager2.js</h1></th>
|
|
<th class=code></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr id='section-SoundManager_2:_JavaScript_Sound_for_the_Web'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-SoundManager_2:_JavaScript_Sound_for_the_Web">¶</a>
|
|
</div>
|
|
<p>@license</p>
|
|
|
|
<h2>SoundManager 2: JavaScript Sound for the Web</h2>
|
|
|
|
<p>http://schillmania.com/projects/soundmanager2/</p>
|
|
|
|
<p>Copyright © 2007, Scott Schiller. All rights reserved.
|
|
Code provided under the BSD License:
|
|
http://schillmania.com/projects/soundmanager2/license.txt</p>
|
|
|
|
<p>V2.97a.20130101</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre><span class="cm">/*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio, opera */</span>
|
|
<span class="cm">/*jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: true */</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-About_this_file'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-About_this_file">¶</a>
|
|
</div>
|
|
<h2>About this file</h2>
|
|
|
|
<p>This is the fully-commented source version of the SoundManager 2 API,
|
|
recommended for use during development and testing.</p>
|
|
|
|
<p>See soundmanager2-nodebug-jsmin.js for an optimized build (~11KB with gzip.)
|
|
http://schillmania.com/projects/soundmanager2/doc/getstarted/#basic-inclusion
|
|
Alternately, serve this file with gzip for 75% compression savings (~30KB over HTTP.)</p>
|
|
|
|
<p>You may notice <d> and </d> comments in this source; these are delimiters for
|
|
debug blocks which are removed in the -nodebug builds, further optimizing code size.</p>
|
|
|
|
<p>Also, as you may note: Whoa, reliable cross-platform/device audio support is hard! ;)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="s2">"use strict"</span><span class="p">;</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">soundManager</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-3'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-3">¶</a>
|
|
</div>
|
|
<p>The SoundManager constructor.</p>
|
|
|
|
<p>@constructor
|
|
@param {string} smURL Optional: Path to SWF files
|
|
@param {string} smID Optional: The ID to use for the SWF container element
|
|
@this {SoundManager}
|
|
@return {SoundManager} The new SoundManager instance</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre><span class="kd">function</span> <span class="nx">SoundManager</span><span class="p">(</span><span class="nx">smURL</span><span class="p">,</span> <span class="nx">smID</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-4'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-4">¶</a>
|
|
</div>
|
|
<p>soundManager configuration options list
|
|
defines top-level configuration properties to be applied to the soundManager instance (eg. soundManager.flashVersion)
|
|
to set these properties, use the setup() method – eg., soundManager.setup({url: ‘/swf/’, flashVersion: 9})</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">setupOptions</span> <span class="o">=</span> <span class="p">{</span>
|
|
|
|
<span class="s1">'url'</span><span class="o">:</span> <span class="p">(</span><span class="nx">smURL</span> <span class="o">||</span> <span class="kc">null</span><span class="p">),</span> <span class="c1">// path (directory) where SoundManager 2 SWFs exist, eg., /path/to/swfs/</span>
|
|
<span class="s1">'flashVersion'</span><span class="o">:</span> <span class="mi">8</span><span class="p">,</span> <span class="c1">// flash build to use (8 or 9.) Some API features require 9.</span>
|
|
<span class="s1">'debugMode'</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="c1">// enable debugging output (console.log() with HTML fallback)</span>
|
|
<span class="s1">'debugFlash'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span> <span class="c1">// enable debugging output inside SWF, troubleshoot Flash/browser issues</span>
|
|
<span class="s1">'useConsole'</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="c1">// use console.log() if available (otherwise, writes to #soundmanager-debug element)</span>
|
|
<span class="s1">'consoleOnly'</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="c1">// if console is being used, do not create/write to #soundmanager-debug</span>
|
|
<span class="s1">'waitForWindowLoad'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span> <span class="c1">// force SM2 to wait for window.onload() before trying to call soundManager.onload()</span>
|
|
<span class="s1">'bgColor'</span><span class="o">:</span> <span class="s1">'#ffffff'</span><span class="p">,</span> <span class="c1">// SWF background color. N/A when wmode = 'transparent'</span>
|
|
<span class="s1">'useHighPerformance'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span> <span class="c1">// position:fixed flash movie can help increase js/flash speed, minimize lag</span>
|
|
<span class="s1">'flashPollingInterval'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// msec affecting whileplaying/loading callback frequency. If null, default of 50 msec is used.</span>
|
|
<span class="s1">'html5PollingInterval'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// msec affecting whileplaying() for HTML5 audio, excluding mobile devices. If null, native HTML5 update events are used.</span>
|
|
<span class="s1">'flashLoadTimeout'</span><span class="o">:</span> <span class="mi">1000</span><span class="p">,</span> <span class="c1">// msec to wait for flash movie to load before failing (0 = infinity)</span>
|
|
<span class="s1">'wmode'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// flash rendering mode - null, 'transparent', or 'opaque' (last two allow z-index to work)</span>
|
|
<span class="s1">'allowScriptAccess'</span><span class="o">:</span> <span class="s1">'always'</span><span class="p">,</span> <span class="c1">// for scripting the SWF (object/embed property), 'always' or 'sameDomain'</span>
|
|
<span class="s1">'useFlashBlock'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span> <span class="c1">// *requires flashblock.css, see demos* - allow recovery from flash blockers. Wait indefinitely and apply timeout CSS to SWF, if applicable.</span>
|
|
<span class="s1">'useHTML5Audio'</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="c1">// use HTML5 Audio() where API is supported (most Safari, Chrome versions), Firefox (no MP3/MP4.) Ideally, transparent vs. Flash API where possible.</span>
|
|
<span class="s1">'html5Test'</span><span class="o">:</span> <span class="sr">/^(probably|maybe)$/i</span><span class="p">,</span> <span class="c1">// HTML5 Audio() format support test. Use /^probably$/i; if you want to be more conservative.</span>
|
|
<span class="s1">'preferFlash'</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="c1">// overrides useHTML5audio. if true and flash support present, will try to use flash for MP3/MP4 as needed since HTML5 audio support is still quirky in browsers.</span>
|
|
<span class="s1">'noSWFCache'</span><span class="o">:</span> <span class="kc">false</span> <span class="c1">// if true, appends ?ts={date} to break aggressive SWF caching.</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">defaultOptions</span> <span class="o">=</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-5'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-5">¶</a>
|
|
</div>
|
|
<p>the default configuration for sound objects made with createSound() and related methods
|
|
eg., volume, auto-load behaviour and so forth</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="s1">'autoLoad'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span> <span class="c1">// enable automatic loading (otherwise .load() will be called on demand with .play(), the latter being nicer on bandwidth - if you want to .load yourself, you also can)</span>
|
|
<span class="s1">'autoPlay'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span> <span class="c1">// enable playing of file as soon as possible (much faster if "stream" is true)</span>
|
|
<span class="s1">'from'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// position to start playback within a sound (msec), default = beginning</span>
|
|
<span class="s1">'loops'</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span> <span class="c1">// how many times to repeat the sound (position will wrap around to 0, setPosition() will break out of loop when >0)</span>
|
|
<span class="s1">'onid3'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback function for "ID3 data is added/available"</span>
|
|
<span class="s1">'onload'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback function for "load finished"</span>
|
|
<span class="s1">'whileloading'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback function for "download progress update" (X of Y bytes received)</span>
|
|
<span class="s1">'onplay'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback for "play" start</span>
|
|
<span class="s1">'onpause'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback for "pause"</span>
|
|
<span class="s1">'onresume'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback for "resume" (pause toggle)</span>
|
|
<span class="s1">'whileplaying'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback during play (position update)</span>
|
|
<span class="s1">'onposition'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// object containing times and function callbacks for positions of interest</span>
|
|
<span class="s1">'onstop'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback for "user stop"</span>
|
|
<span class="s1">'onfailure'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback function for when playing fails</span>
|
|
<span class="s1">'onfinish'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback function for "sound finished playing"</span>
|
|
<span class="s1">'multiShot'</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="c1">// let sounds "restart" or layer on top of each other when played multiple times, rather than one-shot/one at a time</span>
|
|
<span class="s1">'multiShotEvents'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span> <span class="c1">// fire multiple sound events (currently onfinish() only) when multiShot is enabled</span>
|
|
<span class="s1">'position'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// offset (milliseconds) to seek to within loaded sound data.</span>
|
|
<span class="s1">'pan'</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// "pan" settings, left-to-right, -100 to 100</span>
|
|
<span class="s1">'stream'</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="c1">// allows playing before entire file has loaded (recommended)</span>
|
|
<span class="s1">'to'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// position to end playback within a sound (msec), default = end</span>
|
|
<span class="s1">'type'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// MIME-like hint for file pattern / canPlay() tests, eg. audio/mp3</span>
|
|
<span class="s1">'usePolicyFile'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span> <span class="c1">// enable crossdomain.xml request for audio on remote domains (for ID3/waveform access)</span>
|
|
<span class="s1">'volume'</span><span class="o">:</span> <span class="mi">100</span> <span class="c1">// self-explanatory. 0-100, the latter being the max.</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">flash9Options</span> <span class="o">=</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-6'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-6">¶</a>
|
|
</div>
|
|
<p>flash 9-only options,
|
|
merged into defaultOptions if flash 9 is being used</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="s1">'isMovieStar'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// "MovieStar" MPEG4 audio mode. Null (default) = auto detect MP4, AAC etc. based on URL. true = force on, ignore URL</span>
|
|
<span class="s1">'usePeakData'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span> <span class="c1">// enable left/right channel peak (level) data</span>
|
|
<span class="s1">'useWaveformData'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span> <span class="c1">// enable sound spectrum (raw waveform data) - NOTE: May increase CPU load.</span>
|
|
<span class="s1">'useEQData'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span> <span class="c1">// enable sound EQ (frequency spectrum data) - NOTE: May increase CPU load.</span>
|
|
<span class="s1">'onbufferchange'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback for "isBuffering" property change</span>
|
|
<span class="s1">'ondataerror'</span><span class="o">:</span> <span class="kc">null</span> <span class="c1">// callback for waveform/eq data access error (flash playing audio in other tabs/domains)</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">movieStarOptions</span> <span class="o">=</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-7'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-7">¶</a>
|
|
</div>
|
|
<p>flash 9.0r115+ MPEG4 audio options,
|
|
merged into defaultOptions if flash 9+movieStar mode is enabled</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="s1">'bufferTime'</span><span class="o">:</span> <span class="mi">3</span><span class="p">,</span> <span class="c1">// seconds of data to buffer before playback begins (null = flash default of 0.1 seconds - if AAC playback is gappy, try increasing.)</span>
|
|
<span class="s1">'serverURL'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// rtmp: FMS or FMIS server to connect to, required when requesting media via RTMP or one of its variants</span>
|
|
<span class="s1">'onconnect'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// rtmp: callback for connection to flash media server</span>
|
|
<span class="s1">'duration'</span><span class="o">:</span> <span class="kc">null</span> <span class="c1">// rtmp: song duration (msec)</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">audioFormats</span> <span class="o">=</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-8'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-8">¶</a>
|
|
</div>
|
|
<p>determines HTML5 support + flash requirements.
|
|
if no support (via flash and/or HTML5) for a “required” format, SM2 will fail to start.
|
|
flash fallback is used for MP3 or MP4 if HTML5 can’t play it (or if preferFlash = true)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="s1">'mp3'</span><span class="o">:</span> <span class="p">{</span>
|
|
<span class="s1">'type'</span><span class="o">:</span> <span class="p">[</span><span class="s1">'audio/mpeg; codecs="mp3"'</span><span class="p">,</span> <span class="s1">'audio/mpeg'</span><span class="p">,</span> <span class="s1">'audio/mp3'</span><span class="p">,</span> <span class="s1">'audio/MPA'</span><span class="p">,</span> <span class="s1">'audio/mpa-robust'</span><span class="p">],</span>
|
|
<span class="s1">'required'</span><span class="o">:</span> <span class="kc">true</span>
|
|
<span class="p">},</span>
|
|
|
|
<span class="s1">'mp4'</span><span class="o">:</span> <span class="p">{</span>
|
|
<span class="s1">'related'</span><span class="o">:</span> <span class="p">[</span><span class="s1">'aac'</span><span class="p">,</span><span class="s1">'m4a'</span><span class="p">,</span><span class="s1">'m4b'</span><span class="p">],</span> <span class="c1">// additional formats under the MP4 container</span>
|
|
<span class="s1">'type'</span><span class="o">:</span> <span class="p">[</span><span class="s1">'audio/mp4; codecs="mp4a.40.2"'</span><span class="p">,</span> <span class="s1">'audio/aac'</span><span class="p">,</span> <span class="s1">'audio/x-m4a'</span><span class="p">,</span> <span class="s1">'audio/MP4A-LATM'</span><span class="p">,</span> <span class="s1">'audio/mpeg4-generic'</span><span class="p">],</span>
|
|
<span class="s1">'required'</span><span class="o">:</span> <span class="kc">false</span>
|
|
<span class="p">},</span>
|
|
|
|
<span class="s1">'ogg'</span><span class="o">:</span> <span class="p">{</span>
|
|
<span class="s1">'type'</span><span class="o">:</span> <span class="p">[</span><span class="s1">'audio/ogg; codecs=vorbis'</span><span class="p">],</span>
|
|
<span class="s1">'required'</span><span class="o">:</span> <span class="kc">false</span>
|
|
<span class="p">},</span>
|
|
|
|
<span class="s1">'wav'</span><span class="o">:</span> <span class="p">{</span>
|
|
<span class="s1">'type'</span><span class="o">:</span> <span class="p">[</span><span class="s1">'audio/wav; codecs="1"'</span><span class="p">,</span> <span class="s1">'audio/wav'</span><span class="p">,</span> <span class="s1">'audio/wave'</span><span class="p">,</span> <span class="s1">'audio/x-wav'</span><span class="p">],</span>
|
|
<span class="s1">'required'</span><span class="o">:</span> <span class="kc">false</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-9'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-9">¶</a>
|
|
</div>
|
|
<p>HTML attributes (id + class names) for the SWF container</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">movieID</span> <span class="o">=</span> <span class="s1">'sm2-container'</span><span class="p">;</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="p">(</span><span class="nx">smID</span> <span class="o">||</span> <span class="s1">'sm2movie'</span><span class="p">);</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">debugID</span> <span class="o">=</span> <span class="s1">'soundmanager-debug'</span><span class="p">;</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">debugURLParam</span> <span class="o">=</span> <span class="sr">/([#?&])debug=1/i</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-10'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-10">¶</a>
|
|
</div>
|
|
<p>dynamic attributes</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">versionNumber</span> <span class="o">=</span> <span class="s1">'V2.97a.20130101'</span><span class="p">;</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">version</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">movieURL</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">altURL</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">swfLoaded</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">enabled</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">oMC</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">sounds</span> <span class="o">=</span> <span class="p">{};</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">soundIDs</span> <span class="o">=</span> <span class="p">[];</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">muted</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">didFlashBlock</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">filePattern</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">filePatterns</span> <span class="o">=</span> <span class="p">{</span>
|
|
|
|
<span class="s1">'flash8'</span><span class="o">:</span> <span class="sr">/\.mp3(\?.*)?$/i</span><span class="p">,</span>
|
|
<span class="s1">'flash9'</span><span class="o">:</span> <span class="sr">/\.mp3(\?.*)?$/i</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-11'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-11">¶</a>
|
|
</div>
|
|
<p>support indicators, set at init</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">features</span> <span class="o">=</span> <span class="p">{</span>
|
|
|
|
<span class="s1">'buffering'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
|
|
<span class="s1">'peakData'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
|
|
<span class="s1">'waveformData'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
|
|
<span class="s1">'eqData'</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
|
|
<span class="s1">'movieStar'</span><span class="o">:</span> <span class="kc">false</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-12'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-12">¶</a>
|
|
</div>
|
|
<p>flash sandbox info, used primarily in troubleshooting</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">sandbox</span> <span class="o">=</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-13'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-13">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="s1">'type'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span>
|
|
<span class="s1">'types'</span><span class="o">:</span> <span class="p">{</span>
|
|
<span class="s1">'remote'</span><span class="o">:</span> <span class="s1">'remote (domain-based) rules'</span><span class="p">,</span>
|
|
<span class="s1">'localWithFile'</span><span class="o">:</span> <span class="s1">'local with file access (no internet access)'</span><span class="p">,</span>
|
|
<span class="s1">'localWithNetwork'</span><span class="o">:</span> <span class="s1">'local with network (internet access only, no local access)'</span><span class="p">,</span>
|
|
<span class="s1">'localTrusted'</span><span class="o">:</span> <span class="s1">'local, trusted (local+internet access)'</span>
|
|
<span class="p">},</span>
|
|
<span class="s1">'description'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span>
|
|
<span class="s1">'noRemote'</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span>
|
|
<span class="s1">'noLocal'</span><span class="o">:</span> <span class="kc">null</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-14'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-14">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-15'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-15">¶</a>
|
|
</div>
|
|
<p>format support (html5/flash)
|
|
stores canPlayType() results based on audioFormats.
|
|
eg. { mp3: boolean, mp4: boolean }
|
|
treat as read-only.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">html5</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="s1">'usingFlash'</span><span class="o">:</span> <span class="kc">null</span> <span class="c1">// set if/when flash fallback is needed</span>
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-16'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-16">¶</a>
|
|
</div>
|
|
<p>file type support hash</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">flash</span> <span class="o">=</span> <span class="p">{};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-17'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-17">¶</a>
|
|
</div>
|
|
<p>determined at init time</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">html5Only</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-18'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-18">¶</a>
|
|
</div>
|
|
<p>used for special cases (eg. iPad/iPhone/palm OS?)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">ignoreFlash</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-19'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-19">¶</a>
|
|
</div>
|
|
<p>a few private internals (OK, a lot. :D)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">SMSound</span><span class="p">,</span>
|
|
<span class="nx">sm2</span> <span class="o">=</span> <span class="k">this</span><span class="p">,</span> <span class="nx">globalHTML5Audio</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">flash</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">sm</span> <span class="o">=</span> <span class="s1">'soundManager'</span><span class="p">,</span> <span class="nx">smc</span> <span class="o">=</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">': '</span><span class="p">,</span> <span class="nx">h5</span> <span class="o">=</span> <span class="s1">'HTML5::'</span><span class="p">,</span> <span class="nx">id</span><span class="p">,</span> <span class="nx">ua</span> <span class="o">=</span> <span class="nx">navigator</span><span class="p">.</span><span class="nx">userAgent</span><span class="p">,</span> <span class="nx">wl</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">href</span><span class="p">.</span><span class="nx">toString</span><span class="p">(),</span> <span class="nx">doc</span> <span class="o">=</span> <span class="nb">document</span><span class="p">,</span> <span class="nx">doNothing</span><span class="p">,</span> <span class="nx">setProperties</span><span class="p">,</span> <span class="nx">init</span><span class="p">,</span> <span class="nx">fV</span><span class="p">,</span> <span class="nx">on_queue</span> <span class="o">=</span> <span class="p">[],</span> <span class="nx">debugOpen</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span> <span class="nx">debugTS</span><span class="p">,</span> <span class="nx">didAppend</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">appendSuccess</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">didInit</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">disabled</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">windowLoaded</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">_wDS</span><span class="p">,</span> <span class="nx">wdCount</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">initComplete</span><span class="p">,</span> <span class="nx">mixin</span><span class="p">,</span> <span class="nx">assign</span><span class="p">,</span> <span class="nx">extraOptions</span><span class="p">,</span> <span class="nx">addOnEvent</span><span class="p">,</span> <span class="nx">processOnEvents</span><span class="p">,</span> <span class="nx">initUserOnload</span><span class="p">,</span> <span class="nx">delayWaitForEI</span><span class="p">,</span> <span class="nx">waitForEI</span><span class="p">,</span> <span class="nx">setVersionInfo</span><span class="p">,</span> <span class="nx">handleFocus</span><span class="p">,</span> <span class="nx">strings</span><span class="p">,</span> <span class="nx">initMovie</span><span class="p">,</span> <span class="nx">preInit</span><span class="p">,</span> <span class="nx">domContentLoaded</span><span class="p">,</span> <span class="nx">winOnLoad</span><span class="p">,</span> <span class="nx">didDCLoaded</span><span class="p">,</span> <span class="nx">getDocument</span><span class="p">,</span> <span class="nx">createMovie</span><span class="p">,</span> <span class="nx">catchError</span><span class="p">,</span> <span class="nx">setPolling</span><span class="p">,</span> <span class="nx">initDebug</span><span class="p">,</span> <span class="nx">debugLevels</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'log'</span><span class="p">,</span> <span class="s1">'info'</span><span class="p">,</span> <span class="s1">'warn'</span><span class="p">,</span> <span class="s1">'error'</span><span class="p">],</span> <span class="nx">defaultFlashVersion</span> <span class="o">=</span> <span class="mi">8</span><span class="p">,</span> <span class="nx">disableObject</span><span class="p">,</span> <span class="nx">failSafely</span><span class="p">,</span> <span class="nx">normalizeMovieURL</span><span class="p">,</span> <span class="nx">oRemoved</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">oRemovedHTML</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">str</span><span class="p">,</span> <span class="nx">flashBlockHandler</span><span class="p">,</span> <span class="nx">getSWFCSS</span><span class="p">,</span> <span class="nx">swfCSS</span><span class="p">,</span> <span class="nx">toggleDebug</span><span class="p">,</span> <span class="nx">loopFix</span><span class="p">,</span> <span class="nx">policyFix</span><span class="p">,</span> <span class="nx">complain</span><span class="p">,</span> <span class="nx">idCheck</span><span class="p">,</span> <span class="nx">waitingForEI</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">initPending</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">startTimer</span><span class="p">,</span> <span class="nx">stopTimer</span><span class="p">,</span> <span class="nx">timerExecute</span><span class="p">,</span> <span class="nx">h5TimerCount</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">h5IntervalTimer</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">parseURL</span><span class="p">,</span> <span class="nx">messages</span> <span class="o">=</span> <span class="p">[],</span>
|
|
<span class="nx">needsFlash</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">featureCheck</span><span class="p">,</span> <span class="nx">html5OK</span><span class="p">,</span> <span class="nx">html5CanPlay</span><span class="p">,</span> <span class="nx">html5Ext</span><span class="p">,</span> <span class="nx">html5Unload</span><span class="p">,</span> <span class="nx">domContentLoadedIE</span><span class="p">,</span> <span class="nx">testHTML5</span><span class="p">,</span> <span class="nx">event</span><span class="p">,</span> <span class="nx">slice</span> <span class="o">=</span> <span class="nb">Array</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">slice</span><span class="p">,</span> <span class="nx">useGlobalHTML5Audio</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">lastGlobalHTML5URL</span><span class="p">,</span> <span class="nx">hasFlash</span><span class="p">,</span> <span class="nx">detectFlash</span><span class="p">,</span> <span class="nx">badSafariFix</span><span class="p">,</span> <span class="nx">html5_events</span><span class="p">,</span> <span class="nx">showSupport</span><span class="p">,</span> <span class="nx">flushMessages</span><span class="p">,</span>
|
|
<span class="nx">is_iDevice</span> <span class="o">=</span> <span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/(ipad|iphone|ipod)/i</span><span class="p">),</span> <span class="nx">isAndroid</span> <span class="o">=</span> <span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/android/i</span><span class="p">),</span> <span class="nx">isIE</span> <span class="o">=</span> <span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/msie/i</span><span class="p">),</span> <span class="nx">isWebkit</span> <span class="o">=</span> <span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/webkit/i</span><span class="p">),</span> <span class="nx">isSafari</span> <span class="o">=</span> <span class="p">(</span><span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/safari/i</span><span class="p">)</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/chrome/i</span><span class="p">)),</span> <span class="nx">isOpera</span> <span class="o">=</span> <span class="p">(</span><span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/opera/i</span><span class="p">)),</span>
|
|
<span class="nx">mobileHTML5</span> <span class="o">=</span> <span class="p">(</span><span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/(mobile|pre\/|xoom)/i</span><span class="p">)</span> <span class="o">||</span> <span class="nx">is_iDevice</span> <span class="o">||</span> <span class="nx">isAndroid</span><span class="p">),</span>
|
|
<span class="nx">isBadSafari</span> <span class="o">=</span> <span class="p">(</span><span class="o">!</span><span class="nx">wl</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/usehtml5audio/i</span><span class="p">)</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">wl</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/sm2\-ignorebadua/i</span><span class="p">)</span> <span class="o">&&</span> <span class="nx">isSafari</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/silk/i</span><span class="p">)</span> <span class="o">&&</span> <span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/OS X 10_6_([3-7])/i</span><span class="p">)),</span> <span class="c1">// Safari 4 and 5 (excluding Kindle Fire, "Silk") occasionally fail to load/play HTML5 audio on Snow Leopard 10.6.3 through 10.6.7 due to bug(s) in QuickTime X and/or other underlying frameworks. :/ Confirmed bug. https://bugs.webkit.org/show_bug.cgi?id=32159</span>
|
|
<span class="nx">hasConsole</span> <span class="o">=</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">console</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">),</span> <span class="nx">isFocused</span> <span class="o">=</span> <span class="p">(</span><span class="nx">doc</span><span class="p">.</span><span class="nx">hasFocus</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="o">?</span><span class="nx">doc</span><span class="p">.</span><span class="nx">hasFocus</span><span class="p">()</span><span class="o">:</span><span class="kc">null</span><span class="p">),</span> <span class="nx">tryInitOnFocus</span> <span class="o">=</span> <span class="p">(</span><span class="nx">isSafari</span> <span class="o">&&</span> <span class="p">(</span><span class="nx">doc</span><span class="p">.</span><span class="nx">hasFocus</span> <span class="o">===</span> <span class="nx">_undefined</span> <span class="o">||</span> <span class="o">!</span><span class="nx">doc</span><span class="p">.</span><span class="nx">hasFocus</span><span class="p">())),</span> <span class="nx">okToDisable</span> <span class="o">=</span> <span class="o">!</span><span class="nx">tryInitOnFocus</span><span class="p">,</span> <span class="nx">flashMIME</span> <span class="o">=</span> <span class="sr">/(mp3|mp4|mpa|m4a|m4b)/i</span><span class="p">,</span>
|
|
<span class="nx">emptyURL</span> <span class="o">=</span> <span class="s1">'about:blank'</span><span class="p">,</span> <span class="c1">// safe URL to unload, or load nothing from (flash 8 + most HTML5 UAs)</span>
|
|
<span class="nx">overHTTP</span> <span class="o">=</span> <span class="p">(</span><span class="nx">doc</span><span class="p">.</span><span class="nx">location</span><span class="o">?</span><span class="nx">doc</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">protocol</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/http/i</span><span class="p">)</span><span class="o">:</span><span class="kc">null</span><span class="p">),</span>
|
|
<span class="nx">http</span> <span class="o">=</span> <span class="p">(</span><span class="o">!</span><span class="nx">overHTTP</span> <span class="o">?</span> <span class="s1">'http:/'</span><span class="o">+</span><span class="s1">'/'</span> <span class="o">:</span> <span class="s1">''</span><span class="p">),</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-20'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-20">¶</a>
|
|
</div>
|
|
<p>mp3, mp4, aac etc.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">netStreamMimeTypes</span> <span class="o">=</span> <span class="sr">/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i</span><span class="p">,</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-21'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-21">¶</a>
|
|
</div>
|
|
<p>Flash v9.0r115+ “moviestar” formats</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">netStreamTypes</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'mpeg4'</span><span class="p">,</span> <span class="s1">'aac'</span><span class="p">,</span> <span class="s1">'flv'</span><span class="p">,</span> <span class="s1">'mov'</span><span class="p">,</span> <span class="s1">'mp4'</span><span class="p">,</span> <span class="s1">'m4v'</span><span class="p">,</span> <span class="s1">'f4v'</span><span class="p">,</span> <span class="s1">'m4a'</span><span class="p">,</span> <span class="s1">'m4b'</span><span class="p">,</span> <span class="s1">'mp4v'</span><span class="p">,</span> <span class="s1">'3gp'</span><span class="p">,</span> <span class="s1">'3g2'</span><span class="p">],</span>
|
|
<span class="nx">netStreamPattern</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="s1">'\\.('</span> <span class="o">+</span> <span class="nx">netStreamTypes</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">'|'</span><span class="p">)</span> <span class="o">+</span> <span class="s1">')(\\?.*)?$'</span><span class="p">,</span> <span class="s1">'i'</span><span class="p">);</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">mimePattern</span> <span class="o">=</span> <span class="sr">/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i</span><span class="p">;</span> <span class="c1">// default mp3 set</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-22'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-22">¶</a>
|
|
</div>
|
|
<p>use altURL if not “online”</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">useAltURL</span> <span class="o">=</span> <span class="o">!</span><span class="nx">overHTTP</span><span class="p">;</span>
|
|
|
|
<span class="nx">swfCSS</span> <span class="o">=</span> <span class="p">{</span>
|
|
|
|
<span class="s1">'swfBox'</span><span class="o">:</span> <span class="s1">'sm2-object-box'</span><span class="p">,</span>
|
|
<span class="s1">'swfDefault'</span><span class="o">:</span> <span class="s1">'movieContainer'</span><span class="p">,</span>
|
|
<span class="s1">'swfError'</span><span class="o">:</span> <span class="s1">'swf_error'</span><span class="p">,</span> <span class="c1">// SWF loaded, but SM2 couldn't start (other error)</span>
|
|
<span class="s1">'swfTimedout'</span><span class="o">:</span> <span class="s1">'swf_timedout'</span><span class="p">,</span>
|
|
<span class="s1">'swfLoaded'</span><span class="o">:</span> <span class="s1">'swf_loaded'</span><span class="p">,</span>
|
|
<span class="s1">'swfUnblocked'</span><span class="o">:</span> <span class="s1">'swf_unblocked'</span><span class="p">,</span> <span class="c1">// or loaded OK</span>
|
|
<span class="s1">'sm2Debug'</span><span class="o">:</span> <span class="s1">'sm2_debug'</span><span class="p">,</span>
|
|
<span class="s1">'highPerf'</span><span class="o">:</span> <span class="s1">'high_performance'</span><span class="p">,</span>
|
|
<span class="s1">'flashDebug'</span><span class="o">:</span> <span class="s1">'flash_debug'</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-23'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-23">¶</a>
|
|
</div>
|
|
<p>basic HTML5 Audio() support test
|
|
try…catch because of IE 9 “not implemented” nonsense
|
|
https://github.com/Modernizr/Modernizr/issues/224</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">hasHTML5</span> <span class="o">=</span> <span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
<span class="k">try</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-24'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-24">¶</a>
|
|
</div>
|
|
<p>new Audio(null) for stupid Opera 9.64 case, which throws not<em>enough</em>arguments exception otherwise.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="p">(</span><span class="nx">Audio</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="p">(</span><span class="nx">isOpera</span> <span class="o">&&</span> <span class="nx">opera</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="nx">opera</span><span class="p">.</span><span class="nx">version</span><span class="p">()</span> <span class="o"><</span> <span class="mi">10</span> <span class="o">?</span> <span class="k">new</span> <span class="nx">Audio</span><span class="p">(</span><span class="kc">null</span><span class="p">)</span> <span class="o">:</span> <span class="k">new</span> <span class="nx">Audio</span><span class="p">()).</span><span class="nx">canPlayType</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}());</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-Public_SoundManager_API'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-Public_SoundManager_API">¶</a>
|
|
</div>
|
|
<h2>Public SoundManager API</h2>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-26'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-26">¶</a>
|
|
</div>
|
|
<p>Configures top-level soundManager properties.</p>
|
|
|
|
<p>@param {object} options Option parameters, eg. { flashVersion: 9, url: ‘/path/to/swfs/’ }
|
|
onready and ontimeout are also accepted parameters. call soundManager.setup() to see the full list.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">setup</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">noURL</span> <span class="o">=</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">url</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-27'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-27">¶</a>
|
|
</div>
|
|
<p>warn if flash options have already been applied</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">options</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="nx">didInit</span> <span class="o">&&</span> <span class="nx">needsFlash</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">ok</span><span class="p">()</span> <span class="o">&&</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">flashVersion</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">||</span> <span class="nx">options</span><span class="p">.</span><span class="nx">url</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">||</span> <span class="nx">options</span><span class="p">.</span><span class="nx">html5Test</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">complain</span><span class="p">(</span><span class="nx">str</span><span class="p">(</span><span class="s1">'setupLate'</span><span class="p">));</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-28'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-28">¶</a>
|
|
</div>
|
|
<p>TODO: defer: true?</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">assign</span><span class="p">(</span><span class="nx">options</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-29'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-29">¶</a>
|
|
</div>
|
|
<p>special case 1: “Late setup”. SM2 loaded normally, but user didn’t assign flash URL eg., setup({url:…}) before SM2 init. Treat as delayed init.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">noURL</span> <span class="o">&&</span> <span class="nx">didDCLoaded</span> <span class="o">&&</span> <span class="nx">options</span><span class="p">.</span><span class="nx">url</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">beginDelayedInit</span><span class="p">();</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-30'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-30">¶</a>
|
|
</div>
|
|
<p>special case 2: If lazy-loading SM2 (DOMContentLoaded has already happened) and user calls setup() with url: parameter, try to init ASAP.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">didDCLoaded</span> <span class="o">&&</span> <span class="nx">options</span><span class="p">.</span><span class="nx">url</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="nx">doc</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">===</span> <span class="s1">'complete'</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">setTimeout</span><span class="p">(</span><span class="nx">domContentLoaded</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">ok</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">return</span> <span class="p">(</span><span class="nx">needsFlash</span><span class="o">?</span><span class="p">(</span><span class="nx">didInit</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">disabled</span><span class="p">)</span><span class="o">:</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useHTML5Audio</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">hasHTML5</span><span class="p">));</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">supported</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">ok</span><span class="p">;</span> <span class="c1">// legacy</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">getMovie</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">smID</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-31'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-31">¶</a>
|
|
</div>
|
|
<p>safety net: some old browsers differ on SWF references, possibly related to ExternalInterface / flash version</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="nx">id</span><span class="p">(</span><span class="nx">smID</span><span class="p">)</span> <span class="o">||</span> <span class="nx">doc</span><span class="p">[</span><span class="nx">smID</span><span class="p">]</span> <span class="o">||</span> <span class="nb">window</span><span class="p">[</span><span class="nx">smID</span><span class="p">];</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-32'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-32">¶</a>
|
|
</div>
|
|
<p>Creates a SMSound sound object instance.</p>
|
|
|
|
<p>@param {object} oOptions Sound options (at minimum, id and url parameters are required.)
|
|
@return {object} SMSound The new SMSound object.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">createSound</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">,</span> <span class="nx">_url</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">cs</span><span class="p">,</span> <span class="nx">cs_string</span><span class="p">,</span> <span class="nx">options</span><span class="p">,</span> <span class="nx">oSound</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-33'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-33">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">cs</span> <span class="o">=</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.createSound(): '</span><span class="p">;</span>
|
|
<span class="nx">cs_string</span> <span class="o">=</span> <span class="nx">cs</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="o">!</span><span class="nx">didInit</span><span class="o">?</span><span class="s1">'notReady'</span><span class="o">:</span><span class="s1">'notOK'</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-34'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-34">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">didInit</span> <span class="o">||</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">ok</span><span class="p">())</span> <span class="p">{</span>
|
|
<span class="nx">complain</span><span class="p">(</span><span class="nx">cs_string</span><span class="p">);</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">_url</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-35'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-35">¶</a>
|
|
</div>
|
|
<p>function overloading in JS! :) ..assume simple createSound(id,url) use case</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">oOptions</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="s1">'id'</span><span class="o">:</span> <span class="nx">oOptions</span><span class="p">,</span>
|
|
<span class="s1">'url'</span><span class="o">:</span> <span class="nx">_url</span>
|
|
<span class="p">};</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-36'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-36">¶</a>
|
|
</div>
|
|
<p>inherit from defaultOptions</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">options</span> <span class="o">=</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">);</span>
|
|
|
|
<span class="nx">options</span><span class="p">.</span><span class="nx">url</span> <span class="o">=</span> <span class="nx">parseURL</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">url</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-37'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-37">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">id</span><span class="p">.</span><span class="nx">toString</span><span class="p">().</span><span class="nx">charAt</span><span class="p">(</span><span class="mi">0</span><span class="p">).</span><span class="nx">match</span><span class="p">(</span><span class="sr">/^[0-9]$/</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">cs</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="s1">'badID'</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">id</span><span class="p">),</span> <span class="mi">2</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">cs</span> <span class="o">+</span> <span class="nx">options</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">' ('</span> <span class="o">+</span> <span class="nx">options</span><span class="p">.</span><span class="nx">url</span> <span class="o">+</span> <span class="s1">')'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-38'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-38">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="kc">true</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">cs</span> <span class="o">+</span> <span class="nx">options</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">' exists'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">options</span><span class="p">.</span><span class="nx">id</span><span class="p">];</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">function</span> <span class="nx">make</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">options</span> <span class="o">=</span> <span class="nx">loopFix</span><span class="p">(</span><span class="nx">options</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">options</span><span class="p">.</span><span class="nx">id</span><span class="p">]</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">SMSound</span><span class="p">(</span><span class="nx">options</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">id</span><span class="p">);</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">options</span><span class="p">.</span><span class="nx">id</span><span class="p">];</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">html5OK</span><span class="p">(</span><span class="nx">options</span><span class="p">))</span> <span class="p">{</span>
|
|
|
|
<span class="nx">oSound</span> <span class="o">=</span> <span class="nx">make</span><span class="p">();</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Using HTML5'</span><span class="p">);</span>
|
|
<span class="nx">oSound</span><span class="p">.</span><span class="nx">_setup_html5</span><span class="p">(</span><span class="nx">options</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">fV</span> <span class="o">></span> <span class="mi">8</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">isMovieStar</span> <span class="o">===</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-39'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-39">¶</a>
|
|
</div>
|
|
<p>attempt to detect MPEG-4 formats</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">options</span><span class="p">.</span><span class="nx">isMovieStar</span> <span class="o">=</span> <span class="o">!!</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">serverURL</span> <span class="o">||</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">type</span> <span class="o">?</span> <span class="nx">options</span><span class="p">.</span><span class="nx">type</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="nx">netStreamMimeTypes</span><span class="p">)</span> <span class="o">:</span> <span class="kc">false</span><span class="p">)</span> <span class="o">||</span> <span class="nx">options</span><span class="p">.</span><span class="nx">url</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="nx">netStreamPattern</span><span class="p">));</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-40'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-40">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">isMovieStar</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">cs</span> <span class="o">+</span> <span class="s1">'using MovieStar handling'</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">loops</span> <span class="o">></span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'noNSLoop'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-41'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-41">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">}</span>
|
|
|
|
<span class="nx">options</span> <span class="o">=</span> <span class="nx">policyFix</span><span class="p">(</span><span class="nx">options</span><span class="p">,</span> <span class="nx">cs</span><span class="p">);</span>
|
|
<span class="nx">oSound</span> <span class="o">=</span> <span class="nx">make</span><span class="p">();</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">fV</span> <span class="o">===</span> <span class="mi">8</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_createSound</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">loops</span><span class="o">||</span><span class="mi">1</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">usePolicyFile</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_createSound</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">url</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">usePeakData</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">useWaveformData</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">useEQData</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">isMovieStar</span><span class="p">,</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">isMovieStar</span><span class="o">?</span><span class="nx">options</span><span class="p">.</span><span class="nx">bufferTime</span><span class="o">:</span><span class="kc">false</span><span class="p">),</span> <span class="nx">options</span><span class="p">.</span><span class="nx">loops</span><span class="o">||</span><span class="mi">1</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">serverURL</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">duration</span><span class="o">||</span><span class="kc">null</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">autoPlay</span><span class="p">,</span> <span class="kc">true</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">autoLoad</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">usePolicyFile</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">options</span><span class="p">.</span><span class="nx">serverURL</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-42'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-42">¶</a>
|
|
</div>
|
|
<p>We are connected immediately</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">oSound</span><span class="p">.</span><span class="nx">connected</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">onconnect</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">options</span><span class="p">.</span><span class="nx">onconnect</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">oSound</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">options</span><span class="p">.</span><span class="nx">serverURL</span> <span class="o">&&</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">autoLoad</span> <span class="o">||</span> <span class="nx">options</span><span class="p">.</span><span class="nx">autoPlay</span><span class="p">))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-43'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-43">¶</a>
|
|
</div>
|
|
<p>call load for non-rtmp streams</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">oSound</span><span class="p">.</span><span class="nx">load</span><span class="p">(</span><span class="nx">options</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-44'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-44">¶</a>
|
|
</div>
|
|
<p>rtmp will play in onconnect</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">options</span><span class="p">.</span><span class="nx">serverURL</span> <span class="o">&&</span> <span class="nx">options</span><span class="p">.</span><span class="nx">autoPlay</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oSound</span><span class="p">.</span><span class="nx">play</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">oSound</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-45'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-45">¶</a>
|
|
</div>
|
|
<p>Destroys a SMSound sound object instance.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound to destroy</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">destroySound</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">,</span> <span class="nx">_bFromSound</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-46'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-46">¶</a>
|
|
</div>
|
|
<p>explicitly destroy a sound before normal page unload, etc.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">oS</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">],</span> <span class="nx">i</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-47'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-47">¶</a>
|
|
</div>
|
|
<p>Disable all callbacks while the sound is being destroyed</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">oS</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">=</span> <span class="p">{};</span>
|
|
|
|
<span class="nx">oS</span><span class="p">.</span><span class="nx">stop</span><span class="p">();</span>
|
|
<span class="nx">oS</span><span class="p">.</span><span class="nx">unload</span><span class="p">();</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">===</span> <span class="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="k">break</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">_bFromSound</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-48'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-48">¶</a>
|
|
</div>
|
|
<p>ignore if being called from SMSound instance</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">oS</span><span class="p">.</span><span class="nx">destruct</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">oS</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="k">delete</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">];</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-49'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-49">¶</a>
|
|
</div>
|
|
<p>Calls the load() method of a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound
|
|
@param {object} oOptions Optional: Sound options</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">load</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">,</span> <span class="nx">oOptions</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">load</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-50'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-50">¶</a>
|
|
</div>
|
|
<p>Calls the unload() method of a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">unload</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">unload</span><span class="p">();</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-51'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-51">¶</a>
|
|
</div>
|
|
<p>Calls the onPosition() method of a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound
|
|
@param {number} nPosition The position to watch for
|
|
@param {function} oMethod The relevant callback to fire
|
|
@param {object} oScope Optional: The scope to apply the callback to
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">onPosition</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">,</span> <span class="nx">nPosition</span><span class="p">,</span> <span class="nx">oMethod</span><span class="p">,</span> <span class="nx">oScope</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">onposition</span><span class="p">(</span><span class="nx">nPosition</span><span class="p">,</span> <span class="nx">oMethod</span><span class="p">,</span> <span class="nx">oScope</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-52'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-52">¶</a>
|
|
</div>
|
|
<p>legacy/backwards-compability: lower-case method name</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">onposition</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">onPosition</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-53'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-53">¶</a>
|
|
</div>
|
|
<p>Calls the clearOnPosition() method of a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound
|
|
@param {number} nPosition The position to watch for
|
|
@param {function} oMethod Optional: The relevant callback to fire
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">clearOnPosition</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">,</span> <span class="nx">nPosition</span><span class="p">,</span> <span class="nx">oMethod</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">clearOnPosition</span><span class="p">(</span><span class="nx">nPosition</span><span class="p">,</span> <span class="nx">oMethod</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-54'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-54">¶</a>
|
|
</div>
|
|
<p>Calls the play() method of a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound
|
|
@param {object} oOptions Optional: Sound options
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">play</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">,</span> <span class="nx">oOptions</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">result</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">didInit</span> <span class="o">||</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">ok</span><span class="p">())</span> <span class="p">{</span>
|
|
<span class="nx">complain</span><span class="p">(</span><span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.play(): '</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="o">!</span><span class="nx">didInit</span><span class="o">?</span><span class="s1">'notReady'</span><span class="o">:</span><span class="s1">'notOK'</span><span class="p">));</span>
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="nx">oOptions</span> <span class="k">instanceof</span> <span class="nb">Object</span><span class="p">))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-55'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-55">¶</a>
|
|
</div>
|
|
<p>overloading use case: play(‘mySound’,‘/path/to/some.mp3’);</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">oOptions</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="nx">url</span><span class="o">:</span> <span class="nx">oOptions</span>
|
|
<span class="p">};</span>
|
|
<span class="p">}</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">oOptions</span> <span class="o">&&</span> <span class="nx">oOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-56'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-56">¶</a>
|
|
</div>
|
|
<p>overloading use case, create+play: .play(‘someID’,{url:‘/path/to.mp3’});</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.play(): attempting to create "'</span> <span class="o">+</span> <span class="nx">sID</span> <span class="o">+</span> <span class="s1">'"'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="nx">oOptions</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">sID</span><span class="p">;</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">createSound</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">).</span><span class="nx">play</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">play</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">start</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">play</span><span class="p">;</span> <span class="c1">// just for convenience</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-57'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-57">¶</a>
|
|
</div>
|
|
<p>Calls the setPosition() method of a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound
|
|
@param {number} nMsecOffset Position (milliseconds)
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">setPosition</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">,</span> <span class="nx">nMsecOffset</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">setPosition</span><span class="p">(</span><span class="nx">nMsecOffset</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-58'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-58">¶</a>
|
|
</div>
|
|
<p>Calls the stop() method of a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">stop</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.stop('</span> <span class="o">+</span> <span class="nx">sID</span> <span class="o">+</span> <span class="s1">')'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">stop</span><span class="p">();</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-59'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-59">¶</a>
|
|
</div>
|
|
<p>Stops all currently-playing sounds.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">stopAll</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">oSound</span><span class="p">;</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.stopAll()'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">oSound</span> <span class="k">in</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">oSound</span><span class="p">))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-60'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-60">¶</a>
|
|
</div>
|
|
<p>apply only to sound objects</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">oSound</span><span class="p">].</span><span class="nx">stop</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-61'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-61">¶</a>
|
|
</div>
|
|
<p>Calls the pause() method of a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">pause</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">pause</span><span class="p">();</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-62'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-62">¶</a>
|
|
</div>
|
|
<p>Pauses all currently-playing sounds.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">pauseAll</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">i</span><span class="p">;</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">>=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">[</span><span class="nx">i</span><span class="p">]].</span><span class="nx">pause</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-63'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-63">¶</a>
|
|
</div>
|
|
<p>Calls the resume() method of a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">resume</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">resume</span><span class="p">();</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-64'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-64">¶</a>
|
|
</div>
|
|
<p>Resumes all currently-paused sounds.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">resumeAll</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">i</span><span class="p">;</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">>=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">[</span><span class="nx">i</span><span class="p">]].</span><span class="nx">resume</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-65'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-65">¶</a>
|
|
</div>
|
|
<p>Calls the togglePause() method of a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">togglePause</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">togglePause</span><span class="p">();</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-66'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-66">¶</a>
|
|
</div>
|
|
<p>Calls the setPan() method of a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound
|
|
@param {number} nPan The pan value (-100 to 100)
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">setPan</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">,</span> <span class="nx">nPan</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">setPan</span><span class="p">(</span><span class="nx">nPan</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-67'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-67">¶</a>
|
|
</div>
|
|
<p>Calls the setVolume() method of a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound
|
|
@param {number} nVol The volume value (0 to 100)
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">setVolume</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">,</span> <span class="nx">nVol</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">setVolume</span><span class="p">(</span><span class="nx">nVol</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-68'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-68">¶</a>
|
|
</div>
|
|
<p>Calls the mute() method of either a single SMSound object by ID, or all sound objects.</p>
|
|
|
|
<p>@param {string} sID Optional: The ID of the sound (if omitted, all sounds will be used.)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">mute</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sID</span> <span class="k">instanceof</span> <span class="nb">String</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sID</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.mute(): Muting all sounds'</span><span class="p">);</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">>=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">[</span><span class="nx">i</span><span class="p">]].</span><span class="nx">mute</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">muted</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.mute(): Muting "'</span> <span class="o">+</span> <span class="nx">sID</span> <span class="o">+</span> <span class="s1">'"'</span><span class="p">);</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">mute</span><span class="p">();</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-69'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-69">¶</a>
|
|
</div>
|
|
<p>Mutes all sounds.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">muteAll</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">mute</span><span class="p">();</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-70'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-70">¶</a>
|
|
</div>
|
|
<p>Calls the unmute() method of either a single SMSound object by ID, or all sound objects.</p>
|
|
|
|
<p>@param {string} sID Optional: The ID of the sound (if omitted, all sounds will be used.)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">unmute</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">i</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sID</span> <span class="k">instanceof</span> <span class="nb">String</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sID</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.unmute(): Unmuting all sounds'</span><span class="p">);</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">>=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">[</span><span class="nx">i</span><span class="p">]].</span><span class="nx">unmute</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">muted</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.unmute(): Unmuting "'</span> <span class="o">+</span> <span class="nx">sID</span> <span class="o">+</span> <span class="s1">'"'</span><span class="p">);</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">unmute</span><span class="p">();</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-71'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-71">¶</a>
|
|
</div>
|
|
<p>Unmutes all sounds.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">unmuteAll</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">unmute</span><span class="p">();</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-72'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-72">¶</a>
|
|
</div>
|
|
<p>Calls the toggleMute() method of a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">toggleMute</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">sID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">].</span><span class="nx">toggleMute</span><span class="p">();</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-73'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-73">¶</a>
|
|
</div>
|
|
<p>Retrieves the memory used by the flash plugin.</p>
|
|
|
|
<p>@return {number} The amount of memory in use</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">getMemoryUse</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-74'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-74">¶</a>
|
|
</div>
|
|
<p>flash-only</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">ram</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">flash</span> <span class="o">&&</span> <span class="nx">fV</span> <span class="o">!==</span> <span class="mi">8</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">ram</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">flash</span><span class="p">.</span><span class="nx">_getMemoryUse</span><span class="p">(),</span> <span class="mi">10</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">ram</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-75'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-75">¶</a>
|
|
</div>
|
|
<p>Undocumented: NOPs soundManager and all SMSound objects.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">disable</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">bNoDisable</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-76'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-76">¶</a>
|
|
</div>
|
|
<p>destroy all functions</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">i</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">bNoDisable</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">bNoDisable</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">disabled</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">disabled</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'shutdown'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">>=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">disableObject</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">[</span><span class="nx">i</span><span class="p">]]);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-77'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-77">¶</a>
|
|
</div>
|
|
<p>fire “complete”, despite fail</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">initComplete</span><span class="p">(</span><span class="nx">bNoDisable</span><span class="p">);</span>
|
|
<span class="nx">event</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="s1">'load'</span><span class="p">,</span> <span class="nx">initUserOnload</span><span class="p">);</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-78'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-78">¶</a>
|
|
</div>
|
|
<p>Determines playability of a MIME type, eg. ‘audio/mp3’.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">canPlayMIME</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sMIME</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">hasHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="nx">html5CanPlay</span><span class="p">({</span><span class="nx">type</span><span class="o">:</span><span class="nx">sMIME</span><span class="p">});</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">result</span> <span class="o">&&</span> <span class="nx">needsFlash</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-79'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-79">¶</a>
|
|
</div>
|
|
<p>if flash 9, test netStream (movieStar) types as well.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">result</span> <span class="o">=</span> <span class="p">(</span><span class="nx">sMIME</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">ok</span><span class="p">()</span> <span class="o">?</span> <span class="o">!!</span><span class="p">((</span><span class="nx">fV</span> <span class="o">></span> <span class="mi">8</span> <span class="o">?</span> <span class="nx">sMIME</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="nx">netStreamMimeTypes</span><span class="p">)</span> <span class="o">:</span> <span class="kc">null</span><span class="p">)</span> <span class="o">||</span> <span class="nx">sMIME</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">mimePattern</span><span class="p">))</span> <span class="o">:</span> <span class="kc">null</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-80'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-80">¶</a>
|
|
</div>
|
|
<p>Determines playability of a URL based on audio support.</p>
|
|
|
|
<p>@param {string} sURL The URL to test
|
|
@return {boolean} URL playability</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">canPlayURL</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sURL</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">hasHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="nx">html5CanPlay</span><span class="p">({</span><span class="nx">url</span><span class="o">:</span> <span class="nx">sURL</span><span class="p">});</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">result</span> <span class="o">&&</span> <span class="nx">needsFlash</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="p">(</span><span class="nx">sURL</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">ok</span><span class="p">()</span> <span class="o">?</span> <span class="o">!!</span><span class="p">(</span><span class="nx">sURL</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">filePattern</span><span class="p">))</span> <span class="o">:</span> <span class="kc">null</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-81'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-81">¶</a>
|
|
</div>
|
|
<p>Determines playability of an HTML DOM <a> object (or similar object literal) based on audio support.</p>
|
|
|
|
<p>@param {object} oLink an HTML DOM <a> object or object literal including href and/or type attributes
|
|
@return {boolean} URL playability</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">canPlayLink</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oLink</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">oLink</span><span class="p">.</span><span class="nx">type</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="nx">oLink</span><span class="p">.</span><span class="nx">type</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">canPlayMIME</span><span class="p">(</span><span class="nx">oLink</span><span class="p">.</span><span class="nx">type</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">canPlayURL</span><span class="p">(</span><span class="nx">oLink</span><span class="p">.</span><span class="nx">href</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-82'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-82">¶</a>
|
|
</div>
|
|
<p>Retrieves a SMSound object by ID.</p>
|
|
|
|
<p>@param {string} sID The ID of the sound
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">getSoundById</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">,</span> <span class="nx">_suppressDebug</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.getSoundById(): sID is null/_undefined'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">result</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sID</span><span class="p">];</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-83'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-83">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">result</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">_suppressDebug</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="s1">'"'</span> <span class="o">+</span> <span class="nx">sID</span> <span class="o">+</span> <span class="s1">'" is an invalid sound ID.'</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-84'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-84">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-85'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-85">¶</a>
|
|
</div>
|
|
<p>Queues a callback for execution when SoundManager has successfully initialized.</p>
|
|
|
|
<p>@param {function} oMethod The callback method to fire
|
|
@param {object} oScope Optional: The scope to apply to the callback</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">onready</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oMethod</span><span class="p">,</span> <span class="nx">oScope</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="s1">'onready'</span><span class="p">,</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">oMethod</span> <span class="o">===</span> <span class="s1">'function'</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-86'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-86">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">didInit</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">str</span><span class="p">(</span><span class="s1">'queue'</span><span class="p">,</span> <span class="nx">sType</span><span class="p">));</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-87'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-87">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">oScope</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oScope</span> <span class="o">=</span> <span class="nb">window</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">addOnEvent</span><span class="p">(</span><span class="nx">sType</span><span class="p">,</span> <span class="nx">oMethod</span><span class="p">,</span> <span class="nx">oScope</span><span class="p">);</span>
|
|
<span class="nx">processOnEvents</span><span class="p">();</span>
|
|
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="k">throw</span> <span class="nx">str</span><span class="p">(</span><span class="s1">'needFunction'</span><span class="p">,</span> <span class="nx">sType</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-88'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-88">¶</a>
|
|
</div>
|
|
<p>Queues a callback for execution when SoundManager has failed to initialize.</p>
|
|
|
|
<p>@param {function} oMethod The callback method to fire
|
|
@param {object} oScope Optional: The scope to apply to the callback</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">ontimeout</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oMethod</span><span class="p">,</span> <span class="nx">oScope</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="s1">'ontimeout'</span><span class="p">,</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">oMethod</span> <span class="o">===</span> <span class="s1">'function'</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-89'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-89">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">didInit</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">str</span><span class="p">(</span><span class="s1">'queue'</span><span class="p">,</span> <span class="nx">sType</span><span class="p">));</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-90'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-90">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">oScope</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oScope</span> <span class="o">=</span> <span class="nb">window</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">addOnEvent</span><span class="p">(</span><span class="nx">sType</span><span class="p">,</span> <span class="nx">oMethod</span><span class="p">,</span> <span class="nx">oScope</span><span class="p">);</span>
|
|
<span class="nx">processOnEvents</span><span class="p">({</span><span class="nx">type</span><span class="o">:</span><span class="nx">sType</span><span class="p">});</span>
|
|
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="k">throw</span> <span class="nx">str</span><span class="p">(</span><span class="s1">'needFunction'</span><span class="p">,</span> <span class="nx">sType</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-91'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-91">¶</a>
|
|
</div>
|
|
<p>Writes console.log()-style debug output to a console or in-browser element.
|
|
Applies when debugMode = true</p>
|
|
|
|
<p>@param {string} sText The console message
|
|
@param {object} sType Optional string: Log type of ‘info’, ‘warn’ or ‘error’, or object (to be dumped)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_writeDebug</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sText</span><span class="p">,</span> <span class="nx">sType</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-92'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-92">¶</a>
|
|
</div>
|
|
<p>pseudo-private console.log()-style output
|
|
<d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">sDID</span> <span class="o">=</span> <span class="s1">'soundmanager-debug'</span><span class="p">,</span> <span class="nx">o</span><span class="p">,</span> <span class="nx">oItem</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugMode</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">hasConsole</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">useConsole</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sType</span> <span class="o">&&</span> <span class="k">typeof</span> <span class="nx">sType</span> <span class="o">===</span> <span class="s1">'object'</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-93'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-93">¶</a>
|
|
</div>
|
|
<p>object passed; dump to console.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">sText</span><span class="p">,</span> <span class="nx">sType</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">debugLevels</span><span class="p">[</span><span class="nx">sType</span><span class="p">]</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">console</span><span class="p">[</span><span class="nx">debugLevels</span><span class="p">[</span><span class="nx">sType</span><span class="p">]](</span><span class="nx">sText</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">sText</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">consoleOnly</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">o</span> <span class="o">=</span> <span class="nx">id</span><span class="p">(</span><span class="nx">sDID</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">oItem</span> <span class="o">=</span> <span class="nx">doc</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">'div'</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">++</span><span class="nx">wdCount</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oItem</span><span class="p">.</span><span class="nx">className</span> <span class="o">=</span> <span class="s1">'sm2-alt'</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sType</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sType</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">sType</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">sType</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">oItem</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">doc</span><span class="p">.</span><span class="nx">createTextNode</span><span class="p">(</span><span class="nx">sText</span><span class="p">));</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sType</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sType</span> <span class="o">>=</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oItem</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">fontWeight</span> <span class="o">=</span> <span class="s1">'bold'</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sType</span> <span class="o">===</span> <span class="mi">3</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oItem</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">color</span> <span class="o">=</span> <span class="s1">'#ff3333'</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-94'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-94">¶</a>
|
|
</div>
|
|
<p>top-to-bottom
|
|
o.appendChild(oItem);</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-95'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-95">¶</a>
|
|
</div>
|
|
<p>bottom-to-top</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">o</span><span class="p">.</span><span class="nx">insertBefore</span><span class="p">(</span><span class="nx">oItem</span><span class="p">,</span> <span class="nx">o</span><span class="p">.</span><span class="nx">firstChild</span><span class="p">);</span>
|
|
|
|
<span class="nx">o</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-96'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-96">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-97'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-97">¶</a>
|
|
</div>
|
|
<p><d>
|
|
last-resort debugging option</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">wl</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">'sm2-debug=alert'</span><span class="p">)</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_writeDebug</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sText</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nb">window</span><span class="p">.</span><span class="nx">alert</span><span class="p">(</span><span class="nx">sText</span><span class="p">);</span>
|
|
<span class="p">};</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-98'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-98">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-99'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-99">¶</a>
|
|
</div>
|
|
<p>alias</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_wD</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_writeDebug</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-100'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-100">¶</a>
|
|
</div>
|
|
<p>Provides debug / state information on all SMSound objects.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_debug</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-101'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-101">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">j</span><span class="p">;</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'currentObj'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">j</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">j</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">[</span><span class="nx">i</span><span class="p">]].</span><span class="nx">_debug</span><span class="p">();</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-102'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-102">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-103'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-103">¶</a>
|
|
</div>
|
|
<p>Restarts and re-initializes the SoundManager instance.</p>
|
|
|
|
<p>@param {boolean} resetEvents Optional: When true, removes all registered onready and ontimeout event callbacks.
|
|
@param {boolean} excludeInit Options: When true, does not call beginDelayedInit() (which would restart SM2).
|
|
@return {object} soundManager The soundManager instance.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">reboot</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">resetEvents</span><span class="p">,</span> <span class="nx">excludeInit</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-104'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-104">¶</a>
|
|
</div>
|
|
<p>reset some (or all) state, and re-init unless otherwise specified.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-105'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-105">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="s1">'Destroying '</span> <span class="o">+</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">.</span><span class="nx">length</span> <span class="o">+</span> <span class="s1">' SMSound objects...'</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-106'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-106">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">j</span><span class="p">,</span> <span class="nx">k</span><span class="p">;</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">>=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">[</span><span class="nx">i</span><span class="p">]].</span><span class="nx">destruct</span><span class="p">();</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-107'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-107">¶</a>
|
|
</div>
|
|
<p>trash ze flash</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">flash</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">try</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">isIE</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oRemovedHTML</span> <span class="o">=</span> <span class="nx">flash</span><span class="p">.</span><span class="nx">innerHTML</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">oRemoved</span> <span class="o">=</span> <span class="nx">flash</span><span class="p">.</span><span class="nx">parentNode</span><span class="p">.</span><span class="nx">removeChild</span><span class="p">(</span><span class="nx">flash</span><span class="p">);</span>
|
|
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'flRemoved'</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-108'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-108">¶</a>
|
|
</div>
|
|
<p>Remove failed? May be due to flash blockers silently removing the SWF object/embed node from the DOM. Warn and continue.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">_wDS</span><span class="p">(</span><span class="s1">'badRemove'</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-109'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-109">¶</a>
|
|
</div>
|
|
<p>actually, force recreate of movie.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">oRemovedHTML</span> <span class="o">=</span> <span class="nx">oRemoved</span> <span class="o">=</span> <span class="nx">needsFlash</span> <span class="o">=</span> <span class="nx">flash</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">enabled</span> <span class="o">=</span> <span class="nx">didDCLoaded</span> <span class="o">=</span> <span class="nx">didInit</span> <span class="o">=</span> <span class="nx">waitingForEI</span> <span class="o">=</span> <span class="nx">initPending</span> <span class="o">=</span> <span class="nx">didAppend</span> <span class="o">=</span> <span class="nx">appendSuccess</span> <span class="o">=</span> <span class="nx">disabled</span> <span class="o">=</span> <span class="nx">useGlobalHTML5Audio</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">swfLoaded</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span> <span class="o">=</span> <span class="p">[];</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span> <span class="o">=</span> <span class="p">{};</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">resetEvents</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-110'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-110">¶</a>
|
|
</div>
|
|
<p>reset callbacks for onready, ontimeout etc. so that they will fire again on re-init</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">on_queue</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">on_queue</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">i</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">k</span> <span class="o">=</span> <span class="nx">on_queue</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">length</span><span class="p">;</span> <span class="nx">j</span> <span class="o"><</span> <span class="nx">k</span><span class="p">;</span> <span class="nx">j</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">on_queue</span><span class="p">[</span><span class="nx">i</span><span class="p">][</span><span class="nx">j</span><span class="p">].</span><span class="nx">fired</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-111'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-111">¶</a>
|
|
</div>
|
|
<p>remove all callbacks entirely</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">on_queue</span> <span class="o">=</span> <span class="p">[];</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-112'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-112">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">excludeInit</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">sm</span> <span class="o">+</span> <span class="s1">': Rebooting...'</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-113'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-113">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-114'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-114">¶</a>
|
|
</div>
|
|
<p>reset HTML5 and flash canPlay test results</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="s1">'usingFlash'</span><span class="o">:</span> <span class="kc">null</span>
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">flash</span> <span class="o">=</span> <span class="p">{};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-115'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-115">¶</a>
|
|
</div>
|
|
<p>reset device-specific HTML/flash mode switches</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">ignoreFlash</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="nb">window</span><span class="p">.</span><span class="nx">setTimeout</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">preInit</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-116'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-116">¶</a>
|
|
</div>
|
|
<p>by default, re-init</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">excludeInit</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">beginDelayedInit</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">},</span> <span class="mi">20</span><span class="p">);</span>
|
|
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">reset</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-117'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-117">¶</a>
|
|
</div>
|
|
<p>Shuts down and restores the SoundManager instance to its original loaded state, without an explicit reboot. All onready/ontimeout handlers are removed.
|
|
After this call, SM2 may be re-initialized via soundManager.beginDelayedInit().
|
|
@return {object} soundManager The soundManager instance.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">_wDS</span><span class="p">(</span><span class="s1">'reset'</span><span class="p">);</span>
|
|
<span class="k">return</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">reboot</span><span class="p">(</span><span class="kc">true</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-118'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-118">¶</a>
|
|
</div>
|
|
<p>Undocumented: Determines the SM2 flash movie’s load progress.</p>
|
|
|
|
<p>@return {number or null} Percent loaded, or if invalid/unsupported, null.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">getMoviePercent</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-119'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-119">¶</a>
|
|
</div>
|
|
<p>Interesting syntax notes…
|
|
Flash/ExternalInterface (ActiveX/NPAPI) bridge methods are not typeof “function” nor instanceof Function, but are still valid.
|
|
Additionally, JSLint dislikes (‘PercentLoaded’ in flash)-style syntax and recommends hasOwnProperty(), which does not work in this case.
|
|
Furthermore, using (flash && flash.PercentLoaded) causes IE to throw “object doesn’t support this property or method”.
|
|
Thus, ‘in’ syntax must be used.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="p">(</span><span class="nx">flash</span> <span class="o">&&</span> <span class="s1">'PercentLoaded'</span> <span class="k">in</span> <span class="nx">flash</span> <span class="o">?</span> <span class="nx">flash</span><span class="p">.</span><span class="nx">PercentLoaded</span><span class="p">()</span> <span class="o">:</span> <span class="kc">null</span><span class="p">);</span> <span class="c1">// Yes, JSLint. See nearby comment in source for explanation.</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-120'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-120">¶</a>
|
|
</div>
|
|
<p>Additional helper for manually invoking SM2’s init process after DOM Ready / window.onload().</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">beginDelayedInit</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">windowLoaded</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">domContentLoaded</span><span class="p">();</span>
|
|
|
|
<span class="nx">setTimeout</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">initPending</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">createMovie</span><span class="p">();</span>
|
|
<span class="nx">initMovie</span><span class="p">();</span>
|
|
<span class="nx">initPending</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">},</span> <span class="mi">20</span><span class="p">);</span>
|
|
|
|
<span class="nx">delayWaitForEI</span><span class="p">();</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-121'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-121">¶</a>
|
|
</div>
|
|
<p>Destroys the SoundManager instance and all SMSound instances.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">destruct</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.destruct()'</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">disable</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-SMSound()_(sound_object)_constructor'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-SMSound()_(sound_object)_constructor">¶</a>
|
|
</div>
|
|
<h2>SMSound() (sound object) constructor</h2>
|
|
|
|
<p>@param {object} oOptions Sound options (id and url are required attributes)
|
|
@return {SMSound} The new SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">SMSound</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="k">this</span><span class="p">,</span> <span class="nx">resetProperties</span><span class="p">,</span> <span class="nx">add_html5_events</span><span class="p">,</span> <span class="nx">remove_html5_events</span><span class="p">,</span> <span class="nx">stop_html5_timer</span><span class="p">,</span> <span class="nx">start_html5_timer</span><span class="p">,</span> <span class="nx">attachOnPosition</span><span class="p">,</span> <span class="nx">onplay_called</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">onPositionItems</span> <span class="o">=</span> <span class="p">[],</span> <span class="nx">onPositionFired</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">detachOnPosition</span><span class="p">,</span> <span class="nx">applyFromTo</span><span class="p">,</span> <span class="nx">lastURL</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">lastHTML5State</span><span class="p">;</span>
|
|
|
|
<span class="nx">lastHTML5State</span> <span class="o">=</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-123'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-123">¶</a>
|
|
</div>
|
|
<p>tracks duration + position (time)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">duration</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span>
|
|
<span class="nx">time</span><span class="o">:</span> <span class="kc">null</span>
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">oOptions</span><span class="p">.</span><span class="nx">id</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-124'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-124">¶</a>
|
|
</div>
|
|
<p>legacy</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">sID</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">id</span><span class="p">;</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">url</span> <span class="o">=</span> <span class="nx">oOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">;</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">options</span> <span class="o">=</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-125'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-125">¶</a>
|
|
</div>
|
|
<p>per-play-instance-specific options</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">instanceOptions</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-126'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-126">¶</a>
|
|
</div>
|
|
<p>short alias</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">instanceOptions</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-127'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-127">¶</a>
|
|
</div>
|
|
<p>assign property defaults</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">pan</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">pan</span><span class="p">;</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">volume</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">volume</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-128'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-128">¶</a>
|
|
</div>
|
|
<p>whether or not this object is using HTML5</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">isHTML5</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-129'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-129">¶</a>
|
|
</div>
|
|
<p>internal HTML5 Audio() object reference</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_a</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-SMSound()_public_methods'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-SMSound()_public_methods">¶</a>
|
|
</div>
|
|
<h2>SMSound() public methods</h2>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">id3</span> <span class="o">=</span> <span class="p">{};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-131'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-131">¶</a>
|
|
</div>
|
|
<p>Writes SMSound object parameters to debug console</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_debug</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-132'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-132">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Merged options:'</span><span class="p">,</span> <span class="nx">s</span><span class="p">.</span><span class="nx">options</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-133'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-133">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-134'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-134">¶</a>
|
|
</div>
|
|
<p>Begins loading a sound per its <em>url</em>.</p>
|
|
|
|
<p>@param {object} oOptions Optional: Sound options
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">load</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">oSound</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">instanceOptions</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">oOptions</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">=</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">,</span> <span class="nx">s</span><span class="p">.</span><span class="nx">options</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">oOptions</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">options</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">=</span> <span class="nx">oOptions</span><span class="p">;</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">lastURL</span> <span class="o">&&</span> <span class="nx">lastURL</span> <span class="o">!==</span> <span class="nx">s</span><span class="p">.</span><span class="nx">url</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'manURL'</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">url</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">url</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">url</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">url</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">url</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">url</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">url</span> <span class="o">=</span> <span class="nx">parseURL</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">url</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-135'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-135">¶</a>
|
|
</div>
|
|
<p>ensure we’re in sync</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">instanceOptions</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-136'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-136">¶</a>
|
|
</div>
|
|
<p>local shortcut</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">instanceOptions</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">;</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': load ('</span> <span class="o">+</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span> <span class="o">+</span> <span class="s1">')'</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span> <span class="o">===</span> <span class="nx">s</span><span class="p">.</span><span class="nx">url</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">!==</span> <span class="mi">0</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">!==</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'onURL'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-137'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-137">¶</a>
|
|
</div>
|
|
<p>if loaded and an onload() exists, fire immediately.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">===</span> <span class="mi">3</span> <span class="o">&&</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">onload</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-138'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-138">¶</a>
|
|
</div>
|
|
<p>assume success based on truthy duration.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">onload</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">,</span> <span class="p">[(</span><span class="o">!!</span><span class="nx">s</span><span class="p">.</span><span class="nx">duration</span><span class="p">)]);</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-139'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-139">¶</a>
|
|
</div>
|
|
<p>reset a few state properties</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">loaded</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">id3</span> <span class="o">=</span> <span class="p">{};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-140'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-140">¶</a>
|
|
</div>
|
|
<p>TODO: If switching from HTML5 –> flash (or vice versa), stop currently-playing audio.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">html5OK</span><span class="p">(</span><span class="nx">instanceOptions</span><span class="p">))</span> <span class="p">{</span>
|
|
|
|
<span class="nx">oSound</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_setup_html5</span><span class="p">(</span><span class="nx">instanceOptions</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">oSound</span><span class="p">.</span><span class="nx">_called_load</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_html5_canplay</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-141'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-141">¶</a>
|
|
</div>
|
|
<p>TODO: review called<em>load / html5</em>canplay logic</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-142'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-142">¶</a>
|
|
</div>
|
|
<p>if url provided directly to load(), assign it here.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">url</span> <span class="o">!==</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">_wDS</span><span class="p">(</span><span class="s1">'manURL'</span><span class="p">)</span> <span class="o">+</span> <span class="s1">': '</span> <span class="o">+</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">);</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">src</span> <span class="o">=</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-143'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-143">¶</a>
|
|
</div>
|
|
<p>TODO: review / re-apply all relevant options (volume, loop, onposition etc.)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-144'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-144">¶</a>
|
|
</div>
|
|
<p>reset position for new URL</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">setPosition</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-145'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-145">¶</a>
|
|
</div>
|
|
<p>given explicit load call, try to preload.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-146'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-146">¶</a>
|
|
</div>
|
|
<p>early HTML5 implementation (non-standard)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">autobuffer</span> <span class="o">=</span> <span class="s1">'auto'</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-147'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-147">¶</a>
|
|
</div>
|
|
<p>standard</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">preload</span> <span class="o">=</span> <span class="s1">'auto'</span><span class="p">;</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">_called_load</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">autoPlay</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">play</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Ignoring request to load again'</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="k">try</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">=</span> <span class="nx">policyFix</span><span class="p">(</span><span class="nx">loopFix</span><span class="p">(</span><span class="nx">instanceOptions</span><span class="p">));</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-148'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-148">¶</a>
|
|
</div>
|
|
<p>re-assign local shortcut</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">instanceOptions</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">;</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">fV</span> <span class="o">===</span> <span class="mi">8</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_load</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">,</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">stream</span><span class="p">,</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">autoPlay</span><span class="p">,</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">usePolicyFile</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_load</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">,</span> <span class="o">!!</span><span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">stream</span><span class="p">),</span> <span class="o">!!</span><span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">autoPlay</span><span class="p">),</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">loops</span><span class="o">||</span><span class="mi">1</span><span class="p">,</span> <span class="o">!!</span><span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">autoLoad</span><span class="p">),</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">usePolicyFile</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'smError'</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
|
|
<span class="nx">debugTS</span><span class="p">(</span><span class="s1">'onload'</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span>
|
|
<span class="nx">catchError</span><span class="p">({</span><span class="nx">type</span><span class="o">:</span><span class="s1">'SMSOUND_LOAD_JS_EXCEPTION'</span><span class="p">,</span> <span class="nx">fatal</span><span class="o">:</span><span class="kc">true</span><span class="p">});</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-149'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-149">¶</a>
|
|
</div>
|
|
<p>after all of this, ensure sound url is up to date.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">url</span> <span class="o">=</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">;</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-150'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-150">¶</a>
|
|
</div>
|
|
<p>Unloads a sound, canceling any open HTTP requests.</p>
|
|
|
|
<p>@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">unload</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-151'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-151">¶</a>
|
|
</div>
|
|
<p>Flash 8/AS2 can’t “close” a stream – fake it by loading an empty URL
|
|
Flash 9/AS3: Close stream, preventing further load
|
|
HTML5: Most UAs will use empty URL</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">!==</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': unload()'</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">fV</span> <span class="o">===</span> <span class="mi">8</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_unload</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">emptyURL</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_unload</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="nx">stop_html5_timer</span><span class="p">();</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">pause</span><span class="p">();</span>
|
|
<span class="nx">html5Unload</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">,</span> <span class="nx">emptyURL</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-152'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-152">¶</a>
|
|
</div>
|
|
<p>update empty URL, too</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">lastURL</span> <span class="o">=</span> <span class="nx">emptyURL</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-153'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-153">¶</a>
|
|
</div>
|
|
<p>reset load/status flags</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">resetProperties</span><span class="p">();</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-154'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-154">¶</a>
|
|
</div>
|
|
<p>Unloads and destroys a sound.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">destruct</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">_bFromSM</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Destruct'</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-155'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-155">¶</a>
|
|
</div>
|
|
<p>kill sound within Flash
|
|
Disable the onfailure handler</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onfailure</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_destroySound</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="nx">stop_html5_timer</span><span class="p">();</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">pause</span><span class="p">();</span>
|
|
<span class="nx">html5Unload</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">useGlobalHTML5Audio</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">remove_html5_events</span><span class="p">();</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-156'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-156">¶</a>
|
|
</div>
|
|
<p>break obvious circular reference</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">_s</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_a</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">_bFromSM</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-157'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-157">¶</a>
|
|
</div>
|
|
<p>ensure deletion from controller</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">destroySound</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-158'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-158">¶</a>
|
|
</div>
|
|
<p>Begins playing a sound.</p>
|
|
|
|
<p>@param {object} oOptions Optional: Sound options
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">play</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">,</span> <span class="nx">_updatePlayState</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">fN</span><span class="p">,</span> <span class="nx">allowMulti</span><span class="p">,</span> <span class="nx">a</span><span class="p">,</span> <span class="nx">onready</span><span class="p">,</span> <span class="nx">startOK</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span>
|
|
<span class="nx">exit</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-159'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-159">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">fN</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': play(): '</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-160'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-160">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-161'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-161">¶</a>
|
|
</div>
|
|
<p>default to true</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">_updatePlayState</span> <span class="o">=</span> <span class="p">(</span><span class="nx">_updatePlayState</span> <span class="o">===</span> <span class="nx">_undefined</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="nx">_updatePlayState</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">oOptions</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oOptions</span> <span class="o">=</span> <span class="p">{};</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-162'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-162">¶</a>
|
|
</div>
|
|
<p>first, use local URL (if specified)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">url</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">url</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">url</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-163'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-163">¶</a>
|
|
</div>
|
|
<p>mix in any options defined at createSound()</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">=</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">,</span> <span class="nx">s</span><span class="p">.</span><span class="nx">options</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-164'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-164">¶</a>
|
|
</div>
|
|
<p>mix in any options specific to this method</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">=</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">,</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">);</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">url</span> <span class="o">=</span> <span class="nx">parseURL</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">url</span><span class="p">);</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">instanceOptions</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-165'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-165">¶</a>
|
|
</div>
|
|
<p>RTMP-only</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">serverURL</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">connected</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">getAutoPlay</span><span class="p">())</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span><span class="s1">' Netstream not connected yet - setting autoPlay'</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">setAutoPlay</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-166'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-166">¶</a>
|
|
</div>
|
|
<p>play will be called in onconnect()</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">html5OK</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_setup_html5</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">);</span>
|
|
<span class="nx">start_html5_timer</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">===</span> <span class="mi">1</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">paused</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">allowMulti</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">multiShot</span><span class="p">;</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">allowMulti</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="s1">'Already playing (one-shot)'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="nx">exit</span> <span class="o">=</span> <span class="nx">s</span><span class="p">;</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="s1">'Already playing (multi-shot)'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">exit</span> <span class="o">!==</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="nx">exit</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-167'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-167">¶</a>
|
|
</div>
|
|
<p>edge case: play() with explicit URL parameter</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">oOptions</span><span class="p">.</span><span class="nx">url</span> <span class="o">&&</span> <span class="nx">oOptions</span><span class="p">.</span><span class="nx">url</span> <span class="o">!==</span> <span class="nx">s</span><span class="p">.</span><span class="nx">url</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-168'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-168">¶</a>
|
|
</div>
|
|
<p>load using merged options</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">load</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">loaded</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="s1">'Attempting to load'</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-169'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-169">¶</a>
|
|
</div>
|
|
<p>try to get this sound playing ASAP</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-170'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-170">¶</a>
|
|
</div>
|
|
<p>assign directly because setAutoPlay() increments the instanceCount</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">autoPlay</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">load</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-171'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-171">¶</a>
|
|
</div>
|
|
<p>iOS needs this when recycling sounds, loading a new URL on an existing object.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">load</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-172'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-172">¶</a>
|
|
</div>
|
|
<p>HTML5 hack – re-set instanceOptions?</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">instanceOptions</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">===</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="s1">'Could not load - exiting'</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
|
|
<span class="nx">exit</span> <span class="o">=</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="s1">'Loading - attempting to play...'</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">exit</span> <span class="o">!==</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="nx">exit</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span> <span class="o">&&</span> <span class="nx">fV</span> <span class="o">===</span> <span class="mi">9</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">></span> <span class="mi">0</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">===</span> <span class="nx">s</span><span class="p">.</span><span class="nx">duration</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-173'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-173">¶</a>
|
|
</div>
|
|
<p>flash 9 needs a position reset if play() is called while at the end of a sound.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="s1">'Sound at end, resetting to position:0'</span><span class="p">);</span>
|
|
<span class="nx">oOptions</span><span class="p">.</span><span class="nx">position</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-174'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-174">¶</a>
|
|
</div>
|
|
<p>Streams will pause when their buffer is full if they are being loaded.
|
|
In this case paused is true, but the song hasn’t started playing yet.
|
|
If we just call resume() the onplay() callback will never be called.
|
|
So only call resume() if the position is > 0.
|
|
Another reason is because options like volume won’t have been applied yet.
|
|
For normal sounds, just resume.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">paused</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">>=</span> <span class="mi">0</span> <span class="o">&&</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">serverURL</span> <span class="o">||</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">></span> <span class="mi">0</span><span class="p">))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-175'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-175">¶</a>
|
|
</div>
|
|
<p>https://gist.github.com/37b17df75cc4d7a90bf6</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="s1">'Resuming from paused state'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">resume</span><span class="p">();</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">=</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">,</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-176'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-176">¶</a>
|
|
</div>
|
|
<p>apply from/to parameters, if they exist (and not using RTMP)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">from</span> <span class="o">!==</span> <span class="kc">null</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">to</span> <span class="o">!==</span> <span class="kc">null</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">instanceCount</span> <span class="o">===</span> <span class="mi">0</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">===</span> <span class="mi">0</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">serverURL</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">onready</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-177'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-177">¶</a>
|
|
</div>
|
|
<p>sound “canplay” or onload()
|
|
re-apply from/to to instance options, and start playback</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">=</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">,</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">play</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">);</span>
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-178'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-178">¶</a>
|
|
</div>
|
|
<p>HTML5 needs to at least have “canplay” fired before seeking.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">_html5_canplay</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-179'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-179">¶</a>
|
|
</div>
|
|
<p>this hasn’t been loaded yet. load it first, and then do this again.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="s1">'Beginning load for from/to case'</span><span class="p">);</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">load</span><span class="p">({</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-180'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-180">¶</a>
|
|
</div>
|
|
<p>TODO: was _oncanplay. Sounds wrong.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">oncanplay</span><span class="o">:</span> <span class="nx">onready</span>
|
|
<span class="p">});</span>
|
|
|
|
<span class="nx">exit</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">loaded</span> <span class="o">&&</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">||</span> <span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">!==</span> <span class="mi">2</span><span class="p">))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-181'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-181">¶</a>
|
|
</div>
|
|
<p>to be safe, preload the whole thing in Flash.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="s1">'Preloading for from/to case'</span><span class="p">);</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">load</span><span class="p">({</span>
|
|
<span class="nx">onload</span><span class="o">:</span> <span class="nx">onready</span>
|
|
<span class="p">});</span>
|
|
|
|
<span class="nx">exit</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">exit</span> <span class="o">!==</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="nx">exit</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-182'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-182">¶</a>
|
|
</div>
|
|
<p>otherwise, we’re ready to go. re-apply local options, and continue</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">=</span> <span class="nx">applyFromTo</span><span class="p">();</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="s1">'Starting to play'</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">instanceCount</span> <span class="o">||</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">multiShotEvents</span> <span class="o">||</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span> <span class="o">&&</span> <span class="nx">fV</span> <span class="o">></span> <span class="mi">8</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">getAutoPlay</span><span class="p">()))</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">instanceCount</span><span class="o">++</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-183'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-183">¶</a>
|
|
</div>
|
|
<p>if first play and onposition parameters exist, apply them now</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onposition</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">attachOnPosition</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">paused</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">=</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">position</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="o">!</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">position</span><span class="p">)</span> <span class="o">?</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">position</span> <span class="o">:</span> <span class="mi">0</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">=</span> <span class="nx">policyFix</span><span class="p">(</span><span class="nx">loopFix</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">));</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onplay</span> <span class="o">&&</span> <span class="nx">_updatePlayState</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onplay</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="nx">onplay_called</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">setVolume</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">volume</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">setPan</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">pan</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">startOK</span> <span class="o">=</span> <span class="nx">flash</span><span class="p">.</span><span class="nx">_start</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">loops</span> <span class="o">||</span> <span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="nx">fV</span> <span class="o">===</span> <span class="mi">9</span> <span class="o">?</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">position</span> <span class="o">:</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">position</span> <span class="o">/</span> <span class="mi">1000</span><span class="p">),</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">multiShot</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">fV</span> <span class="o">===</span> <span class="mi">9</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">startOK</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-184'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-184">¶</a>
|
|
</div>
|
|
<p>edge case: no sound hardware, or 32-channel flash ceiling hit.
|
|
applies only to Flash 9, non-NetStream/MovieStar sounds.
|
|
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#play%28%29</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="s1">'No sound hardware, or 32-sound ceiling hit'</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onplayerror</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onplayerror</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="nx">start_html5_timer</span><span class="p">();</span>
|
|
|
|
<span class="nx">a</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_setup_html5</span><span class="p">();</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">setPosition</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">position</span><span class="p">);</span>
|
|
|
|
<span class="nx">a</span><span class="p">.</span><span class="nx">play</span><span class="p">();</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-185'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-185">¶</a>
|
|
</div>
|
|
<p>just for convenience</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">start</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">play</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-186'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-186">¶</a>
|
|
</div>
|
|
<p>Stops playing a sound (and optionally, all sounds)</p>
|
|
|
|
<p>@param {boolean} bAll Optional: Whether to stop all sounds
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">stop</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">bAll</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">instanceOptions</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">,</span>
|
|
<span class="nx">originalPosition</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">===</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': stop()'</span><span class="p">);</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_onbufferchange</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_resetOnPosition</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">paused</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-187'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-187">¶</a>
|
|
</div>
|
|
<p>remove onPosition listeners, if any</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">detachOnPosition</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-188'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-188">¶</a>
|
|
</div>
|
|
<p>and “to” position, if set</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">to</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">clearOnPosition</span><span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">to</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_stop</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">bAll</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-189'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-189">¶</a>
|
|
</div>
|
|
<p>hack for netStream: just unload</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">serverURL</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">unload</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">originalPosition</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-190'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-190">¶</a>
|
|
</div>
|
|
<p>act like Flash, though</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">setPosition</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-191'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-191">¶</a>
|
|
</div>
|
|
<p>hack: reflect old position for onstop() (also like Flash)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">=</span> <span class="nx">originalPosition</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-192'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-192">¶</a>
|
|
</div>
|
|
<p>html5 has no stop()
|
|
NOTE: pausing means iOS requires interaction to resume.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">pause</span><span class="p">();</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-193'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-193">¶</a>
|
|
</div>
|
|
<p>and update UI</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_onTimer</span><span class="p">();</span>
|
|
|
|
<span class="nx">stop_html5_timer</span><span class="p">();</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">instanceCount</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">=</span> <span class="p">{};</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">onstop</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">onstop</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-194'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-194">¶</a>
|
|
</div>
|
|
<p>Undocumented/internal: Sets autoPlay for RTMP.</p>
|
|
|
|
<p>@param {boolean} autoPlay state</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">setAutoPlay</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">autoPlay</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Autoplay turned '</span> <span class="o">+</span> <span class="p">(</span><span class="nx">autoPlay</span> <span class="o">?</span> <span class="s1">'on'</span> <span class="o">:</span> <span class="s1">'off'</span><span class="p">));</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">autoPlay</span> <span class="o">=</span> <span class="nx">autoPlay</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_setAutoPlay</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">autoPlay</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">autoPlay</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-195'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-195">¶</a>
|
|
</div>
|
|
<p>only increment the instanceCount if the sound isn’t loaded (TODO: verify RTMP)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">instanceCount</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">===</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">instanceCount</span><span class="o">++</span><span class="p">;</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Incremented instance count to '</span><span class="o">+</span><span class="nx">s</span><span class="p">.</span><span class="nx">instanceCount</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-196'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-196">¶</a>
|
|
</div>
|
|
<p>Undocumented/internal: Returns the autoPlay boolean.</p>
|
|
|
|
<p>@return {boolean} The current autoPlay value</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">getAutoPlay</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">autoPlay</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-197'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-197">¶</a>
|
|
</div>
|
|
<p>Sets the position of a sound.</p>
|
|
|
|
<p>@param {number} nMsecOffset Position (milliseconds)
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">setPosition</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nMsecOffset</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">nMsecOffset</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">nMsecOffset</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">original_pos</span><span class="p">,</span>
|
|
<span class="nx">position</span><span class="p">,</span> <span class="nx">position1K</span><span class="p">,</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-198'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-198">¶</a>
|
|
</div>
|
|
<p>Use the duration from the instance options, if we don’t have a track duration yet.
|
|
position >= 0 and <= current available (loaded) duration</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">offset</span> <span class="o">=</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span> <span class="o">?</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">max</span><span class="p">(</span><span class="nx">nMsecOffset</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">:</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">min</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">duration</span> <span class="o">||</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">duration</span><span class="p">,</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">max</span><span class="p">(</span><span class="nx">nMsecOffset</span><span class="p">,</span> <span class="mi">0</span><span class="p">)));</span>
|
|
|
|
<span class="nx">original_pos</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">=</span> <span class="nx">offset</span><span class="p">;</span>
|
|
<span class="nx">position1K</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span><span class="o">/</span><span class="mi">1000</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_resetOnPosition</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">position</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">position</span> <span class="o">=</span> <span class="nx">offset</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">position</span> <span class="o">=</span> <span class="p">(</span><span class="nx">fV</span> <span class="o">===</span> <span class="mi">9</span> <span class="o">?</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">:</span> <span class="nx">position1K</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">!==</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-199'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-199">¶</a>
|
|
</div>
|
|
<p>if paused or not playing, will not resume (by playing)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">flash</span><span class="p">.</span><span class="nx">_setPosition</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">position</span><span class="p">,</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">paused</span> <span class="o">||</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">playState</span><span class="p">),</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">multiShot</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-200'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-200">¶</a>
|
|
</div>
|
|
<p>Set the position in the canplay handler if the sound is not ready yet</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_html5_canplay</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">currentTime</span> <span class="o">!==</span> <span class="nx">position1K</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-201'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-201">¶</a>
|
|
</div>
|
|
<p>DOM/JS errors/exceptions to watch out for:
|
|
if seek is beyond (loaded?) position, “DOM exception 11”
|
|
“INDEX<em>SIZE</em>ERR”: DOM exception 1</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': setPosition('</span><span class="o">+</span><span class="nx">position1K</span><span class="o">+</span><span class="s1">')'</span><span class="p">);</span>
|
|
<span class="k">try</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">currentTime</span> <span class="o">=</span> <span class="nx">position1K</span><span class="p">;</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">===</span> <span class="mi">0</span> <span class="o">||</span> <span class="nx">s</span><span class="p">.</span><span class="nx">paused</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-202'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-202">¶</a>
|
|
</div>
|
|
<p>allow seek without auto-play/resume</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">pause</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': setPosition('</span> <span class="o">+</span> <span class="nx">position1K</span> <span class="o">+</span> <span class="s1">') failed: '</span> <span class="o">+</span> <span class="nx">e</span><span class="p">.</span><span class="nx">message</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': setPosition('</span> <span class="o">+</span> <span class="nx">position1K</span> <span class="o">+</span> <span class="s1">'): Cannot seek yet, sound not ready'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">paused</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-203'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-203">¶</a>
|
|
</div>
|
|
<p>if paused, refresh UI right away
|
|
force update</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_onTimer</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-204'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-204">¶</a>
|
|
</div>
|
|
<p>Pauses sound playback.</p>
|
|
|
|
<p>@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">pause</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">_bCallFlash</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">paused</span> <span class="o">||</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">===</span> <span class="mi">0</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">!==</span> <span class="mi">1</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': pause()'</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">paused</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">_bCallFlash</span> <span class="o">||</span> <span class="nx">_bCallFlash</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_pause</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">multiShot</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_setup_html5</span><span class="p">().</span><span class="nx">pause</span><span class="p">();</span>
|
|
<span class="nx">stop_html5_timer</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onpause</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onpause</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-205'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-205">¶</a>
|
|
</div>
|
|
<p>Resumes sound playback.</p>
|
|
|
|
<p>@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-206'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-206">¶</a>
|
|
</div>
|
|
<p>When auto-loaded streams pause on buffer full they have a playState of 0.
|
|
We need to make sure that the playState is set to 1 when these streams “resume”.
|
|
When a paused stream is resumed, we need to trigger the onplay() callback if it
|
|
hasn’t been called already. In this case since the sound is being played for the
|
|
first time, I think it’s more appropriate to call onplay() rather than onresume().</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">resume</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">instanceOptions</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">paused</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': resume()'</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">paused</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">isMovieStar</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">serverURL</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-207'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-207">¶</a>
|
|
</div>
|
|
<p>Bizarre Webkit bug (Chrome reported via 8tracks.com dudes): AAC content paused for 30+ seconds(?) will not resume without a reposition.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">setPosition</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">position</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-208'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-208">¶</a>
|
|
</div>
|
|
<p>flash method is toggle-based (pause/resume)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">flash</span><span class="p">.</span><span class="nx">_pause</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">multiShot</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_setup_html5</span><span class="p">().</span><span class="nx">play</span><span class="p">();</span>
|
|
<span class="nx">start_html5_timer</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">onplay_called</span> <span class="o">&&</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">onplay</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">onplay</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="nx">onplay_called</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">onresume</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">onresume</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-209'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-209">¶</a>
|
|
</div>
|
|
<p>Toggles sound playback.</p>
|
|
|
|
<p>@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">togglePause</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': togglePause()'</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">play</span><span class="p">({</span>
|
|
<span class="nx">position</span><span class="o">:</span> <span class="p">(</span><span class="nx">fV</span> <span class="o">===</span> <span class="mi">9</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span> <span class="o">?</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">:</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">/</span> <span class="mi">1000</span><span class="p">)</span>
|
|
<span class="p">});</span>
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">paused</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">resume</span><span class="p">();</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">pause</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-210'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-210">¶</a>
|
|
</div>
|
|
<p>Sets the panning (L-R) effect.</p>
|
|
|
|
<p>@param {number} nPan The pan value (-100 to 100)
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">setPan</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nPan</span><span class="p">,</span> <span class="nx">bInstanceOnly</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">nPan</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">nPan</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">bInstanceOnly</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">bInstanceOnly</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_setPan</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">nPan</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="c1">// else { no HTML5 pan? }</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">pan</span> <span class="o">=</span> <span class="nx">nPan</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">bInstanceOnly</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">pan</span> <span class="o">=</span> <span class="nx">nPan</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">pan</span> <span class="o">=</span> <span class="nx">nPan</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-211'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-211">¶</a>
|
|
</div>
|
|
<p>Sets the volume.</p>
|
|
|
|
<p>@param {number} nVol The volume value (0 to 100)
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">setVolume</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nVol</span><span class="p">,</span> <span class="nx">_bInstanceOnly</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-212'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-212">¶</a>
|
|
</div>
|
|
<p>Note: Setting volume has no effect on iOS “special snowflake” devices.
|
|
Hardware volume control overrides software, and volume
|
|
will always return 1 per Apple docs. (iOS 4 + 5.)
|
|
http://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/AddingSoundtoCanvasAnimations/AddingSoundtoCanvasAnimations.html</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">nVol</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">nVol</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">_bInstanceOnly</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">_bInstanceOnly</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_setVolume</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">muted</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">muted</span><span class="p">)</span> <span class="o">||</span> <span class="nx">s</span><span class="p">.</span><span class="nx">muted</span><span class="o">?</span><span class="mi">0</span><span class="o">:</span><span class="nx">nVol</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-213'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-213">¶</a>
|
|
</div>
|
|
<p>valid range: 0-1</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">volume</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">max</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">min</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nx">nVol</span><span class="o">/</span><span class="mi">100</span><span class="p">));</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">volume</span> <span class="o">=</span> <span class="nx">nVol</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">_bInstanceOnly</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">volume</span> <span class="o">=</span> <span class="nx">nVol</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">volume</span> <span class="o">=</span> <span class="nx">nVol</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-214'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-214">¶</a>
|
|
</div>
|
|
<p>Mutes the sound.</p>
|
|
|
|
<p>@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">mute</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">muted</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_setVolume</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">muted</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-215'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-215">¶</a>
|
|
</div>
|
|
<p>Unmutes the sound.</p>
|
|
|
|
<p>@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">unmute</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">muted</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="kd">var</span> <span class="nx">hasIO</span> <span class="o">=</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">volume</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_setVolume</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">hasIO</span><span class="o">?</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">volume</span><span class="o">:</span><span class="nx">s</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">volume</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">muted</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-216'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-216">¶</a>
|
|
</div>
|
|
<p>Toggles the muted state of a sound.</p>
|
|
|
|
<p>@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">toggleMute</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">return</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">muted</span><span class="o">?</span><span class="nx">s</span><span class="p">.</span><span class="nx">unmute</span><span class="p">()</span><span class="o">:</span><span class="nx">s</span><span class="p">.</span><span class="nx">mute</span><span class="p">());</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-217'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-217">¶</a>
|
|
</div>
|
|
<p>Registers a callback to be fired when a sound reaches a given position during playback.</p>
|
|
|
|
<p>@param {number} nPosition The position to watch for
|
|
@param {function} oMethod The relevant callback to fire
|
|
@param {object} oScope Optional: The scope to apply the callback to
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">onPosition</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nPosition</span><span class="p">,</span> <span class="nx">oMethod</span><span class="p">,</span> <span class="nx">oScope</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-218'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-218">¶</a>
|
|
</div>
|
|
<p>TODO: basic dupe checking?</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">onPositionItems</span><span class="p">.</span><span class="nx">push</span><span class="p">({</span>
|
|
<span class="nx">position</span><span class="o">:</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">nPosition</span><span class="p">,</span> <span class="mi">10</span><span class="p">),</span>
|
|
<span class="nx">method</span><span class="o">:</span> <span class="nx">oMethod</span><span class="p">,</span>
|
|
<span class="nx">scope</span><span class="o">:</span> <span class="p">(</span><span class="nx">oScope</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">?</span> <span class="nx">oScope</span> <span class="o">:</span> <span class="nx">s</span><span class="p">),</span>
|
|
<span class="nx">fired</span><span class="o">:</span> <span class="kc">false</span>
|
|
<span class="p">});</span>
|
|
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-219'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-219">¶</a>
|
|
</div>
|
|
<p>legacy/backwards-compability: lower-case method name</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">onposition</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">onPosition</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-220'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-220">¶</a>
|
|
</div>
|
|
<p>Removes registered callback(s) from a sound, by position and/or callback.</p>
|
|
|
|
<p>@param {number} nPosition The position to clear callback(s) for
|
|
@param {function} oMethod Optional: Identify one callback to be removed when multiple listeners exist for one position
|
|
@return {SMSound} The SMSound object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">clearOnPosition</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nPosition</span><span class="p">,</span> <span class="nx">oMethod</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">i</span><span class="p">;</span>
|
|
|
|
<span class="nx">nPosition</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">nPosition</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">nPosition</span><span class="p">))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-221'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-221">¶</a>
|
|
</div>
|
|
<p>safety check</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">onPositionItems</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">nPosition</span> <span class="o">===</span> <span class="nx">onPositionItems</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">position</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-222'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-222">¶</a>
|
|
</div>
|
|
<p>remove this item if no method was specified, or, if the method matches</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">oMethod</span> <span class="o">||</span> <span class="p">(</span><span class="nx">oMethod</span> <span class="o">===</span> <span class="nx">onPositionItems</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">method</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">onPositionItems</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">fired</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-223'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-223">¶</a>
|
|
</div>
|
|
<p>decrement “fired” counter, too</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">onPositionFired</span><span class="o">--</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">onPositionItems</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_processOnPosition</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">item</span><span class="p">,</span> <span class="nx">j</span> <span class="o">=</span> <span class="nx">onPositionItems</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">j</span> <span class="o">||</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">||</span> <span class="nx">onPositionFired</span> <span class="o">>=</span> <span class="nx">j</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">j</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">>=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">item</span> <span class="o">=</span> <span class="nx">onPositionItems</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">item</span><span class="p">.</span><span class="nx">fired</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">>=</span> <span class="nx">item</span><span class="p">.</span><span class="nx">position</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">item</span><span class="p">.</span><span class="nx">fired</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">onPositionFired</span><span class="o">++</span><span class="p">;</span>
|
|
<span class="nx">item</span><span class="p">.</span><span class="nx">method</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">item</span><span class="p">.</span><span class="nx">scope</span><span class="p">,</span> <span class="p">[</span><span class="nx">item</span><span class="p">.</span><span class="nx">position</span><span class="p">]);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_resetOnPosition</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nPosition</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-224'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-224">¶</a>
|
|
</div>
|
|
<p>reset “fired” for items interested in this position</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">item</span><span class="p">,</span> <span class="nx">j</span> <span class="o">=</span> <span class="nx">onPositionItems</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">j</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">j</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">>=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">item</span> <span class="o">=</span> <span class="nx">onPositionItems</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">item</span><span class="p">.</span><span class="nx">fired</span> <span class="o">&&</span> <span class="nx">nPosition</span> <span class="o"><=</span> <span class="nx">item</span><span class="p">.</span><span class="nx">position</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">item</span><span class="p">.</span><span class="nx">fired</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">onPositionFired</span><span class="o">--</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-SMSound()_private_internals'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-SMSound()_private_internals">¶</a>
|
|
</div>
|
|
<h2>SMSound() private internals</h2>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">applyFromTo</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">instanceOptions</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">,</span>
|
|
<span class="nx">f</span> <span class="o">=</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">from</span><span class="p">,</span>
|
|
<span class="nx">t</span> <span class="o">=</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">to</span><span class="p">,</span>
|
|
<span class="nx">start</span><span class="p">,</span> <span class="nx">end</span><span class="p">;</span>
|
|
|
|
<span class="nx">end</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-226'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-226">¶</a>
|
|
</div>
|
|
<p>end has been reached.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': "To" time of '</span> <span class="o">+</span> <span class="nx">t</span> <span class="o">+</span> <span class="s1">' reached.'</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-227'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-227">¶</a>
|
|
</div>
|
|
<p>detach listener</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">clearOnPosition</span><span class="p">(</span><span class="nx">t</span><span class="p">,</span> <span class="nx">end</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-228'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-228">¶</a>
|
|
</div>
|
|
<p>stop should clear this, too</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">stop</span><span class="p">();</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">start</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Playing "from" '</span> <span class="o">+</span> <span class="nx">f</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-229'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-229">¶</a>
|
|
</div>
|
|
<p>add listener for end</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">t</span> <span class="o">!==</span> <span class="kc">null</span> <span class="o">&&</span> <span class="o">!</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">t</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">onPosition</span><span class="p">(</span><span class="nx">t</span><span class="p">,</span> <span class="nx">end</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">f</span> <span class="o">!==</span> <span class="kc">null</span> <span class="o">&&</span> <span class="o">!</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">f</span><span class="p">))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-230'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-230">¶</a>
|
|
</div>
|
|
<p>apply to instance options, guaranteeing correct start position.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">position</span> <span class="o">=</span> <span class="nx">f</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-231'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-231">¶</a>
|
|
</div>
|
|
<p>multiShot timing can’t be tracked, so prevent that.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">multiShot</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="nx">start</span><span class="p">();</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-232'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-232">¶</a>
|
|
</div>
|
|
<p>return updated instanceOptions including starting position</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="nx">instanceOptions</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">attachOnPosition</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">item</span><span class="p">,</span>
|
|
<span class="nx">op</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onposition</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-233'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-233">¶</a>
|
|
</div>
|
|
<p>attach onposition things, if any, now.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">op</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">item</span> <span class="k">in</span> <span class="nx">op</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">op</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">item</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">onPosition</span><span class="p">(</span><span class="nb">parseInt</span><span class="p">(</span><span class="nx">item</span><span class="p">,</span> <span class="mi">10</span><span class="p">),</span> <span class="nx">op</span><span class="p">[</span><span class="nx">item</span><span class="p">]);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">detachOnPosition</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">item</span><span class="p">,</span>
|
|
<span class="nx">op</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onposition</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-234'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-234">¶</a>
|
|
</div>
|
|
<p>detach any onposition()-style listeners.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">op</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">item</span> <span class="k">in</span> <span class="nx">op</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">op</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">item</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">clearOnPosition</span><span class="p">(</span><span class="nb">parseInt</span><span class="p">(</span><span class="nx">item</span><span class="p">,</span> <span class="mi">10</span><span class="p">));</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">start_html5_timer</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">startTimer</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">stop_html5_timer</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">stopTimer</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">resetProperties</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">retainPosition</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">retainPosition</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">onPositionItems</span> <span class="o">=</span> <span class="p">[];</span>
|
|
<span class="nx">onPositionFired</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">onplay_called</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_hasTimer</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_a</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_html5_canplay</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">bytesLoaded</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">bytesTotal</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">duration</span> <span class="o">=</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">duration</span> <span class="o">?</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">duration</span> <span class="o">:</span> <span class="kc">null</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">durationEstimate</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">buffered</span> <span class="o">=</span> <span class="p">[];</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-235'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-235">¶</a>
|
|
</div>
|
|
<p>legacy: 1D array</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">eqData</span> <span class="o">=</span> <span class="p">[];</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">eqData</span><span class="p">.</span><span class="nx">left</span> <span class="o">=</span> <span class="p">[];</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">eqData</span><span class="p">.</span><span class="nx">right</span> <span class="o">=</span> <span class="p">[];</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">failures</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">isBuffering</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">instanceOptions</span> <span class="o">=</span> <span class="p">{};</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">instanceCount</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">loaded</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">metadata</span> <span class="o">=</span> <span class="p">{};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-236'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-236">¶</a>
|
|
</div>
|
|
<p>0 = uninitialised, 1 = loading, 2 = failed/error, 3 = loaded/success</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">muted</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">paused</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">peakData</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="nx">left</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span>
|
|
<span class="nx">right</span><span class="o">:</span> <span class="mi">0</span>
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">waveformData</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="nx">left</span><span class="o">:</span> <span class="p">[],</span>
|
|
<span class="nx">right</span><span class="o">:</span> <span class="p">[]</span>
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">id3</span> <span class="o">=</span> <span class="p">{};</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">resetProperties</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-Pseudo-private_SMSound_internals'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-Pseudo-private_SMSound_internals">¶</a>
|
|
</div>
|
|
<h2>Pseudo-private SMSound internals</h2>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_onTimer</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">bForce</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-238'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-238">¶</a>
|
|
</div>
|
|
<p>HTML5-only _whileplaying() etc.
|
|
called from both HTML5 native events, and polling/interval-based timers
|
|
mimics flash and fires only when time/duration change, so as to be polling-friendly</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">duration</span><span class="p">,</span> <span class="nx">isNew</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">time</span><span class="p">,</span> <span class="nx">x</span> <span class="o">=</span> <span class="p">{};</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_hasTimer</span> <span class="o">||</span> <span class="nx">bForce</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-239'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-239">¶</a>
|
|
</div>
|
|
<p>TODO: May not need to track readyState (1 = loading)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span> <span class="o">&&</span> <span class="p">(</span><span class="nx">bForce</span> <span class="o">||</span> <span class="p">((</span><span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">></span> <span class="mi">0</span> <span class="o">||</span> <span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">===</span> <span class="mi">1</span><span class="p">)</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">paused</span><span class="p">)))</span> <span class="p">{</span>
|
|
|
|
<span class="nx">duration</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_get_html5_duration</span><span class="p">();</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">duration</span> <span class="o">!==</span> <span class="nx">lastHTML5State</span><span class="p">.</span><span class="nx">duration</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">lastHTML5State</span><span class="p">.</span><span class="nx">duration</span> <span class="o">=</span> <span class="nx">duration</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">duration</span> <span class="o">=</span> <span class="nx">duration</span><span class="p">;</span>
|
|
<span class="nx">isNew</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-240'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-240">¶</a>
|
|
</div>
|
|
<p>TODO: investigate why this goes wack if not set/re-set each time.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">durationEstimate</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">duration</span><span class="p">;</span>
|
|
|
|
<span class="nx">time</span> <span class="o">=</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">currentTime</span> <span class="o">*</span> <span class="mi">1000</span> <span class="o">||</span> <span class="mi">0</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">time</span> <span class="o">!==</span> <span class="nx">lastHTML5State</span><span class="p">.</span><span class="nx">time</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">lastHTML5State</span><span class="p">.</span><span class="nx">time</span> <span class="o">=</span> <span class="nx">time</span><span class="p">;</span>
|
|
<span class="nx">isNew</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">isNew</span> <span class="o">||</span> <span class="nx">bForce</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_whileplaying</span><span class="p">(</span><span class="nx">time</span><span class="p">,</span><span class="nx">x</span><span class="p">,</span><span class="nx">x</span><span class="p">,</span><span class="nx">x</span><span class="p">,</span><span class="nx">x</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span><span class="cm">/* else {</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-241'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-241">¶</a>
|
|
</div>
|
|
<p>sm2.<em>wD(‘</em>onTimer: Warn for “’+s.id+‘”: ’+(!s._a?‘Could not find element. ’:“)+(s.playState === 0?‘playState bad, 0?’:‘playState = ’+s.playState+‘, OK’));</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre><span class="cm"> return false;</span>
|
|
|
|
<span class="cm"> }*/</span>
|
|
|
|
<span class="k">return</span> <span class="nx">isNew</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_get_html5_duration</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">instanceOptions</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">,</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-242'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-242">¶</a>
|
|
</div>
|
|
<p>if audio object exists, use its duration – else, instance option duration (if provided – it’s a hack, really, and should be retired) OR null</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">d</span> <span class="o">=</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">duration</span> <span class="o">?</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">duration</span><span class="o">*</span><span class="mi">1000</span> <span class="o">:</span> <span class="p">(</span><span class="nx">instanceOptions</span> <span class="o">&&</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">duration</span> <span class="o">?</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">duration</span> <span class="o">:</span> <span class="kc">null</span><span class="p">)),</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="p">(</span><span class="nx">d</span> <span class="o">&&</span> <span class="o">!</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">d</span><span class="p">)</span> <span class="o">&&</span> <span class="nx">d</span> <span class="o">!==</span> <span class="kc">Infinity</span> <span class="o">?</span> <span class="nx">d</span> <span class="o">:</span> <span class="kc">null</span><span class="p">);</span>
|
|
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_apply_loop</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">nLoops</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-243'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-243">¶</a>
|
|
</div>
|
|
<p>boolean instead of "loop”, for webkit? – spec says string. http://www.w3.org/TR/html-markup/audio.html#audio.attrs.loop
|
|
note that loop is either off or infinite under HTML5, unlike Flash which allows arbitrary loop counts to be specified.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-244'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-244">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">a</span><span class="p">.</span><span class="nx">loop</span> <span class="o">&&</span> <span class="nx">nLoops</span> <span class="o">></span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="s1">'Note: Native HTML5 looping is infinite.'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-245'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-245">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">a</span><span class="p">.</span><span class="nx">loop</span> <span class="o">=</span> <span class="p">(</span><span class="nx">nLoops</span> <span class="o">></span> <span class="mi">1</span> <span class="o">?</span> <span class="s1">'loop'</span> <span class="o">:</span> <span class="s1">''</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_setup_html5</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">instanceOptions</span> <span class="o">=</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">,</span> <span class="nx">oOptions</span><span class="p">),</span> <span class="nx">d</span> <span class="o">=</span> <span class="nb">decodeURI</span><span class="p">,</span>
|
|
<span class="nx">a</span> <span class="o">=</span> <span class="nx">useGlobalHTML5Audio</span> <span class="o">?</span> <span class="nx">globalHTML5Audio</span> <span class="o">:</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">,</span>
|
|
<span class="nx">dURL</span> <span class="o">=</span> <span class="nx">d</span><span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">),</span>
|
|
<span class="nx">sameURL</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-246'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-246">¶</a>
|
|
</div>
|
|
<p>“First things first, I, Poppa…” (reset the previous state of the old sound, if playing)
|
|
Fixes case with devices that can only play one sound at a time
|
|
Otherwise, other sounds in mid-play will be terminated without warning and in a stuck state</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">useGlobalHTML5Audio</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">dURL</span> <span class="o">===</span> <span class="nx">lastGlobalHTML5URL</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-247'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-247">¶</a>
|
|
</div>
|
|
<p>global HTML5 audio: re-use of URL</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sameURL</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">dURL</span> <span class="o">===</span> <span class="nx">lastURL</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-248'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-248">¶</a>
|
|
</div>
|
|
<p>options URL is the same as the “last” URL, and we used (loaded) it</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sameURL</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">a</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">a</span><span class="p">.</span><span class="nx">_s</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">useGlobalHTML5Audio</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">a</span><span class="p">.</span><span class="nx">_s</span> <span class="o">&&</span> <span class="nx">a</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">sameURL</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-249'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-249">¶</a>
|
|
</div>
|
|
<p>global HTML5 audio case, and loading a new URL. stop the currently-playing one.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">a</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">stop</span><span class="p">();</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">useGlobalHTML5Audio</span> <span class="o">&&</span> <span class="nx">dURL</span> <span class="o">===</span> <span class="nx">d</span><span class="p">(</span><span class="nx">lastURL</span><span class="p">))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-250'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-250">¶</a>
|
|
</div>
|
|
<p>non-global HTML5 reuse case: same url, ignore request</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_apply_loop</span><span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">loops</span><span class="p">);</span>
|
|
|
|
<span class="k">return</span> <span class="nx">a</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sameURL</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-251'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-251">¶</a>
|
|
</div>
|
|
<p>don’t retain onPosition() stuff with new URL.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">resetProperties</span><span class="p">(</span><span class="kc">false</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-252'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-252">¶</a>
|
|
</div>
|
|
<p>assign new HTML5 URL</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">a</span><span class="p">.</span><span class="nx">src</span> <span class="o">=</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">;</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">url</span> <span class="o">=</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">;</span>
|
|
|
|
<span class="nx">lastURL</span> <span class="o">=</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">;</span>
|
|
|
|
<span class="nx">lastGlobalHTML5URL</span> <span class="o">=</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">;</span>
|
|
|
|
<span class="nx">a</span><span class="p">.</span><span class="nx">_called_load</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">autoLoad</span> <span class="o">||</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">autoPlay</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_a</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Audio</span><span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">url</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-253'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-253">¶</a>
|
|
</div>
|
|
<p>null for stupid Opera 9.64 case</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span> <span class="o">=</span> <span class="p">(</span><span class="nx">isOpera</span> <span class="o">&&</span> <span class="nx">opera</span><span class="p">.</span><span class="nx">version</span><span class="p">()</span> <span class="o"><</span> <span class="mi">10</span> <span class="o">?</span> <span class="k">new</span> <span class="nx">Audio</span><span class="p">(</span><span class="kc">null</span><span class="p">)</span> <span class="o">:</span> <span class="k">new</span> <span class="nx">Audio</span><span class="p">());</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-254'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-254">¶</a>
|
|
</div>
|
|
<p>assign local reference</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">a</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">;</span>
|
|
|
|
<span class="nx">a</span><span class="p">.</span><span class="nx">_called_load</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">useGlobalHTML5Audio</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">globalHTML5Audio</span> <span class="o">=</span> <span class="nx">a</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-255'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-255">¶</a>
|
|
</div>
|
|
<p>store a ref on the track</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span> <span class="o">=</span> <span class="nx">a</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-256'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-256">¶</a>
|
|
</div>
|
|
<p>store a ref on the audio</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">a</span><span class="p">.</span><span class="nx">_s</span> <span class="o">=</span> <span class="nx">s</span><span class="p">;</span>
|
|
|
|
<span class="nx">add_html5_events</span><span class="p">();</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_apply_loop</span><span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">loops</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">autoLoad</span> <span class="o">||</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">autoPlay</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">load</span><span class="p">();</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-257'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-257">¶</a>
|
|
</div>
|
|
<p>early HTML5 implementation (non-standard)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">a</span><span class="p">.</span><span class="nx">autobuffer</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-258'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-258">¶</a>
|
|
</div>
|
|
<p>standard (‘none’ is also an option.)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">a</span><span class="p">.</span><span class="nx">preload</span> <span class="o">=</span> <span class="s1">'auto'</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">a</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">add_html5_events</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">_added_events</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">f</span><span class="p">;</span>
|
|
|
|
<span class="kd">function</span> <span class="nx">add</span><span class="p">(</span><span class="nx">oEvt</span><span class="p">,</span> <span class="nx">oFn</span><span class="p">,</span> <span class="nx">bCapture</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span> <span class="o">?</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">addEventListener</span><span class="p">(</span><span class="nx">oEvt</span><span class="p">,</span> <span class="nx">oFn</span><span class="p">,</span> <span class="nx">bCapture</span><span class="o">||</span><span class="kc">false</span><span class="p">)</span> <span class="o">:</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">_added_events</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">f</span> <span class="k">in</span> <span class="nx">html5_events</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">html5_events</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">f</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">add</span><span class="p">(</span><span class="nx">f</span><span class="p">,</span> <span class="nx">html5_events</span><span class="p">[</span><span class="nx">f</span><span class="p">]);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">remove_html5_events</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-259'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-259">¶</a>
|
|
</div>
|
|
<p>Remove event listeners</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">f</span><span class="p">;</span>
|
|
|
|
<span class="kd">function</span> <span class="nx">remove</span><span class="p">(</span><span class="nx">oEvt</span><span class="p">,</span> <span class="nx">oFn</span><span class="p">,</span> <span class="nx">bCapture</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span> <span class="o">?</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">removeEventListener</span><span class="p">(</span><span class="nx">oEvt</span><span class="p">,</span> <span class="nx">oFn</span><span class="p">,</span> <span class="nx">bCapture</span><span class="o">||</span><span class="kc">false</span><span class="p">)</span> <span class="o">:</span> <span class="kc">null</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Removing event listeners'</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">.</span><span class="nx">_added_events</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">f</span> <span class="k">in</span> <span class="nx">html5_events</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">html5_events</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">f</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">remove</span><span class="p">(</span><span class="nx">f</span><span class="p">,</span> <span class="nx">html5_events</span><span class="p">[</span><span class="nx">f</span><span class="p">]);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-Pseudo-private_event_internals'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-Pseudo-private_event_internals">¶</a>
|
|
</div>
|
|
<h2>Pseudo-private event internals</h2>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_onload</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nSuccess</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">fN</span><span class="p">,</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-261'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-261">¶</a>
|
|
</div>
|
|
<p>check for duration to prevent false positives from flash 8 when loading from cache.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">loadOK</span> <span class="o">=</span> <span class="o">!!</span><span class="nx">nSuccess</span> <span class="o">||</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span> <span class="o">&&</span> <span class="nx">fV</span> <span class="o">===</span> <span class="mi">8</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">duration</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-262'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-262">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">fN</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': '</span><span class="p">;</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="p">(</span><span class="nx">loadOK</span> <span class="o">?</span> <span class="s1">'onload()'</span> <span class="o">:</span> <span class="s1">'Failed to load? - '</span> <span class="o">+</span> <span class="nx">s</span><span class="p">.</span><span class="nx">url</span><span class="p">),</span> <span class="p">(</span><span class="nx">loadOK</span> <span class="o">?</span> <span class="mi">1</span> <span class="o">:</span> <span class="mi">2</span><span class="p">));</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">loadOK</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">sandbox</span><span class="p">.</span><span class="nx">noRemote</span> <span class="o">===</span> <span class="kc">true</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="s1">'noNet'</span><span class="p">),</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">sandbox</span><span class="p">.</span><span class="nx">noLocal</span> <span class="o">===</span> <span class="kc">true</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">fN</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="s1">'noLocal'</span><span class="p">),</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-263'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-263">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">loaded</span> <span class="o">=</span> <span class="nx">loadOK</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">=</span> <span class="nx">loadOK</span><span class="o">?</span><span class="mi">3</span><span class="o">:</span><span class="mi">2</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_onbufferchange</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onload</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onload</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">,</span> <span class="p">[</span><span class="nx">loadOK</span><span class="p">]);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_onbufferchange</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nIsBuffering</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-264'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-264">¶</a>
|
|
</div>
|
|
<p>ignore if not playing</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">((</span><span class="nx">nIsBuffering</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">isBuffering</span><span class="p">)</span> <span class="o">||</span> <span class="p">(</span><span class="o">!</span><span class="nx">nIsBuffering</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isBuffering</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">isBuffering</span> <span class="o">=</span> <span class="p">(</span><span class="nx">nIsBuffering</span> <span class="o">===</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onbufferchange</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Buffer state change: '</span> <span class="o">+</span> <span class="nx">nIsBuffering</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onbufferchange</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-265'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-265">¶</a>
|
|
</div>
|
|
<p>Playback may have stopped due to buffering, or related reason.
|
|
This state can be encountered on iOS < 6 when auto-play is blocked.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_onsuspend</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onsuspend</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Playback suspended'</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onsuspend</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-266'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-266">¶</a>
|
|
</div>
|
|
<p>flash 9/movieStar + RTMP-only method, should fire only once at most
|
|
at this point we just recreate failed sounds rather than trying to reconnect</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_onfailure</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">msg</span><span class="p">,</span> <span class="nx">level</span><span class="p">,</span> <span class="nx">code</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">failures</span><span class="o">++</span><span class="p">;</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Failures = '</span> <span class="o">+</span> <span class="nx">s</span><span class="p">.</span><span class="nx">failures</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onfailure</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">failures</span> <span class="o">===</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onfailure</span><span class="p">(</span><span class="nx">s</span><span class="p">,</span> <span class="nx">msg</span><span class="p">,</span> <span class="nx">level</span><span class="p">,</span> <span class="nx">code</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Ignoring failure'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_onfinish</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-267'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-267">¶</a>
|
|
</div>
|
|
<p>store local copy before it gets trashed…</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">io_onfinish</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onfinish</span><span class="p">;</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_onbufferchange</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_resetOnPosition</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-268'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-268">¶</a>
|
|
</div>
|
|
<p>reset some state items</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">instanceCount</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">instanceCount</span><span class="o">--</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">instanceCount</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-269'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-269">¶</a>
|
|
</div>
|
|
<p>remove onPosition listeners, if any</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">detachOnPosition</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-270'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-270">¶</a>
|
|
</div>
|
|
<p>reset instance options</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">paused</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">instanceCount</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">instanceOptions</span> <span class="o">=</span> <span class="p">{};</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span> <span class="o">=</span> <span class="p">{};</span>
|
|
<span class="nx">stop_html5_timer</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-271'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-271">¶</a>
|
|
</div>
|
|
<p>reset position, too</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">instanceCount</span> <span class="o">||</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">multiShotEvents</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-272'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-272">¶</a>
|
|
</div>
|
|
<p>fire onfinish for last, or every instance</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">io_onfinish</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': onfinish()'</span><span class="p">);</span>
|
|
<span class="nx">io_onfinish</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_whileloading</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nBytesLoaded</span><span class="p">,</span> <span class="nx">nBytesTotal</span><span class="p">,</span> <span class="nx">nDuration</span><span class="p">,</span> <span class="nx">nBufferLength</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">instanceOptions</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">;</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">bytesLoaded</span> <span class="o">=</span> <span class="nx">nBytesLoaded</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">bytesTotal</span> <span class="o">=</span> <span class="nx">nBytesTotal</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">duration</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">(</span><span class="nx">nDuration</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">bufferLength</span> <span class="o">=</span> <span class="nx">nBufferLength</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">isMovieStar</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">duration</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-273'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-273">¶</a>
|
|
</div>
|
|
<p>use duration from options, if specified and larger. nobody should be specifying duration in options, actually, and it should be retired.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">durationEstimate</span> <span class="o">=</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">duration</span> <span class="o">></span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">duration</span><span class="p">)</span> <span class="o">?</span> <span class="nx">s</span><span class="p">.</span><span class="nx">duration</span> <span class="o">:</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">duration</span><span class="p">;</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">durationEstimate</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="p">((</span><span class="nx">s</span><span class="p">.</span><span class="nx">bytesTotal</span> <span class="o">/</span> <span class="nx">s</span><span class="p">.</span><span class="nx">bytesLoaded</span><span class="p">)</span> <span class="o">*</span> <span class="nx">s</span><span class="p">.</span><span class="nx">duration</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">durationEstimate</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">duration</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-274'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-274">¶</a>
|
|
</div>
|
|
<p>for flash, reflect sequential-load-style buffering</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">buffered</span> <span class="o">=</span> <span class="p">[{</span>
|
|
<span class="s1">'start'</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span>
|
|
<span class="s1">'end'</span><span class="o">:</span> <span class="nx">s</span><span class="p">.</span><span class="nx">duration</span>
|
|
<span class="p">}];</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-275'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-275">¶</a>
|
|
</div>
|
|
<p>allow whileloading to fire even if “load” fired under HTML5, due to HTTP range/partials</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">((</span><span class="nx">s</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">!==</span> <span class="mi">3</span> <span class="o">||</span> <span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span><span class="p">)</span> <span class="o">&&</span> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">whileloading</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">whileloading</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_whileplaying</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nPosition</span><span class="p">,</span> <span class="nx">oPeakData</span><span class="p">,</span> <span class="nx">oWaveformDataLeft</span><span class="p">,</span> <span class="nx">oWaveformDataRight</span><span class="p">,</span> <span class="nx">oEQData</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">instanceOptions</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">,</span>
|
|
<span class="nx">eqLeft</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">nPosition</span><span class="p">)</span> <span class="o">||</span> <span class="nx">nPosition</span> <span class="o">===</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-276'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-276">¶</a>
|
|
</div>
|
|
<p>flash safety net</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-277'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-277">¶</a>
|
|
</div>
|
|
<p>Safari HTML5 play() may return small -ve values when starting from position: 0, eg. -50.120396875. Unexpected/invalid per W3, I think. Normalize to 0.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">max</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nx">nPosition</span><span class="p">);</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_processOnPosition</span><span class="p">();</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span> <span class="o">&&</span> <span class="nx">fV</span> <span class="o">></span> <span class="mi">8</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">usePeakData</span> <span class="o">&&</span> <span class="nx">oPeakData</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="nx">oPeakData</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">peakData</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="nx">left</span><span class="o">:</span> <span class="nx">oPeakData</span><span class="p">.</span><span class="nx">leftPeak</span><span class="p">,</span>
|
|
<span class="nx">right</span><span class="o">:</span> <span class="nx">oPeakData</span><span class="p">.</span><span class="nx">rightPeak</span>
|
|
<span class="p">};</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">useWaveformData</span> <span class="o">&&</span> <span class="nx">oWaveformDataLeft</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="nx">oWaveformDataLeft</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">waveformData</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="nx">left</span><span class="o">:</span> <span class="nx">oWaveformDataLeft</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">','</span><span class="p">),</span>
|
|
<span class="nx">right</span><span class="o">:</span> <span class="nx">oWaveformDataRight</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">','</span><span class="p">)</span>
|
|
<span class="p">};</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">useEQData</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">oEQData</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="nx">oEQData</span> <span class="o">&&</span> <span class="nx">oEQData</span><span class="p">.</span><span class="nx">leftEQ</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">eqLeft</span> <span class="o">=</span> <span class="nx">oEQData</span><span class="p">.</span><span class="nx">leftEQ</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">','</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">eqData</span> <span class="o">=</span> <span class="nx">eqLeft</span><span class="p">;</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">eqData</span><span class="p">.</span><span class="nx">left</span> <span class="o">=</span> <span class="nx">eqLeft</span><span class="p">;</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">oEQData</span><span class="p">.</span><span class="nx">rightEQ</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="nx">oEQData</span><span class="p">.</span><span class="nx">rightEQ</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">eqData</span><span class="p">.</span><span class="nx">right</span> <span class="o">=</span> <span class="nx">oEQData</span><span class="p">.</span><span class="nx">rightEQ</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">','</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">===</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-278'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-278">¶</a>
|
|
</div>
|
|
<p>special case/hack: ensure buffering is false if loading from cache (and not yet started)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">isHTML5</span> <span class="o">&&</span> <span class="nx">fV</span> <span class="o">===</span> <span class="mi">8</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">isBuffering</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_onbufferchange</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">whileplaying</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-279'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-279">¶</a>
|
|
</div>
|
|
<p>flash may call after actual finish</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">instanceOptions</span><span class="p">.</span><span class="nx">whileplaying</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_oncaptiondata</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oData</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-280'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-280">¶</a>
|
|
</div>
|
|
<p>internal: flash 9 + NetStream (MovieStar/RTMP-only) feature</p>
|
|
|
|
<p>@param {object} oData</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Caption data received.'</span><span class="p">);</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">captiondata</span> <span class="o">=</span> <span class="nx">oData</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">oncaptiondata</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">oncaptiondata</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">,</span> <span class="p">[</span><span class="nx">oData</span><span class="p">]);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_onmetadata</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oMDProps</span><span class="p">,</span> <span class="nx">oMDData</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-281'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-281">¶</a>
|
|
</div>
|
|
<p>internal: flash 9 + NetStream (MovieStar/RTMP-only) feature
|
|
RTMP may include song title, MovieStar content may include encoding info</p>
|
|
|
|
<p>@param {array} oMDProps (names)
|
|
@param {array} oMDData (values)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Metadata received.'</span><span class="p">);</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">oData</span> <span class="o">=</span> <span class="p">{},</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">j</span><span class="p">;</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">j</span> <span class="o">=</span> <span class="nx">oMDProps</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">j</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oData</span><span class="p">[</span><span class="nx">oMDProps</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">=</span> <span class="nx">oMDData</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">metadata</span> <span class="o">=</span> <span class="nx">oData</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onmetadata</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onmetadata</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_onid3</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oID3Props</span><span class="p">,</span> <span class="nx">oID3Data</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-282'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-282">¶</a>
|
|
</div>
|
|
<p>internal: flash 8 + flash 9 ID3 feature
|
|
may include artist, song title etc.</p>
|
|
|
|
<p>@param {array} oID3Props (names)
|
|
@param {array} oID3Data (values)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': ID3 data received.'</span><span class="p">);</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">oData</span> <span class="o">=</span> <span class="p">[],</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">j</span><span class="p">;</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">j</span> <span class="o">=</span> <span class="nx">oID3Props</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">j</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oData</span><span class="p">[</span><span class="nx">oID3Props</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">=</span> <span class="nx">oID3Data</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">id3</span> <span class="o">=</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id3</span><span class="p">,</span> <span class="nx">oData</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onid3</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onid3</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-283'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-283">¶</a>
|
|
</div>
|
|
<p>flash/RTMP-only</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_onconnect</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">bSuccess</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">bSuccess</span> <span class="o">=</span> <span class="p">(</span><span class="nx">bSuccess</span> <span class="o">===</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': '</span> <span class="o">+</span> <span class="p">(</span><span class="nx">bSuccess</span> <span class="o">?</span> <span class="s1">'Connected.'</span> <span class="o">:</span> <span class="s1">'Failed to connect? - '</span> <span class="o">+</span> <span class="nx">s</span><span class="p">.</span><span class="nx">url</span><span class="p">),</span> <span class="p">(</span><span class="nx">bSuccess</span> <span class="o">?</span> <span class="mi">1</span> <span class="o">:</span> <span class="mi">2</span><span class="p">));</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">connected</span> <span class="o">=</span> <span class="nx">bSuccess</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">bSuccess</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">failures</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">idCheck</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">getAutoPlay</span><span class="p">())</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-284'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-284">¶</a>
|
|
</div>
|
|
<p>only update the play state if auto playing</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">play</span><span class="p">(</span><span class="nx">_undefined</span><span class="p">,</span> <span class="nx">s</span><span class="p">.</span><span class="nx">getAutoPlay</span><span class="p">());</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">autoLoad</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">load</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onconnect</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">onconnect</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">,</span> <span class="p">[</span><span class="nx">bSuccess</span><span class="p">]);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_ondataerror</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sError</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-285'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-285">¶</a>
|
|
</div>
|
|
<p>flash 9 wave/eq data handler
|
|
hack: called at start, and end from flash at/after onfinish()</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">playState</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Data error: '</span> <span class="o">+</span> <span class="nx">sError</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">ondataerror</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">ondataerror</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-286'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-286">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_debug</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-287'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-287">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">};</span> <span class="c1">// SMSound()</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-Private_SoundManager_internals'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-Private_SoundManager_internals">¶</a>
|
|
</div>
|
|
<h2>Private SoundManager internals</h2>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">getDocument</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">return</span> <span class="p">(</span><span class="nx">doc</span><span class="p">.</span><span class="nx">body</span> <span class="o">||</span> <span class="nx">doc</span><span class="p">.</span><span class="nx">_docElement</span> <span class="o">||</span> <span class="nx">doc</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">'div'</span><span class="p">)[</span><span class="mi">0</span><span class="p">]);</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">id</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">return</span> <span class="nx">doc</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="nx">sID</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">mixin</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oMain</span><span class="p">,</span> <span class="nx">oAdd</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-289'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-289">¶</a>
|
|
</div>
|
|
<p>non-destructive merge</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">o1</span> <span class="o">=</span> <span class="p">(</span><span class="nx">oMain</span> <span class="o">||</span> <span class="p">{}),</span> <span class="nx">o2</span><span class="p">,</span> <span class="nx">o</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-290'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-290">¶</a>
|
|
</div>
|
|
<p>if unspecified, o2 is the default options object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">o2</span> <span class="o">=</span> <span class="p">(</span><span class="nx">oAdd</span> <span class="o">===</span> <span class="nx">_undefined</span> <span class="o">?</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">defaultOptions</span> <span class="o">:</span> <span class="nx">oAdd</span><span class="p">);</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">o</span> <span class="k">in</span> <span class="nx">o2</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">o2</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="o">&&</span> <span class="nx">o1</span><span class="p">[</span><span class="nx">o</span><span class="p">]</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">o2</span><span class="p">[</span><span class="nx">o</span><span class="p">]</span> <span class="o">!==</span> <span class="s1">'object'</span> <span class="o">||</span> <span class="nx">o2</span><span class="p">[</span><span class="nx">o</span><span class="p">]</span> <span class="o">===</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-291'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-291">¶</a>
|
|
</div>
|
|
<p>assign directly</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">o1</span><span class="p">[</span><span class="nx">o</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o2</span><span class="p">[</span><span class="nx">o</span><span class="p">];</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-292'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-292">¶</a>
|
|
</div>
|
|
<p>recurse through o2</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">o1</span><span class="p">[</span><span class="nx">o</span><span class="p">]</span> <span class="o">=</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">o1</span><span class="p">[</span><span class="nx">o</span><span class="p">],</span> <span class="nx">o2</span><span class="p">[</span><span class="nx">o</span><span class="p">]);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">o1</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-293'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-293">¶</a>
|
|
</div>
|
|
<p>additional soundManager properties that soundManager.setup() will accept</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">extraOptions</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="s1">'onready'</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span>
|
|
<span class="s1">'ontimeout'</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span>
|
|
<span class="s1">'defaultOptions'</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span>
|
|
<span class="s1">'flash9Options'</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span>
|
|
<span class="s1">'movieStarOptions'</span><span class="o">:</span> <span class="mi">1</span>
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">assign</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">,</span> <span class="nx">oParent</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-294'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-294">¶</a>
|
|
</div>
|
|
<p>recursive assignment of properties, soundManager.setup() helper
|
|
allows property assignment based on whitelist</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">i</span><span class="p">,</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span>
|
|
<span class="nx">hasParent</span> <span class="o">=</span> <span class="p">(</span><span class="nx">oParent</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">),</span>
|
|
<span class="nx">setupOptions</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">setupOptions</span><span class="p">,</span>
|
|
<span class="nx">bonusOptions</span> <span class="o">=</span> <span class="nx">extraOptions</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-295'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-295">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-296'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-296">¶</a>
|
|
</div>
|
|
<p>if soundManager.setup() called, show accepted parameters.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">o</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="p">[];</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">setupOptions</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">setupOptions</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">i</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">result</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">bonusOptions</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">bonusOptions</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">i</span><span class="p">))</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">sm2</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">===</span> <span class="s1">'object'</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">result</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">i</span><span class="o">+</span><span class="s1">': {...}'</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="k">instanceof</span> <span class="nb">Function</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">result</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">i</span><span class="o">+</span><span class="s1">': function() {...}'</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="nx">result</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">str</span><span class="p">(</span><span class="s1">'setup'</span><span class="p">,</span> <span class="nx">result</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">', '</span><span class="p">)));</span>
|
|
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-297'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-297">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">i</span><span class="p">))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-298'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-298">¶</a>
|
|
</div>
|
|
<p>if not an {object} we want to recurse through…</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">!==</span> <span class="s1">'object'</span> <span class="o">||</span> <span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">===</span> <span class="kc">null</span> <span class="o">||</span> <span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="k">instanceof</span> <span class="nb">Array</span> <span class="o">||</span> <span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="k">instanceof</span> <span class="nb">RegExp</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-299'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-299">¶</a>
|
|
</div>
|
|
<p>check “allowed” options</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">hasParent</span> <span class="o">&&</span> <span class="nx">bonusOptions</span><span class="p">[</span><span class="nx">oParent</span><span class="p">]</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-300'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-300">¶</a>
|
|
</div>
|
|
<p>valid recursive / nested object option, eg., { defaultOptions: { volume: 50 } }</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">[</span><span class="nx">oParent</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">setupOptions</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-301'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-301">¶</a>
|
|
</div>
|
|
<p>special case: assign to setupOptions object, which soundManager property references</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">setupOptions</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-302'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-302">¶</a>
|
|
</div>
|
|
<p>assign directly to soundManager, too</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">bonusOptions</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-303'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-303">¶</a>
|
|
</div>
|
|
<p>invalid or disallowed parameter. complain.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">complain</span><span class="p">(</span><span class="nx">str</span><span class="p">((</span><span class="nx">sm2</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">===</span> <span class="nx">_undefined</span> <span class="o">?</span> <span class="s1">'setupUndef'</span> <span class="o">:</span> <span class="s1">'setupError'</span><span class="p">),</span> <span class="nx">i</span><span class="p">),</span> <span class="mi">2</span><span class="p">);</span>
|
|
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-304'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-304">¶</a>
|
|
</div>
|
|
<p>valid extraOptions (bonusOptions) parameter.
|
|
is it a method, like onready/ontimeout? call it.
|
|
multiple parameters should be in an array, eg. soundManager.setup({onready: [myHandler, myScope]});</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="k">instanceof</span> <span class="nb">Function</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">apply</span><span class="p">(</span><span class="nx">sm2</span><span class="p">,</span> <span class="p">(</span><span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="k">instanceof</span> <span class="nb">Array</span><span class="o">?</span> <span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">:</span> <span class="p">[</span><span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">]]));</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-305'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-305">¶</a>
|
|
</div>
|
|
<p>good old-fashioned direct assignment</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-306'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-306">¶</a>
|
|
</div>
|
|
<p>recursion case, eg., { defaultOptions: { … } }</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">bonusOptions</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-307'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-307">¶</a>
|
|
</div>
|
|
<p>invalid or disallowed parameter. complain.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">complain</span><span class="p">(</span><span class="nx">str</span><span class="p">((</span><span class="nx">sm2</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">===</span> <span class="nx">_undefined</span> <span class="o">?</span> <span class="s1">'setupUndef'</span> <span class="o">:</span> <span class="s1">'setupError'</span><span class="p">),</span> <span class="nx">i</span><span class="p">),</span> <span class="mi">2</span><span class="p">);</span>
|
|
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-308'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-308">¶</a>
|
|
</div>
|
|
<p>recurse through object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="nx">assign</span><span class="p">(</span><span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span> <span class="nx">i</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="kd">function</span> <span class="nx">preferFlashCheck</span><span class="p">(</span><span class="nx">kind</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-309'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-309">¶</a>
|
|
</div>
|
|
<p>whether flash should play a given type</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">preferFlash</span> <span class="o">&&</span> <span class="nx">hasFlash</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">ignoreFlash</span> <span class="o">&&</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">flash</span><span class="p">[</span><span class="nx">kind</span><span class="p">]</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">flash</span><span class="p">[</span><span class="nx">kind</span><span class="p">]));</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-Internal_DOM2-level_event_helpers'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-Internal_DOM2-level_event_helpers">¶</a>
|
|
</div>
|
|
<h2>Internal DOM2-level event helpers</h2>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">event</span> <span class="o">=</span> <span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-311'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-311">¶</a>
|
|
</div>
|
|
<p>normalize event methods</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">old</span> <span class="o">=</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">attachEvent</span><span class="p">),</span>
|
|
<span class="nx">evt</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="nx">add</span><span class="o">:</span> <span class="p">(</span><span class="nx">old</span><span class="o">?</span><span class="s1">'attachEvent'</span><span class="o">:</span><span class="s1">'addEventListener'</span><span class="p">),</span>
|
|
<span class="nx">remove</span><span class="o">:</span> <span class="p">(</span><span class="nx">old</span><span class="o">?</span><span class="s1">'detachEvent'</span><span class="o">:</span><span class="s1">'removeEventListener'</span><span class="p">)</span>
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-312'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-312">¶</a>
|
|
</div>
|
|
<p>normalize “on” event prefix, optional capture argument</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">function</span> <span class="nx">getArgs</span><span class="p">(</span><span class="nx">oArgs</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">args</span> <span class="o">=</span> <span class="nx">slice</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">oArgs</span><span class="p">),</span>
|
|
<span class="nx">len</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">old</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-313'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-313">¶</a>
|
|
</div>
|
|
<p>prefix</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'on'</span> <span class="o">+</span> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">len</span> <span class="o">></span> <span class="mi">3</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-314'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-314">¶</a>
|
|
</div>
|
|
<p>no capture</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">args</span><span class="p">.</span><span class="nx">pop</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">len</span> <span class="o">===</span> <span class="mi">3</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">args</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="kc">false</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">args</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">function</span> <span class="nx">apply</span><span class="p">(</span><span class="nx">args</span><span class="p">,</span> <span class="nx">sType</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-315'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-315">¶</a>
|
|
</div>
|
|
<p>normalize and call the event method, with the proper arguments</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">element</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">shift</span><span class="p">(),</span>
|
|
<span class="nx">method</span> <span class="o">=</span> <span class="p">[</span><span class="nx">evt</span><span class="p">[</span><span class="nx">sType</span><span class="p">]];</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">old</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-316'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-316">¶</a>
|
|
</div>
|
|
<p>old IE can’t do apply().</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">element</span><span class="p">[</span><span class="nx">method</span><span class="p">](</span><span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">]);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">element</span><span class="p">[</span><span class="nx">method</span><span class="p">].</span><span class="nx">apply</span><span class="p">(</span><span class="nx">element</span><span class="p">,</span> <span class="nx">args</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">function</span> <span class="nx">add</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">apply</span><span class="p">(</span><span class="nx">getArgs</span><span class="p">(</span><span class="nx">arguments</span><span class="p">),</span> <span class="s1">'add'</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">function</span> <span class="nx">remove</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">apply</span><span class="p">(</span><span class="nx">getArgs</span><span class="p">(</span><span class="nx">arguments</span><span class="p">),</span> <span class="s1">'remove'</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="p">{</span>
|
|
<span class="s1">'add'</span><span class="o">:</span> <span class="nx">add</span><span class="p">,</span>
|
|
<span class="s1">'remove'</span><span class="o">:</span> <span class="nx">remove</span>
|
|
<span class="p">};</span>
|
|
|
|
<span class="p">}());</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-Internal_HTML5_event_handling'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-Internal_HTML5_event_handling">¶</a>
|
|
</div>
|
|
<h2>Internal HTML5 event handling</h2>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">function</span> <span class="nx">html5_event</span><span class="p">(</span><span class="nx">oFn</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-318'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-318">¶</a>
|
|
</div>
|
|
<p>wrap html5 event handlers so we don’t call them on destroyed and/or unloaded sounds</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">,</span>
|
|
<span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span> <span class="o">||</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">_a</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-319'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-319">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span> <span class="o">&&</span> <span class="nx">s</span><span class="p">.</span><span class="nx">id</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': Ignoring '</span> <span class="o">+</span> <span class="nx">e</span><span class="p">.</span><span class="nx">type</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">h5</span> <span class="o">+</span> <span class="s1">'Ignoring '</span> <span class="o">+</span> <span class="nx">e</span><span class="p">.</span><span class="nx">type</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-320'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-320">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">result</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="nx">oFn</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">e</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">html5_events</span> <span class="o">=</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-321'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-321">¶</a>
|
|
</div>
|
|
<p>HTML5 event-name-to-handler map</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">abort</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': abort'</span><span class="p">);</span>
|
|
|
|
<span class="p">}),</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-322'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-322">¶</a>
|
|
</div>
|
|
<p>enough has loaded to play</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">canplay</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">,</span>
|
|
<span class="nx">position1K</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_html5_canplay</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-323'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-323">¶</a>
|
|
</div>
|
|
<p>this event has already fired. ignore.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_html5_canplay</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': canplay'</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_onbufferchange</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-324'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-324">¶</a>
|
|
</div>
|
|
<p>position according to instance options</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">position1K</span> <span class="o">=</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">position</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="o">!</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">position</span><span class="p">)</span><span class="o">?</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">position</span><span class="o">/</span><span class="mi">1000</span><span class="o">:</span><span class="kc">null</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-325'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-325">¶</a>
|
|
</div>
|
|
<p>set the position if position was set before the sound loaded</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">&&</span> <span class="k">this</span><span class="p">.</span><span class="nx">currentTime</span> <span class="o">!==</span> <span class="nx">position1K</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': canplay: Setting position to '</span> <span class="o">+</span> <span class="nx">position1K</span><span class="p">);</span>
|
|
<span class="k">try</span> <span class="p">{</span>
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">currentTime</span> <span class="o">=</span> <span class="nx">position1K</span><span class="p">;</span>
|
|
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">ee</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': canplay: Setting position of '</span> <span class="o">+</span> <span class="nx">position1K</span> <span class="o">+</span> <span class="s1">' failed: '</span> <span class="o">+</span> <span class="nx">ee</span><span class="p">.</span><span class="nx">message</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-326'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-326">¶</a>
|
|
</div>
|
|
<p>hack for HTML5 from/to case</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">_oncanplay</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_iO</span><span class="p">.</span><span class="nx">_oncanplay</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}),</span>
|
|
|
|
<span class="nx">canplaythrough</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">loaded</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_onbufferchange</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_whileloading</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">bytesLoaded</span><span class="p">,</span> <span class="nx">s</span><span class="p">.</span><span class="nx">bytesTotal</span><span class="p">,</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_get_html5_duration</span><span class="p">());</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_onload</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}),</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-327'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-327">¶</a>
|
|
</div>
|
|
<p>TODO: Reserved for potential use</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="cm">/*</span>
|
|
<span class="cm"> emptied: html5_event(function() {</span>
|
|
|
|
<span class="cm"> sm2._wD(this._s.id + ': emptied');</span>
|
|
|
|
<span class="cm"> }),</span>
|
|
<span class="cm"> */</span>
|
|
|
|
<span class="nx">ended</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">;</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': ended'</span><span class="p">);</span>
|
|
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_onfinish</span><span class="p">();</span>
|
|
|
|
<span class="p">}),</span>
|
|
|
|
<span class="nx">error</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': HTML5 error, code '</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">error</span><span class="p">.</span><span class="nx">code</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-328'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-328">¶</a>
|
|
</div>
|
|
<p>call load with error state?</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">_onload</span><span class="p">(</span><span class="kc">false</span><span class="p">);</span>
|
|
|
|
<span class="p">}),</span>
|
|
|
|
<span class="nx">loadeddata</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">;</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': loadeddata'</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-329'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-329">¶</a>
|
|
</div>
|
|
<p>safari seems to nicely report progress events, eventually totalling 100%</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">_loaded</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">isSafari</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">duration</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_get_html5_duration</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}),</span>
|
|
|
|
<span class="nx">loadedmetadata</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': loadedmetadata'</span><span class="p">);</span>
|
|
|
|
<span class="p">}),</span>
|
|
|
|
<span class="nx">loadstart</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': loadstart'</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-330'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-330">¶</a>
|
|
</div>
|
|
<p>assume buffering at first</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">_onbufferchange</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
|
|
|
|
<span class="p">}),</span>
|
|
|
|
<span class="nx">play</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': play()'</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-331'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-331">¶</a>
|
|
</div>
|
|
<p>once play starts, no buffering</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">_onbufferchange</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
|
|
|
|
<span class="p">}),</span>
|
|
|
|
<span class="nx">playing</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': playing'</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-332'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-332">¶</a>
|
|
</div>
|
|
<p>once play starts, no buffering</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">_onbufferchange</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
|
|
|
|
<span class="p">}),</span>
|
|
|
|
<span class="nx">progress</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-333'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-333">¶</a>
|
|
</div>
|
|
<p>note: can fire repeatedly after “loaded” event, due to use of HTTP range/partials</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">,</span>
|
|
<span class="nx">i</span><span class="p">,</span> <span class="nx">j</span><span class="p">,</span> <span class="nx">str</span><span class="p">,</span> <span class="nx">buffered</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span>
|
|
<span class="nx">isProgress</span> <span class="o">=</span> <span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">type</span> <span class="o">===</span> <span class="s1">'progress'</span><span class="p">),</span>
|
|
<span class="nx">ranges</span> <span class="o">=</span> <span class="nx">e</span><span class="p">.</span><span class="nx">target</span><span class="p">.</span><span class="nx">buffered</span><span class="p">,</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-334'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-334">¶</a>
|
|
</div>
|
|
<p>firefox 3.6 implements e.loaded/total (bytes)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">loaded</span> <span class="o">=</span> <span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">loaded</span><span class="o">||</span><span class="mi">0</span><span class="p">),</span>
|
|
<span class="nx">total</span> <span class="o">=</span> <span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">total</span><span class="o">||</span><span class="mi">1</span><span class="p">),</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-335'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-335">¶</a>
|
|
</div>
|
|
<p>HTML5 returns msec. SM2 API uses seconds for setPosition() etc., whether Flash or HTML5.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">scale</span> <span class="o">=</span> <span class="mi">1000</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-336'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-336">¶</a>
|
|
</div>
|
|
<p>reset the “buffered” (loaded byte ranges) array</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">buffered</span> <span class="o">=</span> <span class="p">[];</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">ranges</span> <span class="o">&&</span> <span class="nx">ranges</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-337'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-337">¶</a>
|
|
</div>
|
|
<p>if loaded is 0, try TimeRanges implementation as % of load
|
|
https://developer.mozilla.org/en/DOM/TimeRanges</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-338'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-338">¶</a>
|
|
</div>
|
|
<p>re-build “buffered” array</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="nx">j</span><span class="o">=</span><span class="nx">ranges</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o"><</span><span class="nx">j</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">buffered</span><span class="p">.</span><span class="nx">push</span><span class="p">({</span>
|
|
<span class="s1">'start'</span><span class="o">:</span> <span class="nx">ranges</span><span class="p">.</span><span class="nx">start</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span> <span class="o">*</span> <span class="nx">scale</span><span class="p">,</span>
|
|
<span class="s1">'end'</span><span class="o">:</span> <span class="nx">ranges</span><span class="p">.</span><span class="nx">end</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span> <span class="o">*</span> <span class="nx">scale</span>
|
|
<span class="p">});</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-339'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-339">¶</a>
|
|
</div>
|
|
<p>use the last value locally</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">buffered</span> <span class="o">=</span> <span class="p">(</span><span class="nx">ranges</span><span class="p">.</span><span class="nx">end</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">-</span> <span class="nx">ranges</span><span class="p">.</span><span class="nx">start</span><span class="p">(</span><span class="mi">0</span><span class="p">))</span> <span class="o">*</span> <span class="nx">scale</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-340'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-340">¶</a>
|
|
</div>
|
|
<p>linear case, buffer sum; does not account for seeking and HTTP partials / byte ranges</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">loaded</span> <span class="o">=</span> <span class="nx">buffered</span><span class="o">/</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">target</span><span class="p">.</span><span class="nx">duration</span><span class="o">*</span><span class="nx">scale</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-341'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-341">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">isProgress</span> <span class="o">&&</span> <span class="nx">ranges</span><span class="p">.</span><span class="nx">length</span> <span class="o">></span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">str</span> <span class="o">=</span> <span class="p">[];</span>
|
|
<span class="nx">j</span> <span class="o">=</span> <span class="nx">ranges</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o"><</span><span class="nx">j</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">target</span><span class="p">.</span><span class="nx">buffered</span><span class="p">.</span><span class="nx">start</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span><span class="o">*</span><span class="nx">scale</span> <span class="o">+</span><span class="s1">'-'</span><span class="o">+</span> <span class="nx">e</span><span class="p">.</span><span class="nx">target</span><span class="p">.</span><span class="nx">buffered</span><span class="p">.</span><span class="nx">end</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span><span class="o">*</span><span class="nx">scale</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': progress, timeRanges: '</span> <span class="o">+</span> <span class="nx">str</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">', '</span><span class="p">));</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">isProgress</span> <span class="o">&&</span> <span class="o">!</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">loaded</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': progress, '</span> <span class="o">+</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">(</span><span class="nx">loaded</span><span class="o">*</span><span class="mi">100</span><span class="p">)</span> <span class="o">+</span> <span class="s1">'% loaded'</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-342'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-342">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">loaded</span><span class="p">))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-343'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-343">¶</a>
|
|
</div>
|
|
<p>if progress, likely not buffering</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_onbufferchange</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-344'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-344">¶</a>
|
|
</div>
|
|
<p>TODO: prevent calls with duplicate values.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_whileloading</span><span class="p">(</span><span class="nx">loaded</span><span class="p">,</span> <span class="nx">total</span><span class="p">,</span> <span class="nx">s</span><span class="p">.</span><span class="nx">_get_html5_duration</span><span class="p">());</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">loaded</span> <span class="o">&&</span> <span class="nx">total</span> <span class="o">&&</span> <span class="nx">loaded</span> <span class="o">===</span> <span class="nx">total</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-345'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-345">¶</a>
|
|
</div>
|
|
<p>in case “onload” doesn’t fire (eg. gecko 1.9.2)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">html5_events</span><span class="p">.</span><span class="nx">canplaythrough</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">e</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}),</span>
|
|
|
|
<span class="nx">ratechange</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': ratechange'</span><span class="p">);</span>
|
|
|
|
<span class="p">}),</span>
|
|
|
|
<span class="nx">suspend</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-346'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-346">¶</a>
|
|
</div>
|
|
<p>download paused/stopped, may have finished (eg. onload)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">;</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': suspend'</span><span class="p">);</span>
|
|
<span class="nx">html5_events</span><span class="p">.</span><span class="nx">progress</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">e</span><span class="p">);</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">_onsuspend</span><span class="p">();</span>
|
|
|
|
<span class="p">}),</span>
|
|
|
|
<span class="nx">stalled</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': stalled'</span><span class="p">);</span>
|
|
|
|
<span class="p">}),</span>
|
|
|
|
<span class="nx">timeupdate</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">_onTimer</span><span class="p">();</span>
|
|
|
|
<span class="p">}),</span>
|
|
|
|
<span class="nx">waiting</span><span class="o">:</span> <span class="nx">html5_event</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-347'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-347">¶</a>
|
|
</div>
|
|
<p>see also: seeking</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_s</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">': waiting'</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-348'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-348">¶</a>
|
|
</div>
|
|
<p>playback faster than download rate, etc.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span><span class="p">.</span><span class="nx">_onbufferchange</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
|
|
|
|
<span class="p">})</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">html5OK</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">iO</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-349'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-349">¶</a>
|
|
</div>
|
|
<p>playability test based on URL or MIME type</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">iO</span><span class="p">.</span><span class="nx">serverURL</span> <span class="o">||</span> <span class="p">(</span><span class="nx">iO</span><span class="p">.</span><span class="nx">type</span> <span class="o">&&</span> <span class="nx">preferFlashCheck</span><span class="p">(</span><span class="nx">iO</span><span class="p">.</span><span class="nx">type</span><span class="p">)))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-350'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-350">¶</a>
|
|
</div>
|
|
<p>RTMP, or preferring flash</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">result</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-351'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-351">¶</a>
|
|
</div>
|
|
<p>Use type, if specified. If HTML5-only mode, no other options, so just give ‘er</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">result</span> <span class="o">=</span> <span class="p">((</span><span class="nx">iO</span><span class="p">.</span><span class="nx">type</span> <span class="o">?</span> <span class="nx">html5CanPlay</span><span class="p">({</span><span class="nx">type</span><span class="o">:</span><span class="nx">iO</span><span class="p">.</span><span class="nx">type</span><span class="p">})</span> <span class="o">:</span> <span class="nx">html5CanPlay</span><span class="p">({</span><span class="nx">url</span><span class="o">:</span><span class="nx">iO</span><span class="p">.</span><span class="nx">url</span><span class="p">})</span> <span class="o">||</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span><span class="p">));</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">html5Unload</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oAudio</span><span class="p">,</span> <span class="nx">url</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-352'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-352">¶</a>
|
|
</div>
|
|
<p>Internal method: Unload media, and cancel any current/pending network requests.
|
|
Firefox can load an empty URL, which allegedly destroys the decoder and stops the download.
|
|
https://developer.mozilla.org/En/Using<em>audio</em>and<em>video</em>in<em>Firefox#Stopping</em>the<em>download</em>of_media
|
|
However, Firefox has been seen loading a relative URL from “ and thus requesting the hosting page on unload.
|
|
Other UA behaviour is unclear, so everyone else gets an about:blank-style URL.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">oAudio</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-353'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-353">¶</a>
|
|
</div>
|
|
<p>Firefox likes ” for unload (used to work?) – however, may request hosting page URL (bad.) Most other UAs dislike “ and fail to unload.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">oAudio</span><span class="p">.</span><span class="nx">src</span> <span class="o">=</span> <span class="nx">url</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-354'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-354">¶</a>
|
|
</div>
|
|
<p>reset some state, too</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">oAudio</span><span class="p">.</span><span class="nx">_called_load</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">useGlobalHTML5Audio</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-355'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-355">¶</a>
|
|
</div>
|
|
<p>ensure URL state is trashed, also</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">lastGlobalHTML5URL</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">html5CanPlay</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-356'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-356">¶</a>
|
|
</div>
|
|
<p>Try to find MIME, test and return truthiness
|
|
o = {
|
|
url: ’/path/to/an.mp3',
|
|
type: ‘audio/mp3’
|
|
}</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useHTML5Audio</span> <span class="o">||</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">hasHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">url</span> <span class="o">=</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">url</span> <span class="o">||</span> <span class="kc">null</span><span class="p">),</span>
|
|
<span class="nx">mime</span> <span class="o">=</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">type</span> <span class="o">||</span> <span class="kc">null</span><span class="p">),</span>
|
|
<span class="nx">aF</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">audioFormats</span><span class="p">,</span>
|
|
<span class="nx">result</span><span class="p">,</span>
|
|
<span class="nx">offset</span><span class="p">,</span>
|
|
<span class="nx">fileExt</span><span class="p">,</span>
|
|
<span class="nx">item</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-357'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-357">¶</a>
|
|
</div>
|
|
<p>account for known cases like audio/mp3</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">mime</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">mime</span><span class="p">]</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">mime</span><span class="p">]</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">preferFlashCheck</span><span class="p">(</span><span class="nx">mime</span><span class="p">));</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">html5Ext</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">html5Ext</span> <span class="o">=</span> <span class="p">[];</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">item</span> <span class="k">in</span> <span class="nx">aF</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">aF</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">item</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">html5Ext</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">item</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">aF</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">related</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">html5Ext</span> <span class="o">=</span> <span class="nx">html5Ext</span><span class="p">.</span><span class="nx">concat</span><span class="p">(</span><span class="nx">aF</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">related</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">html5Ext</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="s1">'\\.('</span><span class="o">+</span><span class="nx">html5Ext</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">'|'</span><span class="p">)</span><span class="o">+</span><span class="s1">')(\\?.*)?$'</span><span class="p">,</span><span class="s1">'i'</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-358'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-358">¶</a>
|
|
</div>
|
|
<p>TODO: Strip URL queries, etc.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">fileExt</span> <span class="o">=</span> <span class="p">(</span><span class="nx">url</span> <span class="o">?</span> <span class="nx">url</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">().</span><span class="nx">match</span><span class="p">(</span><span class="nx">html5Ext</span><span class="p">)</span> <span class="o">:</span> <span class="kc">null</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">fileExt</span> <span class="o">||</span> <span class="o">!</span><span class="nx">fileExt</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">mime</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-359'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-359">¶</a>
|
|
</div>
|
|
<p>audio/mp3 –> mp3, result should be known</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">offset</span> <span class="o">=</span> <span class="nx">mime</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">';'</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-360'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-360">¶</a>
|
|
</div>
|
|
<p>strip "audio/X; codecs…”</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">fileExt</span> <span class="o">=</span> <span class="p">(</span><span class="nx">offset</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="o">?</span><span class="nx">mime</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="nx">offset</span><span class="p">)</span><span class="o">:</span><span class="nx">mime</span><span class="p">).</span><span class="nx">substr</span><span class="p">(</span><span class="mi">6</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-361'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-361">¶</a>
|
|
</div>
|
|
<p>match the raw extension name – “mp3”, for example</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">fileExt</span> <span class="o">=</span> <span class="nx">fileExt</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">fileExt</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">fileExt</span><span class="p">]</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-362'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-362">¶</a>
|
|
</div>
|
|
<p>result known</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">result</span> <span class="o">=</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">fileExt</span><span class="p">]</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">preferFlashCheck</span><span class="p">(</span><span class="nx">fileExt</span><span class="p">));</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">mime</span> <span class="o">=</span> <span class="s1">'audio/'</span><span class="o">+</span><span class="nx">fileExt</span><span class="p">;</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">.</span><span class="nx">canPlayType</span><span class="p">({</span><span class="nx">type</span><span class="o">:</span><span class="nx">mime</span><span class="p">});</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">fileExt</span><span class="p">]</span> <span class="o">=</span> <span class="nx">result</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-363'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-363">¶</a>
|
|
</div>
|
|
<p>sm2._wD(‘canPlayType, found result: ’ + result);</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">result</span> <span class="o">=</span> <span class="p">(</span><span class="nx">result</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">mime</span><span class="p">]</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">preferFlashCheck</span><span class="p">(</span><span class="nx">mime</span><span class="p">));</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">testHTML5</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-364'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-364">¶</a>
|
|
</div>
|
|
<p>Internal: Iterates over audioFormats, determining support eg. audio/mp3, audio/mpeg and so on
|
|
assigns results to html5[] and flash[].</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useHTML5Audio</span> <span class="o">||</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">hasHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-365'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-365">¶</a>
|
|
</div>
|
|
<p>double-whammy: Opera 9.64 throws WRONG<em>ARGUMENTS</em>ERR if no parameter passed to Audio(), and Webkit + iOS happily tries to load “null” as a URL. :/</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="p">(</span><span class="nx">Audio</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">?</span> <span class="p">(</span><span class="nx">isOpera</span> <span class="o">&&</span> <span class="nx">opera</span><span class="p">.</span><span class="nx">version</span><span class="p">()</span> <span class="o"><</span> <span class="mi">10</span> <span class="o">?</span> <span class="k">new</span> <span class="nx">Audio</span><span class="p">(</span><span class="kc">null</span><span class="p">)</span> <span class="o">:</span> <span class="k">new</span> <span class="nx">Audio</span><span class="p">())</span> <span class="o">:</span> <span class="kc">null</span><span class="p">),</span>
|
|
<span class="nx">item</span><span class="p">,</span> <span class="nx">lookup</span><span class="p">,</span> <span class="nx">support</span> <span class="o">=</span> <span class="p">{},</span> <span class="nx">aF</span><span class="p">,</span> <span class="nx">i</span><span class="p">;</span>
|
|
|
|
<span class="kd">function</span> <span class="nx">cp</span><span class="p">(</span><span class="nx">m</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">canPlay</span><span class="p">,</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">j</span><span class="p">,</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span>
|
|
<span class="nx">isOK</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">a</span> <span class="o">||</span> <span class="k">typeof</span> <span class="nx">a</span><span class="p">.</span><span class="nx">canPlayType</span> <span class="o">!==</span> <span class="s1">'function'</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">m</span> <span class="k">instanceof</span> <span class="nb">Array</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-366'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-366">¶</a>
|
|
</div>
|
|
<p>iterate through all mime types, return any successes</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="nx">j</span><span class="o">=</span><span class="nx">m</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o"><</span><span class="nx">j</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">m</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">||</span> <span class="nx">a</span><span class="p">.</span><span class="nx">canPlayType</span><span class="p">(</span><span class="nx">m</span><span class="p">[</span><span class="nx">i</span><span class="p">]).</span><span class="nx">match</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Test</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">isOK</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">m</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-367'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-367">¶</a>
|
|
</div>
|
|
<p>note flash support, too</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">flash</span><span class="p">[</span><span class="nx">m</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">=</span> <span class="o">!!</span><span class="p">(</span><span class="nx">m</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">match</span><span class="p">(</span><span class="nx">flashMIME</span><span class="p">));</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="nx">isOK</span><span class="p">;</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">canPlay</span> <span class="o">=</span> <span class="p">(</span><span class="nx">a</span> <span class="o">&&</span> <span class="k">typeof</span> <span class="nx">a</span><span class="p">.</span><span class="nx">canPlayType</span> <span class="o">===</span> <span class="s1">'function'</span> <span class="o">?</span> <span class="nx">a</span><span class="p">.</span><span class="nx">canPlayType</span><span class="p">(</span><span class="nx">m</span><span class="p">)</span> <span class="o">:</span> <span class="kc">false</span><span class="p">);</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="o">!!</span><span class="p">(</span><span class="nx">canPlay</span> <span class="o">&&</span> <span class="p">(</span><span class="nx">canPlay</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Test</span><span class="p">)));</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-368'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-368">¶</a>
|
|
</div>
|
|
<p>test all registered formats + codecs</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">aF</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">audioFormats</span><span class="p">;</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">item</span> <span class="k">in</span> <span class="nx">aF</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">aF</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">item</span><span class="p">))</span> <span class="p">{</span>
|
|
|
|
<span class="nx">lookup</span> <span class="o">=</span> <span class="s1">'audio/'</span> <span class="o">+</span> <span class="nx">item</span><span class="p">;</span>
|
|
|
|
<span class="nx">support</span><span class="p">[</span><span class="nx">item</span><span class="p">]</span> <span class="o">=</span> <span class="nx">cp</span><span class="p">(</span><span class="nx">aF</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">type</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-369'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-369">¶</a>
|
|
</div>
|
|
<p>write back generic type too, eg. audio/mp3</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">support</span><span class="p">[</span><span class="nx">lookup</span><span class="p">]</span> <span class="o">=</span> <span class="nx">support</span><span class="p">[</span><span class="nx">item</span><span class="p">];</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-370'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-370">¶</a>
|
|
</div>
|
|
<p>assign flash</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">item</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="nx">flashMIME</span><span class="p">))</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">flash</span><span class="p">[</span><span class="nx">item</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">flash</span><span class="p">[</span><span class="nx">lookup</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">flash</span><span class="p">[</span><span class="nx">item</span><span class="p">]</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">flash</span><span class="p">[</span><span class="nx">lookup</span><span class="p">]</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-371'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-371">¶</a>
|
|
</div>
|
|
<p>assign result to related formats, too</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">aF</span><span class="p">[</span><span class="nx">item</span><span class="p">]</span> <span class="o">&&</span> <span class="nx">aF</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">related</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">aF</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">related</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">>=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-372'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-372">¶</a>
|
|
</div>
|
|
<p>eg. audio/m4a</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">support</span><span class="p">[</span><span class="s1">'audio/'</span><span class="o">+</span><span class="nx">aF</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">related</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">=</span> <span class="nx">support</span><span class="p">[</span><span class="nx">item</span><span class="p">];</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">aF</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">related</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">=</span> <span class="nx">support</span><span class="p">[</span><span class="nx">item</span><span class="p">];</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">flash</span><span class="p">[</span><span class="nx">aF</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">related</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">=</span> <span class="nx">support</span><span class="p">[</span><span class="nx">item</span><span class="p">];</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">support</span><span class="p">.</span><span class="nx">canPlayType</span> <span class="o">=</span> <span class="p">(</span><span class="nx">a</span><span class="o">?</span><span class="nx">cp</span><span class="o">:</span><span class="kc">null</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span> <span class="o">=</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">,</span> <span class="nx">support</span><span class="p">);</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">strings</span> <span class="o">=</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-373'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-373">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">notReady</span><span class="o">:</span> <span class="s1">'Unavailable - wait until onready() has fired.'</span><span class="p">,</span>
|
|
<span class="nx">notOK</span><span class="o">:</span> <span class="s1">'Audio support is not available.'</span><span class="p">,</span>
|
|
<span class="nx">domError</span><span class="o">:</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">'exception caught while appending SWF to DOM.'</span><span class="p">,</span>
|
|
<span class="nx">spcWmode</span><span class="o">:</span> <span class="s1">'Removing wmode, preventing known SWF loading issue(s)'</span><span class="p">,</span>
|
|
<span class="nx">swf404</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Verify that %s is a valid path.'</span><span class="p">,</span>
|
|
<span class="nx">tryDebug</span><span class="o">:</span> <span class="s1">'Try '</span> <span class="o">+</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.debugFlash = true for more security details (output goes to SWF.)'</span><span class="p">,</span>
|
|
<span class="nx">checkSWF</span><span class="o">:</span> <span class="s1">'See SWF output for more debug info.'</span><span class="p">,</span>
|
|
<span class="nx">localFail</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Non-HTTP page ('</span> <span class="o">+</span> <span class="nx">doc</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">protocol</span> <span class="o">+</span> <span class="s1">' URL?) Review Flash player security settings for this special case:\nhttp://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/'</span><span class="p">,</span>
|
|
<span class="nx">waitFocus</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Special case: Waiting for SWF to load with window focus...'</span><span class="p">,</span>
|
|
<span class="nx">waitForever</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Waiting indefinitely for Flash (will recover if unblocked)...'</span><span class="p">,</span>
|
|
<span class="nx">waitSWF</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Waiting for 100% SWF load...'</span><span class="p">,</span>
|
|
<span class="nx">needFunction</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Function object expected for %s'</span><span class="p">,</span>
|
|
<span class="nx">badID</span><span class="o">:</span> <span class="s1">'Warning: Sound ID "%s" should be a string, starting with a non-numeric character'</span><span class="p">,</span>
|
|
<span class="nx">currentObj</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'_debug(): Current sound objects'</span><span class="p">,</span>
|
|
<span class="nx">waitOnload</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Waiting for window.onload()'</span><span class="p">,</span>
|
|
<span class="nx">docLoaded</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Document already loaded'</span><span class="p">,</span>
|
|
<span class="nx">onload</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'initComplete(): calling soundManager.onload()'</span><span class="p">,</span>
|
|
<span class="nx">onloadOK</span><span class="o">:</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.onload() complete'</span><span class="p">,</span>
|
|
<span class="nx">didInit</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'init(): Already called?'</span><span class="p">,</span>
|
|
<span class="nx">secNote</span><span class="o">:</span> <span class="s1">'Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html'</span><span class="p">,</span>
|
|
<span class="nx">badRemove</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Failed to remove Flash node.'</span><span class="p">,</span>
|
|
<span class="nx">shutdown</span><span class="o">:</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.disable(): Shutting down'</span><span class="p">,</span>
|
|
<span class="nx">queue</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Queueing %s handler'</span><span class="p">,</span>
|
|
<span class="nx">smError</span><span class="o">:</span> <span class="s1">'SMSound.load(): Exception: JS-Flash communication failed, or JS error.'</span><span class="p">,</span>
|
|
<span class="nx">fbTimeout</span><span class="o">:</span> <span class="s1">'No flash response, applying .'</span><span class="o">+</span><span class="nx">swfCSS</span><span class="p">.</span><span class="nx">swfTimedout</span><span class="o">+</span><span class="s1">' CSS...'</span><span class="p">,</span>
|
|
<span class="nx">fbLoaded</span><span class="o">:</span> <span class="s1">'Flash loaded'</span><span class="p">,</span>
|
|
<span class="nx">flRemoved</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Flash movie removed.'</span><span class="p">,</span>
|
|
<span class="nx">fbHandler</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'flashBlockHandler()'</span><span class="p">,</span>
|
|
<span class="nx">manURL</span><span class="o">:</span> <span class="s1">'SMSound.load(): Using manually-assigned URL'</span><span class="p">,</span>
|
|
<span class="nx">onURL</span><span class="o">:</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.load(): current URL already assigned.'</span><span class="p">,</span>
|
|
<span class="nx">badFV</span><span class="o">:</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.'</span><span class="p">,</span>
|
|
<span class="nx">as2loop</span><span class="o">:</span> <span class="s1">'Note: Setting stream:false so looping can work (flash 8 limitation)'</span><span class="p">,</span>
|
|
<span class="nx">noNSLoop</span><span class="o">:</span> <span class="s1">'Note: Looping not implemented for MovieStar formats'</span><span class="p">,</span>
|
|
<span class="nx">needfl9</span><span class="o">:</span> <span class="s1">'Note: Switching to flash 9, required for MP4 formats.'</span><span class="p">,</span>
|
|
<span class="nx">mfTimeout</span><span class="o">:</span> <span class="s1">'Setting flashLoadTimeout = 0 (infinite) for off-screen, mobile flash case'</span><span class="p">,</span>
|
|
<span class="nx">needFlash</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Fatal error: Flash is needed to play some required formats, but is not available.'</span><span class="p">,</span>
|
|
<span class="nx">gotFocus</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Got window focus.'</span><span class="p">,</span>
|
|
<span class="nx">policy</span><span class="o">:</span> <span class="s1">'Enabling usePolicyFile for data access'</span><span class="p">,</span>
|
|
<span class="nx">setup</span><span class="o">:</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.setup(): allowed parameters: %s'</span><span class="p">,</span>
|
|
<span class="nx">setupError</span><span class="o">:</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.setup(): "%s" cannot be assigned with this method.'</span><span class="p">,</span>
|
|
<span class="nx">setupUndef</span><span class="o">:</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.setup(): Could not find option "%s"'</span><span class="p">,</span>
|
|
<span class="nx">setupLate</span><span class="o">:</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.setup(): url, flashVersion and html5Test property changes will not take effect until reboot().'</span><span class="p">,</span>
|
|
<span class="nx">noURL</span><span class="o">:</span> <span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Flash URL required. Call soundManager.setup({url:...}) to get started.'</span><span class="p">,</span>
|
|
<span class="nx">sm2Loaded</span><span class="o">:</span> <span class="s1">'SoundManager 2: Ready.'</span><span class="p">,</span>
|
|
<span class="nx">reset</span><span class="o">:</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">'.reset(): Removing event callbacks'</span><span class="p">,</span>
|
|
<span class="nx">mobileUA</span><span class="o">:</span> <span class="s1">'Mobile UA detected, preferring HTML5 by default.'</span><span class="p">,</span>
|
|
<span class="nx">globalHTML5</span><span class="o">:</span> <span class="s1">'Using singleton HTML5 Audio() pattern for this device.'</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-374'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-374">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">};</span>
|
|
|
|
<span class="nx">str</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-375'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-375">¶</a>
|
|
</div>
|
|
<p>internal string replace helper.
|
|
arguments: o [,items to replace]
|
|
<d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-376'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-376">¶</a>
|
|
</div>
|
|
<p>real array, please</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">args</span> <span class="o">=</span> <span class="nx">slice</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">arguments</span><span class="p">),</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-377'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-377">¶</a>
|
|
</div>
|
|
<p>first arg</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">o</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">shift</span><span class="p">(),</span>
|
|
|
|
<span class="nx">str</span> <span class="o">=</span> <span class="p">(</span><span class="nx">strings</span> <span class="o">&&</span> <span class="nx">strings</span><span class="p">[</span><span class="nx">o</span><span class="p">]</span><span class="o">?</span><span class="nx">strings</span><span class="p">[</span><span class="nx">o</span><span class="p">]</span><span class="o">:</span><span class="s1">''</span><span class="p">),</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">j</span><span class="p">;</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">str</span> <span class="o">&&</span> <span class="nx">args</span> <span class="o">&&</span> <span class="nx">args</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">j</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">j</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">str</span> <span class="o">=</span> <span class="nx">str</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="s1">'%s'</span><span class="p">,</span> <span class="nx">args</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">str</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-378'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-378">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">};</span>
|
|
|
|
<span class="nx">loopFix</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sOpt</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-379'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-379">¶</a>
|
|
</div>
|
|
<p>flash 8 requires stream = false for looping to work</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">fV</span> <span class="o">===</span> <span class="mi">8</span> <span class="o">&&</span> <span class="nx">sOpt</span><span class="p">.</span><span class="nx">loops</span> <span class="o">></span> <span class="mi">1</span> <span class="o">&&</span> <span class="nx">sOpt</span><span class="p">.</span><span class="nx">stream</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'as2loop'</span><span class="p">);</span>
|
|
<span class="nx">sOpt</span><span class="p">.</span><span class="nx">stream</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">sOpt</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">policyFix</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sOpt</span><span class="p">,</span> <span class="nx">sPre</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sOpt</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">sOpt</span><span class="p">.</span><span class="nx">usePolicyFile</span> <span class="o">&&</span> <span class="p">(</span><span class="nx">sOpt</span><span class="p">.</span><span class="nx">onid3</span> <span class="o">||</span> <span class="nx">sOpt</span><span class="p">.</span><span class="nx">usePeakData</span> <span class="o">||</span> <span class="nx">sOpt</span><span class="p">.</span><span class="nx">useWaveformData</span> <span class="o">||</span> <span class="nx">sOpt</span><span class="p">.</span><span class="nx">useEQData</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">((</span><span class="nx">sPre</span> <span class="o">||</span> <span class="s1">''</span><span class="p">)</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="s1">'policy'</span><span class="p">));</span>
|
|
<span class="nx">sOpt</span><span class="p">.</span><span class="nx">usePolicyFile</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">sOpt</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">complain</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sMsg</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-380'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-380">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">console</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="nx">console</span><span class="p">.</span><span class="nx">warn</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">console</span><span class="p">.</span><span class="nx">warn</span><span class="p">(</span><span class="nx">sMsg</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">sMsg</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-381'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-381">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">};</span>
|
|
|
|
<span class="nx">doNothing</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">disableObject</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">oProp</span><span class="p">;</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">oProp</span> <span class="k">in</span> <span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">oProp</span><span class="p">)</span> <span class="o">&&</span> <span class="k">typeof</span> <span class="nx">o</span><span class="p">[</span><span class="nx">oProp</span><span class="p">]</span> <span class="o">===</span> <span class="s1">'function'</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">o</span><span class="p">[</span><span class="nx">oProp</span><span class="p">]</span> <span class="o">=</span> <span class="nx">doNothing</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">oProp</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">failSafely</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">bNoDisable</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-382'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-382">¶</a>
|
|
</div>
|
|
<p>general failure exception handler</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">bNoDisable</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">bNoDisable</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">disabled</span> <span class="o">||</span> <span class="nx">bNoDisable</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">disable</span><span class="p">(</span><span class="nx">bNoDisable</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">normalizeMovieURL</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">smURL</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">urlParams</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">url</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">smURL</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">smURL</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/\.swf(\?.*)?$/i</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">urlParams</span> <span class="o">=</span> <span class="nx">smURL</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="nx">smURL</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">().</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s1">'.swf?'</span><span class="p">)</span> <span class="o">+</span> <span class="mi">4</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">urlParams</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-383'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-383">¶</a>
|
|
</div>
|
|
<p>assume user knows what they’re doing</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="nx">smURL</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">smURL</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s1">'/'</span><span class="p">)</span> <span class="o">!==</span> <span class="nx">smURL</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-384'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-384">¶</a>
|
|
</div>
|
|
<p>append trailing slash, if needed</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">smURL</span> <span class="o">+=</span> <span class="s1">'/'</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">url</span> <span class="o">=</span> <span class="p">(</span><span class="nx">smURL</span> <span class="o">&&</span> <span class="nx">smURL</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s1">'/'</span><span class="p">)</span> <span class="o">!==</span> <span class="o">-</span> <span class="mi">1</span> <span class="o">?</span> <span class="nx">smURL</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nx">smURL</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s1">'/'</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">:</span> <span class="s1">'./'</span><span class="p">)</span> <span class="o">+</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">movieURL</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">noSWFCache</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">url</span> <span class="o">+=</span> <span class="p">(</span><span class="s1">'?ts='</span> <span class="o">+</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">().</span><span class="nx">getTime</span><span class="p">());</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">url</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">setVersionInfo</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-385'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-385">¶</a>
|
|
</div>
|
|
<p>short-hand for internal use</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">fV</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">flashVersion</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">fV</span> <span class="o">!==</span> <span class="mi">8</span> <span class="o">&&</span> <span class="nx">fV</span> <span class="o">!==</span> <span class="mi">9</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">str</span><span class="p">(</span><span class="s1">'badFV'</span><span class="p">,</span> <span class="nx">fV</span><span class="p">,</span> <span class="nx">defaultFlashVersion</span><span class="p">));</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">flashVersion</span> <span class="o">=</span> <span class="nx">fV</span> <span class="o">=</span> <span class="nx">defaultFlashVersion</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-386'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-386">¶</a>
|
|
</div>
|
|
<p>debug flash movie, if applicable</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">isDebug</span> <span class="o">=</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugMode</span> <span class="o">||</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">debugFlash</span><span class="o">?</span><span class="s1">'_debug.swf'</span><span class="o">:</span><span class="s1">'.swf'</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useHTML5Audio</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">audioFormats</span><span class="p">.</span><span class="nx">mp4</span><span class="p">.</span><span class="nx">required</span> <span class="o">&&</span> <span class="nx">fV</span> <span class="o"><</span> <span class="mi">9</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">str</span><span class="p">(</span><span class="s1">'needfl9'</span><span class="p">));</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">flashVersion</span> <span class="o">=</span> <span class="nx">fV</span> <span class="o">=</span> <span class="mi">9</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">version</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">versionNumber</span> <span class="o">+</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span><span class="o">?</span><span class="s1">' (HTML5-only mode)'</span><span class="o">:</span><span class="p">(</span><span class="nx">fV</span> <span class="o">===</span> <span class="mi">9</span><span class="o">?</span><span class="s1">' (AS3/Flash 9)'</span><span class="o">:</span><span class="s1">' (AS2/Flash 8)'</span><span class="p">));</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-387'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-387">¶</a>
|
|
</div>
|
|
<p>set up default options</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">fV</span> <span class="o">></span> <span class="mi">8</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-388'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-388">¶</a>
|
|
</div>
|
|
<p>+flash 9 base options</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">defaultOptions</span> <span class="o">=</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">defaultOptions</span><span class="p">,</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">flash9Options</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">features</span><span class="p">.</span><span class="nx">buffering</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-389'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-389">¶</a>
|
|
</div>
|
|
<p>+moviestar support</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">defaultOptions</span> <span class="o">=</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">defaultOptions</span><span class="p">,</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">movieStarOptions</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">filePatterns</span><span class="p">.</span><span class="nx">flash9</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="s1">'\\.(mp3|'</span> <span class="o">+</span> <span class="nx">netStreamTypes</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">'|'</span><span class="p">)</span> <span class="o">+</span> <span class="s1">')(\\?.*)?$'</span><span class="p">,</span> <span class="s1">'i'</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">features</span><span class="p">.</span><span class="nx">movieStar</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">features</span><span class="p">.</span><span class="nx">movieStar</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-390'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-390">¶</a>
|
|
</div>
|
|
<p>regExp for flash canPlay(), etc.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">filePattern</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">filePatterns</span><span class="p">[(</span><span class="nx">fV</span> <span class="o">!==</span> <span class="mi">8</span><span class="o">?</span><span class="s1">'flash9'</span><span class="o">:</span><span class="s1">'flash8'</span><span class="p">)];</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-391'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-391">¶</a>
|
|
</div>
|
|
<p>if applicable, use _debug versions of SWFs</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">movieURL</span> <span class="o">=</span> <span class="p">(</span><span class="nx">fV</span> <span class="o">===</span> <span class="mi">8</span><span class="o">?</span><span class="s1">'soundmanager2.swf'</span><span class="o">:</span><span class="s1">'soundmanager2_flash9.swf'</span><span class="p">).</span><span class="nx">replace</span><span class="p">(</span><span class="s1">'.swf'</span><span class="p">,</span> <span class="nx">isDebug</span><span class="p">);</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">features</span><span class="p">.</span><span class="nx">peakData</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">features</span><span class="p">.</span><span class="nx">waveformData</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">features</span><span class="p">.</span><span class="nx">eqData</span> <span class="o">=</span> <span class="p">(</span><span class="nx">fV</span> <span class="o">></span> <span class="mi">8</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">setPolling</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">bPolling</span><span class="p">,</span> <span class="nx">bHighPerformance</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">flash</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">flash</span><span class="p">.</span><span class="nx">_setPolling</span><span class="p">(</span><span class="nx">bPolling</span><span class="p">,</span> <span class="nx">bHighPerformance</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">initDebug</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-392'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-392">¶</a>
|
|
</div>
|
|
<p>starts debug mode, creating output <div> for UAs without console object</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-393'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-393">¶</a>
|
|
</div>
|
|
<p>allow force of debug mode via URL</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugURLParam</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">wl</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">debugMode</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-394'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-394">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">id</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugID</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">oD</span><span class="p">,</span> <span class="nx">oDebug</span><span class="p">,</span> <span class="nx">oTarget</span><span class="p">,</span> <span class="nx">oToggle</span><span class="p">,</span> <span class="nx">tmp</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugMode</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">id</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugID</span><span class="p">)</span> <span class="o">&&</span> <span class="p">(</span><span class="o">!</span><span class="nx">hasConsole</span> <span class="o">||</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useConsole</span> <span class="o">||</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">consoleOnly</span><span class="p">))</span> <span class="p">{</span>
|
|
|
|
<span class="nx">oD</span> <span class="o">=</span> <span class="nx">doc</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">'div'</span><span class="p">);</span>
|
|
<span class="nx">oD</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">debugID</span> <span class="o">+</span> <span class="s1">'-toggle'</span><span class="p">;</span>
|
|
|
|
<span class="nx">oToggle</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="s1">'position'</span><span class="o">:</span> <span class="s1">'fixed'</span><span class="p">,</span>
|
|
<span class="s1">'bottom'</span><span class="o">:</span> <span class="s1">'0px'</span><span class="p">,</span>
|
|
<span class="s1">'right'</span><span class="o">:</span> <span class="s1">'0px'</span><span class="p">,</span>
|
|
<span class="s1">'width'</span><span class="o">:</span> <span class="s1">'1.2em'</span><span class="p">,</span>
|
|
<span class="s1">'height'</span><span class="o">:</span> <span class="s1">'1.2em'</span><span class="p">,</span>
|
|
<span class="s1">'lineHeight'</span><span class="o">:</span> <span class="s1">'1.2em'</span><span class="p">,</span>
|
|
<span class="s1">'margin'</span><span class="o">:</span> <span class="s1">'2px'</span><span class="p">,</span>
|
|
<span class="s1">'textAlign'</span><span class="o">:</span> <span class="s1">'center'</span><span class="p">,</span>
|
|
<span class="s1">'border'</span><span class="o">:</span> <span class="s1">'1px solid #999'</span><span class="p">,</span>
|
|
<span class="s1">'cursor'</span><span class="o">:</span> <span class="s1">'pointer'</span><span class="p">,</span>
|
|
<span class="s1">'background'</span><span class="o">:</span> <span class="s1">'#fff'</span><span class="p">,</span>
|
|
<span class="s1">'color'</span><span class="o">:</span> <span class="s1">'#333'</span><span class="p">,</span>
|
|
<span class="s1">'zIndex'</span><span class="o">:</span> <span class="mi">10001</span>
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">oD</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">doc</span><span class="p">.</span><span class="nx">createTextNode</span><span class="p">(</span><span class="s1">'-'</span><span class="p">));</span>
|
|
<span class="nx">oD</span><span class="p">.</span><span class="nx">onclick</span> <span class="o">=</span> <span class="nx">toggleDebug</span><span class="p">;</span>
|
|
<span class="nx">oD</span><span class="p">.</span><span class="nx">title</span> <span class="o">=</span> <span class="s1">'Toggle SM2 debug console'</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/msie 6/i</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">oD</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">position</span> <span class="o">=</span> <span class="s1">'absolute'</span><span class="p">;</span>
|
|
<span class="nx">oD</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">cursor</span> <span class="o">=</span> <span class="s1">'hand'</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">tmp</span> <span class="k">in</span> <span class="nx">oToggle</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">oToggle</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">tmp</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">oD</span><span class="p">.</span><span class="nx">style</span><span class="p">[</span><span class="nx">tmp</span><span class="p">]</span> <span class="o">=</span> <span class="nx">oToggle</span><span class="p">[</span><span class="nx">tmp</span><span class="p">];</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">oDebug</span> <span class="o">=</span> <span class="nx">doc</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">'div'</span><span class="p">);</span>
|
|
<span class="nx">oDebug</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">debugID</span><span class="p">;</span>
|
|
<span class="nx">oDebug</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">display</span> <span class="o">=</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugMode</span><span class="o">?</span><span class="s1">'block'</span><span class="o">:</span><span class="s1">'none'</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugMode</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">id</span><span class="p">(</span><span class="nx">oD</span><span class="p">.</span><span class="nx">id</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">try</span> <span class="p">{</span>
|
|
<span class="nx">oTarget</span> <span class="o">=</span> <span class="nx">getDocument</span><span class="p">();</span>
|
|
<span class="nx">oTarget</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">oD</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">e2</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="nx">str</span><span class="p">(</span><span class="s1">'domError'</span><span class="p">)</span><span class="o">+</span><span class="s1">' \n'</span><span class="o">+</span><span class="nx">e2</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">oTarget</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">oDebug</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">oTarget</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-395'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-395">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">};</span>
|
|
|
|
<span class="nx">idCheck</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getSoundById</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-396'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-396">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">_wDS</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">,</span> <span class="nx">errorLevel</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">return</span> <span class="p">(</span><span class="o">!</span><span class="nx">o</span> <span class="o">?</span> <span class="s1">''</span> <span class="o">:</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">str</span><span class="p">(</span><span class="nx">o</span><span class="p">),</span> <span class="nx">errorLevel</span><span class="p">));</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">toggleDebug</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="nx">id</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugID</span><span class="p">),</span>
|
|
<span class="nx">oT</span> <span class="o">=</span> <span class="nx">id</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugID</span> <span class="o">+</span> <span class="s1">'-toggle'</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">debugOpen</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-397'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-397">¶</a>
|
|
</div>
|
|
<p>minimize</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">oT</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s1">'+'</span><span class="p">;</span>
|
|
<span class="nx">o</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s1">'none'</span><span class="p">;</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">oT</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s1">'-'</span><span class="p">;</span>
|
|
<span class="nx">o</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s1">'block'</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">debugOpen</span> <span class="o">=</span> <span class="o">!</span><span class="nx">debugOpen</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">debugTS</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sEventType</span><span class="p">,</span> <span class="nx">bSuccess</span><span class="p">,</span> <span class="nx">sMessage</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-398'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-398">¶</a>
|
|
</div>
|
|
<p>troubleshooter debug hooks</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">sm2Debugger</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">try</span> <span class="p">{</span>
|
|
<span class="nx">sm2Debugger</span><span class="p">.</span><span class="nx">handleEvent</span><span class="p">(</span><span class="nx">sEventType</span><span class="p">,</span> <span class="nx">bSuccess</span><span class="p">,</span> <span class="nx">sMessage</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-399'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-399">¶</a>
|
|
</div>
|
|
<p>oh well</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-400'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-400">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">getSWFCSS</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">css</span> <span class="o">=</span> <span class="p">[];</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugMode</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">css</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">swfCSS</span><span class="p">.</span><span class="nx">sm2Debug</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugFlash</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">css</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">swfCSS</span><span class="p">.</span><span class="nx">flashDebug</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useHighPerformance</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">css</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">swfCSS</span><span class="p">.</span><span class="nx">highPerf</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">css</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">' '</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">flashBlockHandler</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-401'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-401">¶</a>
|
|
</div>
|
|
<p><em>possible</em> flash block situation.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">name</span> <span class="o">=</span> <span class="nx">str</span><span class="p">(</span><span class="s1">'fbHandler'</span><span class="p">),</span>
|
|
<span class="nx">p</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">getMoviePercent</span><span class="p">(),</span>
|
|
<span class="nx">css</span> <span class="o">=</span> <span class="nx">swfCSS</span><span class="p">,</span>
|
|
<span class="nx">error</span> <span class="o">=</span> <span class="p">{</span><span class="nx">type</span><span class="o">:</span><span class="s1">'FLASHBLOCK'</span><span class="p">};</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">ok</span><span class="p">())</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">needsFlash</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-402'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-402">¶</a>
|
|
</div>
|
|
<p>make the movie more visible, so user can fix</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">className</span> <span class="o">=</span> <span class="nx">getSWFCSS</span><span class="p">()</span> <span class="o">+</span> <span class="s1">' '</span> <span class="o">+</span> <span class="nx">css</span><span class="p">.</span><span class="nx">swfDefault</span> <span class="o">+</span> <span class="s1">' '</span> <span class="o">+</span> <span class="p">(</span><span class="nx">p</span> <span class="o">===</span> <span class="kc">null</span><span class="o">?</span><span class="nx">css</span><span class="p">.</span><span class="nx">swfTimedout</span><span class="o">:</span><span class="nx">css</span><span class="p">.</span><span class="nx">swfError</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">name</span> <span class="o">+</span> <span class="s1">': '</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="s1">'fbTimeout'</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="nx">p</span> <span class="o">?</span> <span class="s1">' ('</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="s1">'fbLoaded'</span><span class="p">)</span> <span class="o">+</span> <span class="s1">')'</span> <span class="o">:</span> <span class="s1">''</span><span class="p">));</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">didFlashBlock</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-403'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-403">¶</a>
|
|
</div>
|
|
<p>fire onready(), complain lightly</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">processOnEvents</span><span class="p">({</span><span class="nx">type</span><span class="o">:</span><span class="s1">'ontimeout'</span><span class="p">,</span> <span class="nx">ignoreInit</span><span class="o">:</span><span class="kc">true</span><span class="p">,</span> <span class="nx">error</span><span class="o">:</span><span class="nx">error</span><span class="p">});</span>
|
|
<span class="nx">catchError</span><span class="p">(</span><span class="nx">error</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-404'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-404">¶</a>
|
|
</div>
|
|
<p>SM2 loaded OK (or recovered)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-405'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-405">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">didFlashBlock</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">name</span> <span class="o">+</span> <span class="s1">': Unblocked'</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-406'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-406">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">className</span> <span class="o">=</span> <span class="p">[</span><span class="nx">getSWFCSS</span><span class="p">(),</span> <span class="nx">css</span><span class="p">.</span><span class="nx">swfDefault</span><span class="p">,</span> <span class="nx">css</span><span class="p">.</span><span class="nx">swfLoaded</span> <span class="o">+</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">didFlashBlock</span><span class="o">?</span><span class="s1">' '</span><span class="o">+</span><span class="nx">css</span><span class="p">.</span><span class="nx">swfUnblocked</span><span class="o">:</span><span class="s1">''</span><span class="p">)].</span><span class="nx">join</span><span class="p">(</span><span class="s1">' '</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">addOnEvent</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sType</span><span class="p">,</span> <span class="nx">oMethod</span><span class="p">,</span> <span class="nx">oScope</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">on_queue</span><span class="p">[</span><span class="nx">sType</span><span class="p">]</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">on_queue</span><span class="p">[</span><span class="nx">sType</span><span class="p">]</span> <span class="o">=</span> <span class="p">[];</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">on_queue</span><span class="p">[</span><span class="nx">sType</span><span class="p">].</span><span class="nx">push</span><span class="p">({</span>
|
|
<span class="s1">'method'</span><span class="o">:</span> <span class="nx">oMethod</span><span class="p">,</span>
|
|
<span class="s1">'scope'</span><span class="o">:</span> <span class="p">(</span><span class="nx">oScope</span> <span class="o">||</span> <span class="kc">null</span><span class="p">),</span>
|
|
<span class="s1">'fired'</span><span class="o">:</span> <span class="kc">false</span>
|
|
<span class="p">});</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">processOnEvents</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oOptions</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-407'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-407">¶</a>
|
|
</div>
|
|
<p>if unspecified, assume OK/error</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">oOptions</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oOptions</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="nx">type</span><span class="o">:</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">ok</span><span class="p">()</span> <span class="o">?</span> <span class="s1">'onready'</span> <span class="o">:</span> <span class="s1">'ontimeout'</span><span class="p">)</span>
|
|
<span class="p">};</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">didInit</span> <span class="o">&&</span> <span class="nx">oOptions</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">oOptions</span><span class="p">.</span><span class="nx">ignoreInit</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-408'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-408">¶</a>
|
|
</div>
|
|
<p>not ready yet.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">oOptions</span><span class="p">.</span><span class="nx">type</span> <span class="o">===</span> <span class="s1">'ontimeout'</span> <span class="o">&&</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">ok</span><span class="p">()</span> <span class="o">||</span> <span class="p">(</span><span class="nx">disabled</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">oOptions</span><span class="p">.</span><span class="nx">ignoreInit</span><span class="p">)))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-409'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-409">¶</a>
|
|
</div>
|
|
<p>invalid case</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">status</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="nx">success</span><span class="o">:</span> <span class="p">(</span><span class="nx">oOptions</span> <span class="o">&&</span> <span class="nx">oOptions</span><span class="p">.</span><span class="nx">ignoreInit</span><span class="o">?</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">ok</span><span class="p">()</span><span class="o">:!</span><span class="nx">disabled</span><span class="p">)</span>
|
|
<span class="p">},</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-410'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-410">¶</a>
|
|
</div>
|
|
<p>queue specified by type, or none</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">srcQueue</span> <span class="o">=</span> <span class="p">(</span><span class="nx">oOptions</span> <span class="o">&&</span> <span class="nx">oOptions</span><span class="p">.</span><span class="nx">type</span><span class="o">?</span><span class="nx">on_queue</span><span class="p">[</span><span class="nx">oOptions</span><span class="p">.</span><span class="nx">type</span><span class="p">]</span><span class="o">||</span><span class="p">[]</span><span class="o">:</span><span class="p">[]),</span>
|
|
|
|
<span class="nx">queue</span> <span class="o">=</span> <span class="p">[],</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">j</span><span class="p">,</span>
|
|
<span class="nx">args</span> <span class="o">=</span> <span class="p">[</span><span class="nx">status</span><span class="p">],</span>
|
|
<span class="nx">canRetry</span> <span class="o">=</span> <span class="p">(</span><span class="nx">needsFlash</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">ok</span><span class="p">());</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">oOptions</span><span class="p">.</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nx">error</span> <span class="o">=</span> <span class="nx">oOptions</span><span class="p">.</span><span class="nx">error</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">j</span> <span class="o">=</span> <span class="nx">srcQueue</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">j</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">srcQueue</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">fired</span> <span class="o">!==</span> <span class="kc">true</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">queue</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">srcQueue</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">queue</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-411'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-411">¶</a>
|
|
</div>
|
|
<p>sm2._wD(sm + ‘: Firing ’ + queue.length + ‘ ’ + oOptions.type + ‘() item’ + (queue.length === 1 ? “ : ’s'));</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">j</span> <span class="o">=</span> <span class="nx">queue</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">j</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">queue</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">scope</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">queue</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">method</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">queue</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">scope</span><span class="p">,</span> <span class="nx">args</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">queue</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">method</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">args</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">canRetry</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-412'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-412">¶</a>
|
|
</div>
|
|
<p>useFlashBlock and SWF timeout case doesn’t count here.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">queue</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">fired</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">initUserOnload</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nb">window</span><span class="p">.</span><span class="nx">setTimeout</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useFlashBlock</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">flashBlockHandler</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">processOnEvents</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-413'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-413">¶</a>
|
|
</div>
|
|
<p>call user-defined "onload”, scoped to window</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">onload</span> <span class="o">===</span> <span class="s1">'function'</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'onload'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">onload</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nb">window</span><span class="p">);</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'onloadOK'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">waitForWindowLoad</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">event</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="s1">'load'</span><span class="p">,</span> <span class="nx">initUserOnload</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">},</span><span class="mi">1</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">detectFlash</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-414'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-414">¶</a>
|
|
</div>
|
|
<p>hat tip: Flash Detect library (BSD, © 2007) by Carl “DocYes” S. Yestrau – http://featureblend.com/javascript-flash-detection-library.html / http://featureblend.com/license.txt</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">hasFlash</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-415'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-415">¶</a>
|
|
</div>
|
|
<p>this work has already been done.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="nx">hasFlash</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">hasPlugin</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">n</span> <span class="o">=</span> <span class="nx">navigator</span><span class="p">,</span> <span class="nx">nP</span> <span class="o">=</span> <span class="nx">n</span><span class="p">.</span><span class="nx">plugins</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">type</span><span class="p">,</span> <span class="nx">types</span><span class="p">,</span> <span class="nx">AX</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">ActiveXObject</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">nP</span> <span class="o">&&</span> <span class="nx">nP</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">type</span> <span class="o">=</span> <span class="s1">'application/x-shockwave-flash'</span><span class="p">;</span>
|
|
<span class="nx">types</span> <span class="o">=</span> <span class="nx">n</span><span class="p">.</span><span class="nx">mimeTypes</span><span class="p">;</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">types</span> <span class="o">&&</span> <span class="nx">types</span><span class="p">[</span><span class="nx">type</span><span class="p">]</span> <span class="o">&&</span> <span class="nx">types</span><span class="p">[</span><span class="nx">type</span><span class="p">].</span><span class="nx">enabledPlugin</span> <span class="o">&&</span> <span class="nx">types</span><span class="p">[</span><span class="nx">type</span><span class="p">].</span><span class="nx">enabledPlugin</span><span class="p">.</span><span class="nx">description</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">hasPlugin</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">AX</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/MSAppHost/i</span><span class="p">))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-416'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-416">¶</a>
|
|
</div>
|
|
<p>Windows 8 Store Apps (MSAppHost) are weird (compatibility?) and won’t complain here, but will barf if Flash/ActiveX object is appended to the DOM.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">try</span> <span class="p">{</span>
|
|
<span class="nx">obj</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">AX</span><span class="p">(</span><span class="s1">'ShockwaveFlash.ShockwaveFlash'</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-417'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-417">¶</a>
|
|
</div>
|
|
<p>oh well</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">}</span>
|
|
<span class="nx">hasPlugin</span> <span class="o">=</span> <span class="p">(</span><span class="o">!!</span><span class="nx">obj</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-418'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-418">¶</a>
|
|
</div>
|
|
<p>cleanup, because it is ActiveX after all</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">obj</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">hasFlash</span> <span class="o">=</span> <span class="nx">hasPlugin</span><span class="p">;</span>
|
|
|
|
<span class="k">return</span> <span class="nx">hasPlugin</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">featureCheck</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">needsFlash</span><span class="p">,</span>
|
|
<span class="nx">item</span><span class="p">,</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span>
|
|
<span class="nx">formats</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">audioFormats</span><span class="p">,</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-419'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-419">¶</a>
|
|
</div>
|
|
<p>iPhone <= 3.1 has broken HTML5 audio(), but firmware 3.2 (original iPad) + iOS4 works.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">isSpecial</span> <span class="o">=</span> <span class="p">(</span><span class="nx">is_iDevice</span> <span class="o">&&</span> <span class="o">!!</span><span class="p">(</span><span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/os (1|2|3_0|3_1)/i</span><span class="p">)));</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">isSpecial</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-420'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-420">¶</a>
|
|
</div>
|
|
<p>has Audio(), but is broken; let it load links directly.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">hasHTML5</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-421'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-421">¶</a>
|
|
</div>
|
|
<p>ignore flash case, however</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s1">'none'</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useHTML5Audio</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span> <span class="o">||</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">.</span><span class="nx">canPlayType</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="s1">'SoundManager: No HTML5 Audio() support detected.'</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">hasHTML5</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-422'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-422">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">isBadSafari</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">smc</span> <span class="o">+</span> <span class="s1">'Note: Buggy HTML5 Audio in Safari on this OS X release, see https://bugs.webkit.org/show_bug.cgi?id=32159 - '</span> <span class="o">+</span> <span class="p">(</span><span class="o">!</span><span class="nx">hasFlash</span> <span class="o">?</span><span class="s1">' would use flash fallback for MP3/MP4, but none detected.'</span> <span class="o">:</span> <span class="s1">'will use flash fallback for MP3/MP4, if available'</span><span class="p">),</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-423'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-423">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useHTML5Audio</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">hasHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">item</span> <span class="k">in</span> <span class="nx">formats</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">formats</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">item</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">((</span><span class="nx">formats</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">required</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">.</span><span class="nx">canPlayType</span><span class="p">(</span><span class="nx">formats</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">type</span><span class="p">))</span> <span class="o">||</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">preferFlash</span> <span class="o">&&</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">flash</span><span class="p">[</span><span class="nx">item</span><span class="p">]</span> <span class="o">||</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">flash</span><span class="p">[</span><span class="nx">formats</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">type</span><span class="p">])))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-424'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-424">¶</a>
|
|
</div>
|
|
<p>flash may be required, or preferred for this format</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">needsFlash</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-425'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-425">¶</a>
|
|
</div>
|
|
<p>sanity check…</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">ignoreFlash</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">needsFlash</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span> <span class="o">=</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">hasHTML5</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">useHTML5Audio</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">needsFlash</span><span class="p">);</span>
|
|
|
|
<span class="k">return</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">parseURL</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">url</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-426'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-426">¶</a>
|
|
</div>
|
|
<p>Internal: Finds and returns the first playable URL (or failing that, the first URL.)
|
|
@param {string or array} url A single URL string, OR, an array of URL strings or {url:‘/path/to/resource’, type:‘audio/mp3’} objects.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">j</span><span class="p">,</span> <span class="nx">urlResult</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">url</span> <span class="k">instanceof</span> <span class="nb">Array</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-427'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-427">¶</a>
|
|
</div>
|
|
<p>find the first good one</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="nx">j</span><span class="o">=</span><span class="nx">url</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o"><</span><span class="nx">j</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">url</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="k">instanceof</span> <span class="nb">Object</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-428'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-428">¶</a>
|
|
</div>
|
|
<p>MIME check</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">canPlayMIME</span><span class="p">(</span><span class="nx">url</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">type</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">urlResult</span> <span class="o">=</span> <span class="nx">i</span><span class="p">;</span>
|
|
<span class="k">break</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">canPlayURL</span><span class="p">(</span><span class="nx">url</span><span class="p">[</span><span class="nx">i</span><span class="p">]))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-429'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-429">¶</a>
|
|
</div>
|
|
<p>URL string check</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">urlResult</span> <span class="o">=</span> <span class="nx">i</span><span class="p">;</span>
|
|
<span class="k">break</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-430'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-430">¶</a>
|
|
</div>
|
|
<p>normalize to string</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">url</span><span class="p">[</span><span class="nx">urlResult</span><span class="p">].</span><span class="nx">url</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">url</span><span class="p">[</span><span class="nx">urlResult</span><span class="p">]</span> <span class="o">=</span> <span class="nx">url</span><span class="p">[</span><span class="nx">urlResult</span><span class="p">].</span><span class="nx">url</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="nx">url</span><span class="p">[</span><span class="nx">urlResult</span><span class="p">];</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-431'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-431">¶</a>
|
|
</div>
|
|
<p>single URL case</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">result</span> <span class="o">=</span> <span class="nx">url</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
|
|
<span class="nx">startTimer</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oSound</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-432'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-432">¶</a>
|
|
</div>
|
|
<p>attach a timer to this sound, and start an interval if needed</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">oSound</span><span class="p">.</span><span class="nx">_hasTimer</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">oSound</span><span class="p">.</span><span class="nx">_hasTimer</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">mobileHTML5</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5PollingInterval</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">h5IntervalTimer</span> <span class="o">===</span> <span class="kc">null</span> <span class="o">&&</span> <span class="nx">h5TimerCount</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">h5IntervalTimer</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">setInterval</span><span class="p">(</span><span class="nx">timerExecute</span><span class="p">,</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5PollingInterval</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">h5TimerCount</span><span class="o">++</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">stopTimer</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oSound</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-433'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-433">¶</a>
|
|
</div>
|
|
<p>detach a timer</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">oSound</span><span class="p">.</span><span class="nx">_hasTimer</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">oSound</span><span class="p">.</span><span class="nx">_hasTimer</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">mobileHTML5</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5PollingInterval</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-434'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-434">¶</a>
|
|
</div>
|
|
<p>interval will stop itself at next execution.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">h5TimerCount</span><span class="o">--</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">timerExecute</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-435'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-435">¶</a>
|
|
</div>
|
|
<p>manual polling for HTML5 progress events, ie., whileplaying() (can achieve greater precision than conservative default HTML5 interval)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">i</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">h5IntervalTimer</span> <span class="o">!==</span> <span class="kc">null</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">h5TimerCount</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-436'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-436">¶</a>
|
|
</div>
|
|
<p>no active timers, stop polling interval.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nb">window</span><span class="p">.</span><span class="nx">clearInterval</span><span class="p">(</span><span class="nx">h5IntervalTimer</span><span class="p">);</span>
|
|
|
|
<span class="nx">h5IntervalTimer</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-437'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-437">¶</a>
|
|
</div>
|
|
<p>check all HTML5 sounds with timers</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">>=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">[</span><span class="nx">i</span><span class="p">]].</span><span class="nx">isHTML5</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">[</span><span class="nx">i</span><span class="p">]].</span><span class="nx">_hasTimer</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">sounds</span><span class="p">[</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">soundIDs</span><span class="p">[</span><span class="nx">i</span><span class="p">]].</span><span class="nx">_onTimer</span><span class="p">();</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">catchError</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">options</span> <span class="o">=</span> <span class="p">(</span><span class="nx">options</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">?</span> <span class="nx">options</span> <span class="o">:</span> <span class="p">{});</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">onerror</span> <span class="o">===</span> <span class="s1">'function'</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">onerror</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="p">[{</span><span class="nx">type</span><span class="o">:</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">type</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">?</span> <span class="nx">options</span><span class="p">.</span><span class="nx">type</span> <span class="o">:</span> <span class="kc">null</span><span class="p">)}]);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">fatal</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="nx">options</span><span class="p">.</span><span class="nx">fatal</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">disable</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">badSafariFix</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-438'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-438">¶</a>
|
|
</div>
|
|
<p>special case: “bad” Safari (OS X 10.3 – 10.7) must fall back to flash for MP3/MP4</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">isBadSafari</span> <span class="o">||</span> <span class="o">!</span><span class="nx">detectFlash</span><span class="p">())</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-439'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-439">¶</a>
|
|
</div>
|
|
<p>doesn’t apply</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">aF</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">audioFormats</span><span class="p">,</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">item</span><span class="p">;</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">item</span> <span class="k">in</span> <span class="nx">aF</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">aF</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">item</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">item</span> <span class="o">===</span> <span class="s1">'mp3'</span> <span class="o">||</span> <span class="nx">item</span> <span class="o">===</span> <span class="s1">'mp4'</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">sm</span> <span class="o">+</span> <span class="s1">': Using flash fallback for '</span> <span class="o">+</span> <span class="nx">item</span> <span class="o">+</span> <span class="s1">' format'</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">item</span><span class="p">]</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-440'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-440">¶</a>
|
|
</div>
|
|
<p>assign result to related formats, too</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">aF</span><span class="p">[</span><span class="nx">item</span><span class="p">]</span> <span class="o">&&</span> <span class="nx">aF</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">related</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="nx">aF</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">related</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">>=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">aF</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">related</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-Pseudo-private_flash/ExternalInterface_methods'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-Pseudo-private_flash/ExternalInterface_methods">¶</a>
|
|
</div>
|
|
<h2>Pseudo-private flash/ExternalInterface methods</h2>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">_setSandboxType</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sandboxType</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-442'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-442">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">sb</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">sandbox</span><span class="p">;</span>
|
|
|
|
<span class="nx">sb</span><span class="p">.</span><span class="nx">type</span> <span class="o">=</span> <span class="nx">sandboxType</span><span class="p">;</span>
|
|
<span class="nx">sb</span><span class="p">.</span><span class="nx">description</span> <span class="o">=</span> <span class="nx">sb</span><span class="p">.</span><span class="nx">types</span><span class="p">[(</span><span class="nx">sb</span><span class="p">.</span><span class="nx">types</span><span class="p">[</span><span class="nx">sandboxType</span><span class="p">]</span> <span class="o">!==</span> <span class="nx">_undefined</span><span class="o">?</span><span class="nx">sandboxType</span><span class="o">:</span><span class="s1">'unknown'</span><span class="p">)];</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sb</span><span class="p">.</span><span class="nx">type</span> <span class="o">===</span> <span class="s1">'localWithFile'</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sb</span><span class="p">.</span><span class="nx">noRemote</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">sb</span><span class="p">.</span><span class="nx">noLocal</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'secNote'</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">sb</span><span class="p">.</span><span class="nx">type</span> <span class="o">===</span> <span class="s1">'localWithNetwork'</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sb</span><span class="p">.</span><span class="nx">noRemote</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">sb</span><span class="p">.</span><span class="nx">noLocal</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">sb</span><span class="p">.</span><span class="nx">type</span> <span class="o">===</span> <span class="s1">'localTrusted'</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sb</span><span class="p">.</span><span class="nx">noRemote</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">sb</span><span class="p">.</span><span class="nx">noLocal</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-443'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-443">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">};</span>
|
|
|
|
<span class="k">this</span><span class="p">.</span><span class="nx">_externalInterfaceOK</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">flashDate</span><span class="p">,</span> <span class="nx">swfVersion</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-444'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-444">¶</a>
|
|
</div>
|
|
<p>flash callback confirming flash loaded, EI working etc.
|
|
flashDate = approx. timing/delay info for JS/flash bridge
|
|
swfVersion: SWF build string</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">swfLoaded</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">e</span><span class="p">;</span>
|
|
|
|
<span class="nx">debugTS</span><span class="p">(</span><span class="s1">'swf'</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
|
|
<span class="nx">debugTS</span><span class="p">(</span><span class="s1">'flashtojs'</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">swfLoaded</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">tryInitOnFocus</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">isBadSafari</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">badSafariFix</span><span class="p">();</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-445'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-445">¶</a>
|
|
</div>
|
|
<p>complain if JS + SWF build/version strings don’t match, excluding +DEV builds
|
|
<d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">swfVersion</span> <span class="o">||</span> <span class="nx">swfVersion</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\+dev/i</span><span class="p">,</span><span class="s1">''</span><span class="p">)</span> <span class="o">!==</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">versionNumber</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\+dev/i</span><span class="p">,</span> <span class="s1">''</span><span class="p">))</span> <span class="p">{</span>
|
|
|
|
<span class="nx">e</span> <span class="o">=</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">': Fatal: JavaScript file build "'</span> <span class="o">+</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">versionNumber</span> <span class="o">+</span> <span class="s1">'" does not match Flash SWF build "'</span> <span class="o">+</span> <span class="nx">swfVersion</span> <span class="o">+</span> <span class="s1">'" at '</span> <span class="o">+</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">url</span> <span class="o">+</span> <span class="s1">'. Ensure both are up-to-date.'</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-446'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-446">¶</a>
|
|
</div>
|
|
<p>escape flash –> JS stack so this error fires in window.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">setTimeout</span><span class="p">(</span><span class="kd">function</span> <span class="nx">versionMismatch</span><span class="p">()</span> <span class="p">{</span>
|
|
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span>
|
|
<span class="p">},</span> <span class="mi">0</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-447'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-447">¶</a>
|
|
</div>
|
|
<p>exit, init will fail with timeout</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-448'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-448">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-449'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-449">¶</a>
|
|
</div>
|
|
<p>slight delay before init</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">setTimeout</span><span class="p">(</span><span class="nx">init</span><span class="p">,</span> <span class="nx">isIE</span> <span class="o">?</span> <span class="mi">100</span> <span class="o">:</span> <span class="mi">1</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-Private_initialization_helpers'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-Private_initialization_helpers">¶</a>
|
|
</div>
|
|
<h2>Private initialization helpers</h2>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">createMovie</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">smID</span><span class="p">,</span> <span class="nx">smURL</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">didAppend</span> <span class="o">&&</span> <span class="nx">appendSuccess</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-451'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-451">¶</a>
|
|
</div>
|
|
<p>ignore if already succeeded</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">function</span> <span class="nx">initMsg</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-452'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-452">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">options</span> <span class="o">=</span> <span class="p">[],</span> <span class="nx">title</span><span class="p">,</span> <span class="nx">str</span> <span class="o">=</span> <span class="p">[],</span> <span class="nx">delimiter</span> <span class="o">=</span> <span class="s1">' + '</span><span class="p">;</span>
|
|
|
|
<span class="nx">title</span> <span class="o">=</span> <span class="s1">'SoundManager '</span> <span class="o">+</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">version</span> <span class="o">+</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">useHTML5Audio</span> <span class="o">?</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">hasHTML5</span> <span class="o">?</span> <span class="s1">' + HTML5 audio'</span> <span class="o">:</span> <span class="s1">', no HTML5 audio support'</span><span class="p">)</span> <span class="o">:</span> <span class="s1">''</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">preferFlash</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">options</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="s1">'preferFlash'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useHighPerformance</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">options</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="s1">'useHighPerformance'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">flashPollingInterval</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">options</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="s1">'flashPollingInterval ('</span> <span class="o">+</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">flashPollingInterval</span> <span class="o">+</span> <span class="s1">'ms)'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5PollingInterval</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">options</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="s1">'html5PollingInterval ('</span> <span class="o">+</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5PollingInterval</span> <span class="o">+</span> <span class="s1">'ms)'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">wmode</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">options</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="s1">'wmode ('</span> <span class="o">+</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">wmode</span> <span class="o">+</span> <span class="s1">')'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugFlash</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">options</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="s1">'debugFlash'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useFlashBlock</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">options</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="s1">'flashBlock'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5PollingInterval</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">options</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="s1">'html5PollingInterval ('</span> <span class="o">+</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5PollingInterval</span> <span class="o">+</span> <span class="s1">'ms)'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">str</span> <span class="o">=</span> <span class="nx">str</span><span class="p">.</span><span class="nx">concat</span><span class="p">([</span><span class="nx">options</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">delimiter</span><span class="p">)]);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">title</span> <span class="o">+</span> <span class="p">(</span><span class="nx">str</span><span class="p">.</span><span class="nx">length</span> <span class="o">?</span> <span class="nx">delimiter</span> <span class="o">+</span> <span class="nx">str</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">', '</span><span class="p">)</span> <span class="o">:</span> <span class="s1">''</span><span class="p">),</span> <span class="mi">1</span><span class="p">);</span>
|
|
|
|
<span class="nx">showSupport</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-453'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-453">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-454'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-454">¶</a>
|
|
</div>
|
|
<p>100% HTML5 mode</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">setVersionInfo</span><span class="p">();</span>
|
|
|
|
<span class="nx">initMsg</span><span class="p">();</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span> <span class="o">=</span> <span class="nx">id</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">movieID</span><span class="p">);</span>
|
|
<span class="nx">init</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-455'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-455">¶</a>
|
|
</div>
|
|
<p>prevent multiple init attempts</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">didAppend</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="nx">appendSuccess</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-456'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-456">¶</a>
|
|
</div>
|
|
<p>flash path</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="kd">var</span> <span class="nx">remoteURL</span> <span class="o">=</span> <span class="p">(</span><span class="nx">smURL</span> <span class="o">||</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">url</span><span class="p">),</span>
|
|
<span class="nx">localURL</span> <span class="o">=</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">altURL</span> <span class="o">||</span> <span class="nx">remoteURL</span><span class="p">),</span>
|
|
<span class="nx">swfTitle</span> <span class="o">=</span> <span class="s1">'JS/Flash audio component (SoundManager 2)'</span><span class="p">,</span>
|
|
<span class="nx">oTarget</span> <span class="o">=</span> <span class="nx">getDocument</span><span class="p">(),</span>
|
|
<span class="nx">extraClass</span> <span class="o">=</span> <span class="nx">getSWFCSS</span><span class="p">(),</span>
|
|
<span class="nx">isRTL</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span>
|
|
<span class="nx">html</span> <span class="o">=</span> <span class="nx">doc</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">'html'</span><span class="p">)[</span><span class="mi">0</span><span class="p">],</span>
|
|
<span class="nx">oEmbed</span><span class="p">,</span> <span class="nx">oMovie</span><span class="p">,</span> <span class="nx">tmp</span><span class="p">,</span> <span class="nx">movieHTML</span><span class="p">,</span> <span class="nx">oEl</span><span class="p">,</span> <span class="nx">s</span><span class="p">,</span> <span class="nx">x</span><span class="p">,</span> <span class="nx">sClass</span><span class="p">;</span>
|
|
|
|
<span class="nx">isRTL</span> <span class="o">=</span> <span class="p">(</span><span class="nx">html</span> <span class="o">&&</span> <span class="nx">html</span><span class="p">.</span><span class="nx">dir</span> <span class="o">&&</span> <span class="nx">html</span><span class="p">.</span><span class="nx">dir</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/rtl/i</span><span class="p">));</span>
|
|
<span class="nx">smID</span> <span class="o">=</span> <span class="p">(</span><span class="nx">smID</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="o">?</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">id</span><span class="o">:</span><span class="nx">smID</span><span class="p">);</span>
|
|
|
|
<span class="kd">function</span> <span class="nx">param</span><span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">value</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="s1">'<param name="'</span><span class="o">+</span><span class="nx">name</span><span class="o">+</span><span class="s1">'" value="'</span><span class="o">+</span><span class="nx">value</span><span class="o">+</span><span class="s1">'" />'</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-457'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-457">¶</a>
|
|
</div>
|
|
<p>safety check for legacy (change to Flash 9 URL)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">setVersionInfo</span><span class="p">();</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">url</span> <span class="o">=</span> <span class="nx">normalizeMovieURL</span><span class="p">(</span><span class="nx">overHTTP</span><span class="o">?</span><span class="nx">remoteURL</span><span class="o">:</span><span class="nx">localURL</span><span class="p">);</span>
|
|
<span class="nx">smURL</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">url</span><span class="p">;</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">wmode</span> <span class="o">=</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">wmode</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">useHighPerformance</span> <span class="o">?</span> <span class="s1">'transparent'</span> <span class="o">:</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">wmode</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">wmode</span> <span class="o">!==</span> <span class="kc">null</span> <span class="o">&&</span> <span class="p">(</span><span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/msie 8/i</span><span class="p">)</span> <span class="o">||</span> <span class="p">(</span><span class="o">!</span><span class="nx">isIE</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useHighPerformance</span><span class="p">))</span> <span class="o">&&</span> <span class="nx">navigator</span><span class="p">.</span><span class="nx">platform</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/win32|win64/i</span><span class="p">))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-458'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-458">¶</a>
|
|
</div>
|
|
<p>extra-special case: movie doesn’t load until scrolled into view when using wmode = anything but ‘window’ here
|
|
does not apply when using high performance (position:fixed means on-screen), OR infinite flash load timeout
|
|
wmode breaks IE 8 on Vista + Win7 too in some cases, as of January 2011 (?)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">messages</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">strings</span><span class="p">.</span><span class="nx">spcWmode</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">wmode</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">oEmbed</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="s1">'name'</span><span class="o">:</span> <span class="nx">smID</span><span class="p">,</span>
|
|
<span class="s1">'id'</span><span class="o">:</span> <span class="nx">smID</span><span class="p">,</span>
|
|
<span class="s1">'src'</span><span class="o">:</span> <span class="nx">smURL</span><span class="p">,</span>
|
|
<span class="s1">'quality'</span><span class="o">:</span> <span class="s1">'high'</span><span class="p">,</span>
|
|
<span class="s1">'allowScriptAccess'</span><span class="o">:</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">allowScriptAccess</span><span class="p">,</span>
|
|
<span class="s1">'bgcolor'</span><span class="o">:</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">bgColor</span><span class="p">,</span>
|
|
<span class="s1">'pluginspage'</span><span class="o">:</span> <span class="nx">http</span><span class="o">+</span><span class="s1">'www.macromedia.com/go/getflashplayer'</span><span class="p">,</span>
|
|
<span class="s1">'title'</span><span class="o">:</span> <span class="nx">swfTitle</span><span class="p">,</span>
|
|
<span class="s1">'type'</span><span class="o">:</span> <span class="s1">'application/x-shockwave-flash'</span><span class="p">,</span>
|
|
<span class="s1">'wmode'</span><span class="o">:</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">wmode</span><span class="p">,</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-459'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-459">¶</a>
|
|
</div>
|
|
<p>http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c36cfb8137124318eebc6-7ffd.html</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="s1">'hasPriority'</span><span class="o">:</span> <span class="s1">'true'</span>
|
|
<span class="p">};</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugFlash</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oEmbed</span><span class="p">.</span><span class="nx">FlashVars</span> <span class="o">=</span> <span class="s1">'debug=1'</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">wmode</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-460'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-460">¶</a>
|
|
</div>
|
|
<p>don’t write empty attribute</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">delete</span> <span class="nx">oEmbed</span><span class="p">.</span><span class="nx">wmode</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">isIE</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-461'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-461">¶</a>
|
|
</div>
|
|
<p>IE is “special”.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">oMovie</span> <span class="o">=</span> <span class="nx">doc</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">'div'</span><span class="p">);</span>
|
|
<span class="nx">movieHTML</span> <span class="o">=</span> <span class="p">[</span>
|
|
<span class="s1">'<object id="'</span> <span class="o">+</span> <span class="nx">smID</span> <span class="o">+</span> <span class="s1">'" data="'</span> <span class="o">+</span> <span class="nx">smURL</span> <span class="o">+</span> <span class="s1">'" type="'</span> <span class="o">+</span> <span class="nx">oEmbed</span><span class="p">.</span><span class="nx">type</span> <span class="o">+</span> <span class="s1">'" title="'</span> <span class="o">+</span> <span class="nx">oEmbed</span><span class="p">.</span><span class="nx">title</span> <span class="o">+</span><span class="s1">'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'</span> <span class="o">+</span> <span class="nx">http</span><span class="o">+</span><span class="s1">'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">'</span><span class="p">,</span>
|
|
<span class="nx">param</span><span class="p">(</span><span class="s1">'movie'</span><span class="p">,</span> <span class="nx">smURL</span><span class="p">),</span>
|
|
<span class="nx">param</span><span class="p">(</span><span class="s1">'AllowScriptAccess'</span><span class="p">,</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">allowScriptAccess</span><span class="p">),</span>
|
|
<span class="nx">param</span><span class="p">(</span><span class="s1">'quality'</span><span class="p">,</span> <span class="nx">oEmbed</span><span class="p">.</span><span class="nx">quality</span><span class="p">),</span>
|
|
<span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">wmode</span><span class="o">?</span> <span class="nx">param</span><span class="p">(</span><span class="s1">'wmode'</span><span class="p">,</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">wmode</span><span class="p">)</span><span class="o">:</span> <span class="s1">''</span><span class="p">),</span>
|
|
<span class="nx">param</span><span class="p">(</span><span class="s1">'bgcolor'</span><span class="p">,</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">bgColor</span><span class="p">),</span>
|
|
<span class="nx">param</span><span class="p">(</span><span class="s1">'hasPriority'</span><span class="p">,</span> <span class="s1">'true'</span><span class="p">),</span>
|
|
<span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugFlash</span> <span class="o">?</span> <span class="nx">param</span><span class="p">(</span><span class="s1">'FlashVars'</span><span class="p">,</span> <span class="nx">oEmbed</span><span class="p">.</span><span class="nx">FlashVars</span><span class="p">)</span> <span class="o">:</span> <span class="s1">''</span><span class="p">),</span>
|
|
<span class="s1">'</object>'</span>
|
|
<span class="p">].</span><span class="nx">join</span><span class="p">(</span><span class="s1">''</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
|
|
<span class="nx">oMovie</span> <span class="o">=</span> <span class="nx">doc</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">'embed'</span><span class="p">);</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">tmp</span> <span class="k">in</span> <span class="nx">oEmbed</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">oEmbed</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">tmp</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">oMovie</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="nx">tmp</span><span class="p">,</span> <span class="nx">oEmbed</span><span class="p">[</span><span class="nx">tmp</span><span class="p">]);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">initDebug</span><span class="p">();</span>
|
|
<span class="nx">extraClass</span> <span class="o">=</span> <span class="nx">getSWFCSS</span><span class="p">();</span>
|
|
<span class="nx">oTarget</span> <span class="o">=</span> <span class="nx">getDocument</span><span class="p">();</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">oTarget</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span> <span class="o">=</span> <span class="p">(</span><span class="nx">id</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">movieID</span><span class="p">)</span> <span class="o">||</span> <span class="nx">doc</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">'div'</span><span class="p">));</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">id</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">movieID</span><span class="p">;</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">className</span> <span class="o">=</span> <span class="nx">swfCSS</span><span class="p">.</span><span class="nx">swfDefault</span> <span class="o">+</span> <span class="s1">' '</span> <span class="o">+</span> <span class="nx">extraClass</span><span class="p">;</span>
|
|
<span class="nx">s</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="nx">oEl</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useFlashBlock</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useHighPerformance</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-462'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-462">¶</a>
|
|
</div>
|
|
<p>on-screen at all times</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="s1">'position'</span><span class="o">:</span> <span class="s1">'fixed'</span><span class="p">,</span>
|
|
<span class="s1">'width'</span><span class="o">:</span> <span class="s1">'8px'</span><span class="p">,</span>
|
|
<span class="s1">'height'</span><span class="o">:</span> <span class="s1">'8px'</span><span class="p">,</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-463'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-463">¶</a>
|
|
</div>
|
|
<blockquote>
|
|
<p>= 6px for flash to run fast, >= 8px to start up under Firefox/win32 in some cases. odd? yes.</p>
|
|
</blockquote>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="s1">'bottom'</span><span class="o">:</span> <span class="s1">'0px'</span><span class="p">,</span>
|
|
<span class="s1">'left'</span><span class="o">:</span> <span class="s1">'0px'</span><span class="p">,</span>
|
|
<span class="s1">'overflow'</span><span class="o">:</span> <span class="s1">'hidden'</span>
|
|
<span class="p">};</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-464'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-464">¶</a>
|
|
</div>
|
|
<p>hide off-screen, lower priority</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">s</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="s1">'position'</span><span class="o">:</span> <span class="s1">'absolute'</span><span class="p">,</span>
|
|
<span class="s1">'width'</span><span class="o">:</span> <span class="s1">'6px'</span><span class="p">,</span>
|
|
<span class="s1">'height'</span><span class="o">:</span> <span class="s1">'6px'</span><span class="p">,</span>
|
|
<span class="s1">'top'</span><span class="o">:</span> <span class="s1">'-9999px'</span><span class="p">,</span>
|
|
<span class="s1">'left'</span><span class="o">:</span> <span class="s1">'-9999px'</span>
|
|
<span class="p">};</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">isRTL</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">s</span><span class="p">.</span><span class="nx">left</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">abs</span><span class="p">(</span><span class="nb">parseInt</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">left</span><span class="p">,</span><span class="mi">10</span><span class="p">))</span><span class="o">+</span><span class="s1">'px'</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">isWebkit</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-465'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-465">¶</a>
|
|
</div>
|
|
<p>soundcloud-reported render/crash fix, safari 5</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">zIndex</span> <span class="o">=</span> <span class="mi">10000</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugFlash</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">x</span> <span class="k">in</span> <span class="nx">s</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">x</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">style</span><span class="p">[</span><span class="nx">x</span><span class="p">]</span> <span class="o">=</span> <span class="nx">s</span><span class="p">[</span><span class="nx">x</span><span class="p">];</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">try</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">isIE</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">oMovie</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">oTarget</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">isIE</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oEl</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">doc</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">'div'</span><span class="p">));</span>
|
|
<span class="nx">oEl</span><span class="p">.</span><span class="nx">className</span> <span class="o">=</span> <span class="nx">swfCSS</span><span class="p">.</span><span class="nx">swfBox</span><span class="p">;</span>
|
|
<span class="nx">oEl</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">movieHTML</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">appendSuccess</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="nx">str</span><span class="p">(</span><span class="s1">'domError'</span><span class="p">)</span><span class="o">+</span><span class="s1">' \n'</span><span class="o">+</span><span class="nx">e</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-466'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-466">¶</a>
|
|
</div>
|
|
<p>SM2 container is already in the document (eg. flashblock use case)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sClass</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">className</span><span class="p">;</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">className</span> <span class="o">=</span> <span class="p">(</span><span class="nx">sClass</span><span class="o">?</span><span class="nx">sClass</span><span class="o">+</span><span class="s1">' '</span><span class="o">:</span><span class="nx">swfCSS</span><span class="p">.</span><span class="nx">swfDefault</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="nx">extraClass</span><span class="o">?</span><span class="s1">' '</span><span class="o">+</span><span class="nx">extraClass</span><span class="o">:</span><span class="s1">''</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">oMovie</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">isIE</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">oEl</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">doc</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">'div'</span><span class="p">));</span>
|
|
<span class="nx">oEl</span><span class="p">.</span><span class="nx">className</span> <span class="o">=</span> <span class="nx">swfCSS</span><span class="p">.</span><span class="nx">swfBox</span><span class="p">;</span>
|
|
<span class="nx">oEl</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">movieHTML</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">appendSuccess</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">didAppend</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">initMsg</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-467'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-467">¶</a>
|
|
</div>
|
|
<p>sm2._wD(sm + ‘: Trying to load ’ + smURL + (!overHTTP && sm2.altURL ? ‘ (alternate URL)’ : “), 1);</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">initMovie</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">createMovie</span><span class="p">();</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-468'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-468">¶</a>
|
|
</div>
|
|
<p>attempt to get, or create, movie (may already exist)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">flash</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">url</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-469'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-469">¶</a>
|
|
</div>
|
|
<p>Something isn’t right – we’ve reached init, but the soundManager url property has not been set.
|
|
User has not called setup({url: …}), or has not set soundManager.url (legacy use case) directly before init time.
|
|
Notify and exit. If user calls setup() with a url: property, init will be restarted as in the deferred loading case.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">_wDS</span><span class="p">(</span><span class="s1">'noURL'</span><span class="p">);</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-470'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-470">¶</a>
|
|
</div>
|
|
<p>inline markup case</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">flash</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">getMovie</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">id</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">flash</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">oRemoved</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-471'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-471">¶</a>
|
|
</div>
|
|
<p>try to create</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">createMovie</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">url</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-472'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-472">¶</a>
|
|
</div>
|
|
<p>try to re-append removed movie after reboot()</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">isIE</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">oRemoved</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">oRemovedHTML</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">oRemoved</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
|
<span class="nx">didAppend</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">flash</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">getMovie</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">id</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">oninitmovie</span> <span class="o">===</span> <span class="s1">'function'</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">setTimeout</span><span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">oninitmovie</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-473'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-473">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">flushMessages</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-474'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-474">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">delayWaitForEI</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">setTimeout</span><span class="p">(</span><span class="nx">waitForEI</span><span class="p">,</span> <span class="mi">1000</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">waitForEI</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">p</span><span class="p">,</span>
|
|
<span class="nx">loadIncomplete</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">url</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-475'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-475">¶</a>
|
|
</div>
|
|
<p>No SWF url to load (noURL case) – exit for now. Will be retried when url is set.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">waitingForEI</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">waitingForEI</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">event</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="s1">'load'</span><span class="p">,</span> <span class="nx">delayWaitForEI</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">tryInitOnFocus</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">isFocused</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-476'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-476">¶</a>
|
|
</div>
|
|
<p>Safari won’t load flash in background tabs, only when focused.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">_wDS</span><span class="p">(</span><span class="s1">'waitFocus'</span><span class="p">);</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">didInit</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">p</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">getMoviePercent</span><span class="p">();</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">p</span> <span class="o">></span> <span class="mi">0</span> <span class="o">&&</span> <span class="nx">p</span> <span class="o"><</span> <span class="mi">100</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">loadIncomplete</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">setTimeout</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="nx">p</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">getMoviePercent</span><span class="p">();</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">loadIncomplete</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-477'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-477">¶</a>
|
|
</div>
|
|
<p>special case: if movie <em>partially</em> loaded, retry until it’s 100% before assuming failure.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">waitingForEI</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">str</span><span class="p">(</span><span class="s1">'waitSWF'</span><span class="p">));</span>
|
|
<span class="nb">window</span><span class="p">.</span><span class="nx">setTimeout</span><span class="p">(</span><span class="nx">delayWaitForEI</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-478'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-478">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">didInit</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">sm</span> <span class="o">+</span> <span class="s1">': No Flash response within expected time. Likely causes: '</span> <span class="o">+</span> <span class="p">(</span><span class="nx">p</span> <span class="o">===</span> <span class="mi">0</span> <span class="o">?</span> <span class="s1">'SWF load failed, '</span><span class="o">:</span><span class="s1">''</span><span class="p">)</span> <span class="o">+</span> <span class="s1">'Flash blocked or JS-Flash security error.'</span> <span class="o">+</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugFlash</span><span class="o">?</span><span class="s1">' '</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="s1">'checkSWF'</span><span class="p">)</span><span class="o">:</span><span class="s1">''</span><span class="p">),</span> <span class="mi">2</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">overHTTP</span> <span class="o">&&</span> <span class="nx">p</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'localFail'</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugFlash</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'tryDebug'</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">p</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-479'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-479">¶</a>
|
|
</div>
|
|
<p>if 0 (not null), probably a 404.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="nx">str</span><span class="p">(</span><span class="s1">'swf404'</span><span class="p">,</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">url</span><span class="p">),</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">debugTS</span><span class="p">(</span><span class="s1">'flashtojs'</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="s1">': Timed out'</span> <span class="o">+</span> <span class="nx">overHTTP</span><span class="o">?</span><span class="s1">' (Check flash security or flash blockers)'</span><span class="o">:</span><span class="s1">' (No plugin/missing SWF?)'</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-480'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-480">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-481'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-481">¶</a>
|
|
</div>
|
|
<p>give up / time-out, depending</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">didInit</span> <span class="o">&&</span> <span class="nx">okToDisable</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">p</span> <span class="o">===</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-482'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-482">¶</a>
|
|
</div>
|
|
<p>SWF failed. Maybe blocked.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useFlashBlock</span> <span class="o">||</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">flashLoadTimeout</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useFlashBlock</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">flashBlockHandler</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'waitForever'</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-483'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-483">¶</a>
|
|
</div>
|
|
<p>no custom flash block handling, but SWF has timed out. Will recover if user unblocks / allows SWF load.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">_wDS</span><span class="p">(</span><span class="s1">'waitForever'</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-484'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-484">¶</a>
|
|
</div>
|
|
<p>fire any regular registered ontimeout() listeners.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">processOnEvents</span><span class="p">({</span><span class="nx">type</span><span class="o">:</span><span class="s1">'ontimeout'</span><span class="p">,</span> <span class="nx">ignoreInit</span><span class="o">:</span> <span class="kc">true</span><span class="p">});</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-485'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-485">¶</a>
|
|
</div>
|
|
<p>flash loaded? Shouldn’t be a blocking issue, then.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">flashLoadTimeout</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'waitForever'</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">failSafely</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">},</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">flashLoadTimeout</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">handleFocus</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">function</span> <span class="nx">cleanup</span><span class="p">()</span> <span class="p">{</span>
|
|
<span class="nx">event</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="s1">'focus'</span><span class="p">,</span> <span class="nx">handleFocus</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">isFocused</span> <span class="o">||</span> <span class="o">!</span><span class="nx">tryInitOnFocus</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-486'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-486">¶</a>
|
|
</div>
|
|
<p>already focused, or not special Safari background tab case</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">cleanup</span><span class="p">();</span>
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">okToDisable</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">isFocused</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'gotFocus'</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-487'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-487">¶</a>
|
|
</div>
|
|
<p>allow init to restart</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">waitingForEI</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-488'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-488">¶</a>
|
|
</div>
|
|
<p>kick off ExternalInterface timeout, now that the SWF has started</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">delayWaitForEI</span><span class="p">();</span>
|
|
|
|
<span class="nx">cleanup</span><span class="p">();</span>
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">flushMessages</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-489'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-489">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-490'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-490">¶</a>
|
|
</div>
|
|
<p>SM2 pre-init debug messages</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">messages</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="s1">'SoundManager 2: '</span> <span class="o">+</span> <span class="nx">messages</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">' '</span><span class="p">),</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="nx">messages</span> <span class="o">=</span> <span class="p">[];</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-491'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-491">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">};</span>
|
|
|
|
<span class="nx">showSupport</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-492'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-492">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">flushMessages</span><span class="p">();</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">item</span><span class="p">,</span> <span class="nx">tests</span> <span class="o">=</span> <span class="p">[];</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useHTML5Audio</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">hasHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">item</span> <span class="k">in</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">audioFormats</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">audioFormats</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">item</span><span class="p">))</span> <span class="p">{</span>
|
|
<span class="nx">tests</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">item</span> <span class="o">+</span> <span class="s1">' = '</span> <span class="o">+</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">item</span><span class="p">]</span> <span class="o">+</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">item</span><span class="p">]</span> <span class="o">&&</span> <span class="nx">hasFlash</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">flash</span><span class="p">[</span><span class="nx">item</span><span class="p">]</span> <span class="o">?</span> <span class="s1">' (using flash)'</span> <span class="o">:</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">preferFlash</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">flash</span><span class="p">[</span><span class="nx">item</span><span class="p">]</span> <span class="o">&&</span> <span class="nx">hasFlash</span> <span class="o">?</span> <span class="s1">' (preferring flash)'</span><span class="o">:</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">[</span><span class="nx">item</span><span class="p">]</span> <span class="o">?</span> <span class="s1">' ('</span> <span class="o">+</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">audioFormats</span><span class="p">[</span><span class="nx">item</span><span class="p">].</span><span class="nx">required</span> <span class="o">?</span> <span class="s1">'required, '</span><span class="o">:</span><span class="s1">''</span><span class="p">)</span> <span class="o">+</span> <span class="s1">'and no flash support)'</span> <span class="o">:</span> <span class="s1">''</span><span class="p">))));</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="s1">'SoundManager 2 HTML5 support: '</span> <span class="o">+</span> <span class="nx">tests</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">', '</span><span class="p">),</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-493'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-493">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">};</span>
|
|
|
|
<span class="nx">initComplete</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">bNoDisable</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">didInit</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-494'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-494">¶</a>
|
|
</div>
|
|
<p>all good.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">_wDS</span><span class="p">(</span><span class="s1">'sm2Loaded'</span><span class="p">);</span>
|
|
<span class="nx">didInit</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">initUserOnload</span><span class="p">();</span>
|
|
<span class="nx">debugTS</span><span class="p">(</span><span class="s1">'onload'</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">wasTimeout</span> <span class="o">=</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useFlashBlock</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">flashLoadTimeout</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">getMoviePercent</span><span class="p">()),</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span>
|
|
<span class="nx">error</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">wasTimeout</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">didInit</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">disabled</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">error</span> <span class="o">=</span> <span class="p">{</span><span class="nx">type</span><span class="o">:</span> <span class="p">(</span><span class="o">!</span><span class="nx">hasFlash</span> <span class="o">&&</span> <span class="nx">needsFlash</span> <span class="o">?</span> <span class="s1">'NO_FLASH'</span> <span class="o">:</span> <span class="s1">'INIT_TIMEOUT'</span><span class="p">)};</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="s1">'SoundManager 2 '</span> <span class="o">+</span> <span class="p">(</span><span class="nx">disabled</span> <span class="o">?</span> <span class="s1">'failed to load'</span> <span class="o">:</span> <span class="s1">'loaded'</span><span class="p">)</span> <span class="o">+</span> <span class="s1">' ('</span> <span class="o">+</span> <span class="p">(</span><span class="nx">disabled</span> <span class="o">?</span> <span class="s1">'Flash security/load error'</span> <span class="o">:</span> <span class="s1">'OK'</span><span class="p">)</span> <span class="o">+</span> <span class="s1">')'</span><span class="p">,</span> <span class="nx">disabled</span> <span class="o">?</span> <span class="mi">2</span><span class="o">:</span> <span class="mi">1</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">disabled</span> <span class="o">||</span> <span class="nx">bNoDisable</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useFlashBlock</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">oMC</span><span class="p">.</span><span class="nx">className</span> <span class="o">=</span> <span class="nx">getSWFCSS</span><span class="p">()</span> <span class="o">+</span> <span class="s1">' '</span> <span class="o">+</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">getMoviePercent</span><span class="p">()</span> <span class="o">===</span> <span class="kc">null</span><span class="o">?</span><span class="nx">swfCSS</span><span class="p">.</span><span class="nx">swfTimedout</span><span class="o">:</span><span class="nx">swfCSS</span><span class="p">.</span><span class="nx">swfError</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">processOnEvents</span><span class="p">({</span><span class="nx">type</span><span class="o">:</span><span class="s1">'ontimeout'</span><span class="p">,</span> <span class="nx">error</span><span class="o">:</span><span class="nx">error</span><span class="p">,</span> <span class="nx">ignoreInit</span><span class="o">:</span> <span class="kc">true</span><span class="p">});</span>
|
|
<span class="nx">debugTS</span><span class="p">(</span><span class="s1">'onload'</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span>
|
|
<span class="nx">catchError</span><span class="p">(</span><span class="nx">error</span><span class="p">);</span>
|
|
<span class="nx">result</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
<span class="nx">debugTS</span><span class="p">(</span><span class="s1">'onload'</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">disabled</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">waitForWindowLoad</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">windowLoaded</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'waitOnload'</span><span class="p">);</span>
|
|
<span class="nx">event</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="s1">'load'</span><span class="p">,</span> <span class="nx">initUserOnload</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-495'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-495">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">waitForWindowLoad</span> <span class="o">&&</span> <span class="nx">windowLoaded</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'docLoaded'</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-496'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-496">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">initUserOnload</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-497'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-497">¶</a>
|
|
</div>
|
|
<p>apply top-level setupOptions object as local properties, eg., this.setupOptions.flashVersion –> this.flashVersion (soundManager.flashVersion)
|
|
this maintains backward compatibility, and allows properties to be defined separately for use by soundManager.setup().</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">setProperties</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">i</span><span class="p">,</span>
|
|
<span class="nx">o</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">setupOptions</span><span class="p">;</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">i</span><span class="p">))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-498'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-498">¶</a>
|
|
</div>
|
|
<p>assign local property if not already defined</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">===</span> <span class="nx">_undefined</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">!==</span> <span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-499'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-499">¶</a>
|
|
</div>
|
|
<p>legacy support: write manually-assigned property (eg., soundManager.url) back to setupOptions to keep things in sync</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">setupOptions</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
|
|
<span class="nx">init</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-500'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-500">¶</a>
|
|
</div>
|
|
<p>called after onload()</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">didInit</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">'didInit'</span><span class="p">);</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="kd">function</span> <span class="nx">cleanup</span><span class="p">()</span> <span class="p">{</span>
|
|
<span class="nx">event</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="s1">'load'</span><span class="p">,</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">beginDelayedInit</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">didInit</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-501'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-501">¶</a>
|
|
</div>
|
|
<p>we don’t need no steenking flash!</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">cleanup</span><span class="p">();</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">enabled</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">initComplete</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-502'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-502">¶</a>
|
|
</div>
|
|
<p>flash path</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">initMovie</span><span class="p">();</span>
|
|
|
|
<span class="k">try</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-503'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-503">¶</a>
|
|
</div>
|
|
<p>attempt to talk to Flash</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">flash</span><span class="p">.</span><span class="nx">_externalInterfaceTest</span><span class="p">(</span><span class="kc">false</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-504'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-504">¶</a>
|
|
</div>
|
|
<p>apply user-specified polling interval, OR, if "high performance” set, faster vs. default polling
|
|
(determines frequency of whileloading/whileplaying callbacks, effectively driving UI framerates)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">setPolling</span><span class="p">(</span><span class="kc">true</span><span class="p">,</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">flashPollingInterval</span> <span class="o">||</span> <span class="p">(</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useHighPerformance</span> <span class="o">?</span> <span class="mi">10</span> <span class="o">:</span> <span class="mi">50</span><span class="p">)));</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">debugMode</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-505'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-505">¶</a>
|
|
</div>
|
|
<p>stop the SWF from making debug output calls to JS</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">flash</span><span class="p">.</span><span class="nx">_disableDebug</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">enabled</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">debugTS</span><span class="p">(</span><span class="s1">'jstoflash'</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-506'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-506">¶</a>
|
|
</div>
|
|
<p>prevent browser from showing cached page state (or rather, restoring “suspended” page state) via back button, because flash may be dead
|
|
http://www.webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">event</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="s1">'unload'</span><span class="p">,</span> <span class="nx">doNothing</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="s1">'js/flash exception: '</span> <span class="o">+</span> <span class="nx">e</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
|
|
<span class="nx">debugTS</span><span class="p">(</span><span class="s1">'jstoflash'</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span>
|
|
<span class="nx">catchError</span><span class="p">({</span><span class="nx">type</span><span class="o">:</span><span class="s1">'JS_TO_FLASH_EXCEPTION'</span><span class="p">,</span> <span class="nx">fatal</span><span class="o">:</span><span class="kc">true</span><span class="p">});</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-507'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-507">¶</a>
|
|
</div>
|
|
<p>don’t disable, for reboot()</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">failSafely</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
|
|
<span class="nx">initComplete</span><span class="p">();</span>
|
|
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">initComplete</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-508'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-508">¶</a>
|
|
</div>
|
|
<p>disconnect events</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">cleanup</span><span class="p">();</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">domContentLoaded</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">didDCLoaded</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">didDCLoaded</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-509'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-509">¶</a>
|
|
</div>
|
|
<p>assign top-level soundManager properties eg. soundManager.url</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">setProperties</span><span class="p">();</span>
|
|
|
|
<span class="nx">initDebug</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-510'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-510">¶</a>
|
|
</div>
|
|
<p>Temporary feature: allow force of HTML5 via URL params: sm2-usehtml5audio=0 or 1
|
|
Ditto for sm2-preferFlash, too.
|
|
<d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="p">(</span><span class="kd">function</span><span class="p">(){</span>
|
|
|
|
<span class="kd">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="s1">'sm2-usehtml5audio='</span><span class="p">,</span>
|
|
<span class="nx">a2</span> <span class="o">=</span> <span class="s1">'sm2-preferflash='</span><span class="p">,</span>
|
|
<span class="nx">b</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span>
|
|
<span class="nx">b2</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span>
|
|
<span class="nx">hasCon</span> <span class="o">=</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">console</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&&</span> <span class="k">typeof</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="o">===</span> <span class="s1">'function'</span><span class="p">),</span>
|
|
<span class="nx">l</span> <span class="o">=</span> <span class="nx">wl</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">();</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">l</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">a</span><span class="p">)</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">b</span> <span class="o">=</span> <span class="p">(</span><span class="nx">l</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="nx">l</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">a</span><span class="p">)</span><span class="o">+</span><span class="nx">a</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="o">===</span> <span class="s1">'1'</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">hasCon</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">((</span><span class="nx">b</span><span class="o">?</span><span class="s1">'Enabling '</span><span class="o">:</span><span class="s1">'Disabling '</span><span class="p">)</span><span class="o">+</span><span class="s1">'useHTML5Audio via URL parameter'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">setup</span><span class="p">({</span>
|
|
<span class="s1">'useHTML5Audio'</span><span class="o">:</span> <span class="nx">b</span>
|
|
<span class="p">});</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">l</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">a2</span><span class="p">)</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">b2</span> <span class="o">=</span> <span class="p">(</span><span class="nx">l</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="nx">l</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">a2</span><span class="p">)</span><span class="o">+</span><span class="nx">a2</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="o">===</span> <span class="s1">'1'</span><span class="p">);</span>
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">hasCon</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">((</span><span class="nx">b2</span><span class="o">?</span><span class="s1">'Enabling '</span><span class="o">:</span><span class="s1">'Disabling '</span><span class="p">)</span><span class="o">+</span><span class="s1">'preferFlash via URL parameter'</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">setup</span><span class="p">({</span>
|
|
<span class="s1">'preferFlash'</span><span class="o">:</span> <span class="nx">b2</span>
|
|
<span class="p">});</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}());</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-511'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-511">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">hasFlash</span> <span class="o">&&</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">hasHTML5</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">_wD</span><span class="p">(</span><span class="s1">'SoundManager: No Flash detected'</span> <span class="o">+</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">useHTML5Audio</span> <span class="o">?</span> <span class="s1">', enabling HTML5.'</span> <span class="o">:</span> <span class="s1">'. Trying HTML5-only mode.'</span><span class="p">),</span> <span class="mi">1</span><span class="p">);</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">setup</span><span class="p">({</span>
|
|
<span class="s1">'useHTML5Audio'</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-512'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-512">¶</a>
|
|
</div>
|
|
<p>make sure we aren’t preferring flash, either
|
|
TODO: preferFlash should not matter if flash is not installed. Currently, stuff breaks without the below tweak.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="s1">'preferFlash'</span><span class="o">:</span> <span class="kc">false</span>
|
|
<span class="p">});</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">testHTML5</span><span class="p">();</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">.</span><span class="nx">usingFlash</span> <span class="o">=</span> <span class="nx">featureCheck</span><span class="p">();</span>
|
|
<span class="nx">needsFlash</span> <span class="o">=</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">html5</span><span class="p">.</span><span class="nx">usingFlash</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">hasFlash</span> <span class="o">&&</span> <span class="nx">needsFlash</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">messages</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">strings</span><span class="p">.</span><span class="nx">needFlash</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-513'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-513">¶</a>
|
|
</div>
|
|
<p>TODO: Fatal here vs. timeout approach, etc.
|
|
hack: fail sooner.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">setup</span><span class="p">({</span>
|
|
<span class="s1">'flashLoadTimeout'</span><span class="o">:</span> <span class="mi">1</span>
|
|
<span class="p">});</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">doc</span><span class="p">.</span><span class="nx">removeEventListener</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">doc</span><span class="p">.</span><span class="nx">removeEventListener</span><span class="p">(</span><span class="s1">'DOMContentLoaded'</span><span class="p">,</span> <span class="nx">domContentLoaded</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nx">initMovie</span><span class="p">();</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">domContentLoadedIE</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">doc</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">===</span> <span class="s1">'complete'</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">domContentLoaded</span><span class="p">();</span>
|
|
<span class="nx">doc</span><span class="p">.</span><span class="nx">detachEvent</span><span class="p">(</span><span class="s1">'onreadystatechange'</span><span class="p">,</span> <span class="nx">domContentLoadedIE</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">winOnLoad</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-514'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-514">¶</a>
|
|
</div>
|
|
<p>catch edge case of initComplete() firing after window.load()</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">windowLoaded</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">event</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="s1">'load'</span><span class="p">,</span> <span class="nx">winOnLoad</span><span class="p">);</span>
|
|
|
|
<span class="p">};</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-515'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-515">¶</a>
|
|
</div>
|
|
<p>miscellaneous run-time, pre-init stuff</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">preInit</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">mobileHTML5</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-516'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-516">¶</a>
|
|
</div>
|
|
<p>prefer HTML5 for mobile + tablet-like devices, probably more reliable vs. flash at this point.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-517'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-517">¶</a>
|
|
</div>
|
|
<p><d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">setupOptions</span><span class="p">.</span><span class="nx">useHTML5Audio</span> <span class="o">||</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">setupOptions</span><span class="p">.</span><span class="nx">preferFlash</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-518'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-518">¶</a>
|
|
</div>
|
|
<p>notify that defaults are being changed.</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">messages</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">strings</span><span class="p">.</span><span class="nx">mobileUA</span><span class="p">);</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-519'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-519">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">sm2</span><span class="p">.</span><span class="nx">setupOptions</span><span class="p">.</span><span class="nx">useHTML5Audio</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">setupOptions</span><span class="p">.</span><span class="nx">preferFlash</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">is_iDevice</span> <span class="o">||</span> <span class="p">(</span><span class="nx">isAndroid</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">ua</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/android\s2\.3/i</span><span class="p">)))</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-520'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-520">¶</a>
|
|
</div>
|
|
<p>iOS and Android devices tend to work better with a single audio instance, specifically for chained playback of sounds in sequence.
|
|
common use case: exiting sound onfinish() –> createSound() –> play()
|
|
<d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">messages</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">strings</span><span class="p">.</span><span class="nx">globalHTML5</span><span class="p">);</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-521'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-521">¶</a>
|
|
</div>
|
|
<p></d></p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">is_iDevice</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">sm2</span><span class="p">.</span><span class="nx">ignoreFlash</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="nx">useGlobalHTML5Audio</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">};</span>
|
|
|
|
<span class="nx">preInit</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-522'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-522">¶</a>
|
|
</div>
|
|
<p>sniff up-front</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">detectFlash</span><span class="p">();</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-523'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-523">¶</a>
|
|
</div>
|
|
<p>focus and window load, init (primarily flash-driven)</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">event</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="s1">'focus'</span><span class="p">,</span> <span class="nx">handleFocus</span><span class="p">);</span>
|
|
<span class="nx">event</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="s1">'load'</span><span class="p">,</span> <span class="nx">delayWaitForEI</span><span class="p">);</span>
|
|
<span class="nx">event</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="s1">'load'</span><span class="p">,</span> <span class="nx">winOnLoad</span><span class="p">);</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="nx">doc</span><span class="p">.</span><span class="nx">addEventListener</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">doc</span><span class="p">.</span><span class="nx">addEventListener</span><span class="p">(</span><span class="s1">'DOMContentLoaded'</span><span class="p">,</span> <span class="nx">domContentLoaded</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">doc</span><span class="p">.</span><span class="nx">attachEvent</span><span class="p">)</span> <span class="p">{</span>
|
|
|
|
<span class="nx">doc</span><span class="p">.</span><span class="nx">attachEvent</span><span class="p">(</span><span class="s1">'onreadystatechange'</span><span class="p">,</span> <span class="nx">domContentLoadedIE</span><span class="p">);</span>
|
|
|
|
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-524'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-524">¶</a>
|
|
</div>
|
|
<p>no add/attachevent support – safe to assume no JS –> Flash either</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre> <span class="nx">debugTS</span><span class="p">(</span><span class="s1">'onload'</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span>
|
|
<span class="nx">catchError</span><span class="p">({</span><span class="nx">type</span><span class="o">:</span><span class="s1">'NO_DOM2_EVENTS'</span><span class="p">,</span> <span class="nx">fatal</span><span class="o">:</span><span class="kc">true</span><span class="p">});</span>
|
|
|
|
<span class="p">}</span>
|
|
|
|
<span class="p">}</span> <span class="c1">// SoundManager()</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-525'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-525">¶</a>
|
|
</div>
|
|
<p>SM2_DEFER details: http://www.schillmania.com/projects/soundmanager2/doc/getstarted/#lazy-loading</p>
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre><span class="k">if</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">SM2_DEFER</span> <span class="o">===</span> <span class="kc">undefined</span> <span class="o">||</span> <span class="o">!</span><span class="nx">SM2_DEFER</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="nx">soundManager</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">SoundManager</span><span class="p">();</span>
|
|
<span class="p">}</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
<tr id='section-SoundManager_public_interfaces'>
|
|
<td class=docs>
|
|
<div class="pilwrap">
|
|
<a class="pilcrow" href="#section-SoundManager_public_interfaces">¶</a>
|
|
</div>
|
|
<h2>SoundManager public interfaces</h2>
|
|
|
|
</td>
|
|
<td class=code>
|
|
<div class='highlight'><pre><span class="nb">window</span><span class="p">.</span><span class="nx">SoundManager</span> <span class="o">=</span> <span class="nx">SoundManager</span><span class="p">;</span> <span class="c1">// constructor</span>
|
|
<span class="nb">window</span><span class="p">.</span><span class="nx">soundManager</span> <span class="o">=</span> <span class="nx">soundManager</span><span class="p">;</span> <span class="c1">// public API, flash callbacks etc.</span>
|
|
|
|
<span class="p">}(</span><span class="nb">window</span><span class="p">));</span></pre></div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</body>
|