soundmap_theme/carnaval/soundmanagerv297a-20130101/doc/generated/script/soundmanager2.html
2016-11-29 01:18:17 +01:00

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 &hellip;
<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">&#182;</a>
</div>
<p>@license</p>
<h2>SoundManager 2: JavaScript Sound for the Web</h2>
<p>http://schillmania.com/projects/soundmanager2/</p>
<p>Copyright &copy; 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">&#182;</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">&quot;use strict&quot;</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">&#182;</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">&#182;</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 &ndash; eg., soundManager.setup({url: &lsquo;/swf/&rsquo;, 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">&#39;url&#39;</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">&#39;flashVersion&#39;</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">&#39;debugMode&#39;</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">&#39;debugFlash&#39;</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">&#39;useConsole&#39;</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">&#39;consoleOnly&#39;</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">&#39;waitForWindowLoad&#39;</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">&#39;bgColor&#39;</span><span class="o">:</span> <span class="s1">&#39;#ffffff&#39;</span><span class="p">,</span> <span class="c1">// SWF background color. N/A when wmode = &#39;transparent&#39;</span>
<span class="s1">&#39;useHighPerformance&#39;</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">&#39;flashPollingInterval&#39;</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">&#39;html5PollingInterval&#39;</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">&#39;flashLoadTimeout&#39;</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">&#39;wmode&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// flash rendering mode - null, &#39;transparent&#39;, or &#39;opaque&#39; (last two allow z-index to work)</span>
<span class="s1">&#39;allowScriptAccess&#39;</span><span class="o">:</span> <span class="s1">&#39;always&#39;</span><span class="p">,</span> <span class="c1">// for scripting the SWF (object/embed property), &#39;always&#39; or &#39;sameDomain&#39;</span>
<span class="s1">&#39;useFlashBlock&#39;</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">&#39;useHTML5Audio&#39;</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">&#39;html5Test&#39;</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">&#39;preferFlash&#39;</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">&#39;noSWFCache&#39;</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">&#182;</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">&#39;autoLoad&#39;</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">&#39;autoPlay&#39;</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 &quot;stream&quot; is true)</span>
<span class="s1">&#39;from&#39;</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">&#39;loops&#39;</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 &gt;0)</span>
<span class="s1">&#39;onid3&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback function for &quot;ID3 data is added/available&quot;</span>
<span class="s1">&#39;onload&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback function for &quot;load finished&quot;</span>
<span class="s1">&#39;whileloading&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback function for &quot;download progress update&quot; (X of Y bytes received)</span>
<span class="s1">&#39;onplay&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback for &quot;play&quot; start</span>
<span class="s1">&#39;onpause&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback for &quot;pause&quot;</span>
<span class="s1">&#39;onresume&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback for &quot;resume&quot; (pause toggle)</span>
<span class="s1">&#39;whileplaying&#39;</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">&#39;onposition&#39;</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">&#39;onstop&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback for &quot;user stop&quot;</span>
<span class="s1">&#39;onfailure&#39;</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">&#39;onfinish&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback function for &quot;sound finished playing&quot;</span>
<span class="s1">&#39;multiShot&#39;</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="c1">// let sounds &quot;restart&quot; or layer on top of each other when played multiple times, rather than one-shot/one at a time</span>
<span class="s1">&#39;multiShotEvents&#39;</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">&#39;position&#39;</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">&#39;pan&#39;</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// &quot;pan&quot; settings, left-to-right, -100 to 100</span>
<span class="s1">&#39;stream&#39;</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">&#39;to&#39;</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">&#39;type&#39;</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">&#39;usePolicyFile&#39;</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">&#39;volume&#39;</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">&#182;</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">&#39;isMovieStar&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// &quot;MovieStar&quot; MPEG4 audio mode. Null (default) = auto detect MP4, AAC etc. based on URL. true = force on, ignore URL</span>
<span class="s1">&#39;usePeakData&#39;</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">&#39;useWaveformData&#39;</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">&#39;useEQData&#39;</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">&#39;onbufferchange&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// callback for &quot;isBuffering&quot; property change</span>
<span class="s1">&#39;ondataerror&#39;</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">&#182;</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">&#39;bufferTime&#39;</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">&#39;serverURL&#39;</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">&#39;onconnect&#39;</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">&#39;duration&#39;</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">&#182;</a>
</div>
<p>determines HTML5 support + flash requirements.
if no support (via flash and/or HTML5) for a &ldquo;required&rdquo; format, SM2 will fail to start.
flash fallback is used for MP3 or MP4 if HTML5 can&rsquo;t play it (or if preferFlash = true)</p>
</td>
<td class=code>
<div class='highlight'><pre> <span class="s1">&#39;mp3&#39;</span><span class="o">:</span> <span class="p">{</span>
<span class="s1">&#39;type&#39;</span><span class="o">:</span> <span class="p">[</span><span class="s1">&#39;audio/mpeg; codecs=&quot;mp3&quot;&#39;</span><span class="p">,</span> <span class="s1">&#39;audio/mpeg&#39;</span><span class="p">,</span> <span class="s1">&#39;audio/mp3&#39;</span><span class="p">,</span> <span class="s1">&#39;audio/MPA&#39;</span><span class="p">,</span> <span class="s1">&#39;audio/mpa-robust&#39;</span><span class="p">],</span>
<span class="s1">&#39;required&#39;</span><span class="o">:</span> <span class="kc">true</span>
<span class="p">},</span>
<span class="s1">&#39;mp4&#39;</span><span class="o">:</span> <span class="p">{</span>
<span class="s1">&#39;related&#39;</span><span class="o">:</span> <span class="p">[</span><span class="s1">&#39;aac&#39;</span><span class="p">,</span><span class="s1">&#39;m4a&#39;</span><span class="p">,</span><span class="s1">&#39;m4b&#39;</span><span class="p">],</span> <span class="c1">// additional formats under the MP4 container</span>
<span class="s1">&#39;type&#39;</span><span class="o">:</span> <span class="p">[</span><span class="s1">&#39;audio/mp4; codecs=&quot;mp4a.40.2&quot;&#39;</span><span class="p">,</span> <span class="s1">&#39;audio/aac&#39;</span><span class="p">,</span> <span class="s1">&#39;audio/x-m4a&#39;</span><span class="p">,</span> <span class="s1">&#39;audio/MP4A-LATM&#39;</span><span class="p">,</span> <span class="s1">&#39;audio/mpeg4-generic&#39;</span><span class="p">],</span>
<span class="s1">&#39;required&#39;</span><span class="o">:</span> <span class="kc">false</span>
<span class="p">},</span>
<span class="s1">&#39;ogg&#39;</span><span class="o">:</span> <span class="p">{</span>
<span class="s1">&#39;type&#39;</span><span class="o">:</span> <span class="p">[</span><span class="s1">&#39;audio/ogg; codecs=vorbis&#39;</span><span class="p">],</span>
<span class="s1">&#39;required&#39;</span><span class="o">:</span> <span class="kc">false</span>
<span class="p">},</span>
<span class="s1">&#39;wav&#39;</span><span class="o">:</span> <span class="p">{</span>
<span class="s1">&#39;type&#39;</span><span class="o">:</span> <span class="p">[</span><span class="s1">&#39;audio/wav; codecs=&quot;1&quot;&#39;</span><span class="p">,</span> <span class="s1">&#39;audio/wav&#39;</span><span class="p">,</span> <span class="s1">&#39;audio/wave&#39;</span><span class="p">,</span> <span class="s1">&#39;audio/x-wav&#39;</span><span class="p">],</span>
<span class="s1">&#39;required&#39;</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">&#182;</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">&#39;sm2-container&#39;</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">&#39;sm2movie&#39;</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">&#39;soundmanager-debug&#39;</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">/([#?&amp;])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">&#182;</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">&#39;V2.97a.20130101&#39;</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">&#39;flash8&#39;</span><span class="o">:</span> <span class="sr">/\.mp3(\?.*)?$/i</span><span class="p">,</span>
<span class="s1">&#39;flash9&#39;</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">&#182;</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">&#39;buffering&#39;</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="s1">&#39;peakData&#39;</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="s1">&#39;waveformData&#39;</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="s1">&#39;eqData&#39;</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="s1">&#39;movieStar&#39;</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">&#182;</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">&#182;</a>
</div>
<p><d></p>
</td>
<td class=code>
<div class='highlight'><pre> <span class="s1">&#39;type&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="s1">&#39;types&#39;</span><span class="o">:</span> <span class="p">{</span>
<span class="s1">&#39;remote&#39;</span><span class="o">:</span> <span class="s1">&#39;remote (domain-based) rules&#39;</span><span class="p">,</span>
<span class="s1">&#39;localWithFile&#39;</span><span class="o">:</span> <span class="s1">&#39;local with file access (no internet access)&#39;</span><span class="p">,</span>
<span class="s1">&#39;localWithNetwork&#39;</span><span class="o">:</span> <span class="s1">&#39;local with network (internet access only, no local access)&#39;</span><span class="p">,</span>
<span class="s1">&#39;localTrusted&#39;</span><span class="o">:</span> <span class="s1">&#39;local, trusted (local+internet access)&#39;</span>
<span class="p">},</span>
<span class="s1">&#39;description&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="s1">&#39;noRemote&#39;</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="s1">&#39;noLocal&#39;</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">&#182;</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">&#182;</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">&#39;usingFlash&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;soundManager&#39;</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">&#39;: &#39;</span><span class="p">,</span> <span class="nx">h5</span> <span class="o">=</span> <span class="s1">&#39;HTML5::&#39;</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">&#39;log&#39;</span><span class="p">,</span> <span class="s1">&#39;info&#39;</span><span class="p">,</span> <span class="s1">&#39;warn&#39;</span><span class="p">,</span> <span class="s1">&#39;error&#39;</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">&amp;&amp;</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">&amp;&amp;</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">&amp;&amp;</span> <span class="nx">isSafari</span> <span class="o">&amp;&amp;</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">&amp;&amp;</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, &quot;Silk&quot;) 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">&amp;&amp;</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">&amp;&amp;</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">&#39;about:blank&#39;</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">&#39;http:/&#39;</span><span class="o">+</span><span class="s1">&#39;/&#39;</span> <span class="o">:</span> <span class="s1">&#39;&#39;</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">&#182;</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">&#182;</a>
</div>
<p>Flash v9.0r115+ &ldquo;moviestar&rdquo; 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">&#39;mpeg4&#39;</span><span class="p">,</span> <span class="s1">&#39;aac&#39;</span><span class="p">,</span> <span class="s1">&#39;flv&#39;</span><span class="p">,</span> <span class="s1">&#39;mov&#39;</span><span class="p">,</span> <span class="s1">&#39;mp4&#39;</span><span class="p">,</span> <span class="s1">&#39;m4v&#39;</span><span class="p">,</span> <span class="s1">&#39;f4v&#39;</span><span class="p">,</span> <span class="s1">&#39;m4a&#39;</span><span class="p">,</span> <span class="s1">&#39;m4b&#39;</span><span class="p">,</span> <span class="s1">&#39;mp4v&#39;</span><span class="p">,</span> <span class="s1">&#39;3gp&#39;</span><span class="p">,</span> <span class="s1">&#39;3g2&#39;</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">&#39;\\.(&#39;</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">&#39;|&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;)(\\?.*)?$&#39;</span><span class="p">,</span> <span class="s1">&#39;i&#39;</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">&#182;</a>
</div>
<p>use altURL if not &ldquo;online&rdquo;</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">&#39;swfBox&#39;</span><span class="o">:</span> <span class="s1">&#39;sm2-object-box&#39;</span><span class="p">,</span>
<span class="s1">&#39;swfDefault&#39;</span><span class="o">:</span> <span class="s1">&#39;movieContainer&#39;</span><span class="p">,</span>
<span class="s1">&#39;swfError&#39;</span><span class="o">:</span> <span class="s1">&#39;swf_error&#39;</span><span class="p">,</span> <span class="c1">// SWF loaded, but SM2 couldn&#39;t start (other error)</span>
<span class="s1">&#39;swfTimedout&#39;</span><span class="o">:</span> <span class="s1">&#39;swf_timedout&#39;</span><span class="p">,</span>
<span class="s1">&#39;swfLoaded&#39;</span><span class="o">:</span> <span class="s1">&#39;swf_loaded&#39;</span><span class="p">,</span>
<span class="s1">&#39;swfUnblocked&#39;</span><span class="o">:</span> <span class="s1">&#39;swf_unblocked&#39;</span><span class="p">,</span> <span class="c1">// or loaded OK</span>
<span class="s1">&#39;sm2Debug&#39;</span><span class="o">:</span> <span class="s1">&#39;sm2_debug&#39;</span><span class="p">,</span>
<span class="s1">&#39;highPerf&#39;</span><span class="o">:</span> <span class="s1">&#39;high_performance&#39;</span><span class="p">,</span>
<span class="s1">&#39;flashDebug&#39;</span><span class="o">:</span> <span class="s1">&#39;flash_debug&#39;</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">&#182;</a>
</div>
<p>basic HTML5 Audio() support test
try&hellip;catch because of IE 9 &ldquo;not implemented&rdquo; 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">&#182;</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">&amp;&amp;</span> <span class="p">(</span><span class="nx">isOpera</span> <span class="o">&amp;&amp;</span> <span class="nx">opera</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&amp;&amp;</span> <span class="nx">opera</span><span class="p">.</span><span class="nx">version</span><span class="p">()</span> <span class="o">&lt;</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">&#182;</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">&#182;</a>
</div>
<p>Configures top-level soundManager properties.</p>
<p>@param {object} options Option parameters, eg. { flashVersion: 9, url: &lsquo;/path/to/swfs/&rsquo; }
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">&#182;</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">&amp;&amp;</span> <span class="nx">didInit</span> <span class="o">&amp;&amp;</span> <span class="nx">needsFlash</span> <span class="o">&amp;&amp;</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">ok</span><span class="p">()</span> <span class="o">&amp;&amp;</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">&#39;setupLate&#39;</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">&#182;</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">&#182;</a>
</div>
<p>special case 1: &ldquo;Late setup&rdquo;. SM2 loaded normally, but user didn&rsquo;t assign flash URL eg., setup({url:&hellip;}) 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">&amp;&amp;</span> <span class="nx">didDCLoaded</span> <span class="o">&amp;&amp;</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">&#182;</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">&amp;&amp;</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">&amp;&amp;</span> <span class="nx">doc</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">===</span> <span class="s1">&#39;complete&#39;</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">&amp;&amp;</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">&amp;&amp;</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">&#182;</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">&#182;</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">&#182;</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">&#39;.createSound(): &#39;</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">&#39;notReady&#39;</span><span class="o">:</span><span class="s1">&#39;notOK&#39;</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">&#182;</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">&#182;</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">&#39;id&#39;</span><span class="o">:</span> <span class="nx">oOptions</span><span class="p">,</span>
<span class="s1">&#39;url&#39;</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">&#182;</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">&#182;</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">&#39;badID&#39;</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">&#39; (&#39;</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">&#39;)&#39;</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">&#182;</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">&#39; exists&#39;</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">&#39;: Using HTML5&#39;</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">&gt;</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">&#182;</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">&#182;</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">&#39;using MovieStar handling&#39;</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">&gt;</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">&#39;noNSLoop&#39;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&#182;</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">&#182;</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">&lt;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;.play(): &#39;</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">&#39;notReady&#39;</span><span class="o">:</span><span class="s1">&#39;notOK&#39;</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">&#182;</a>
</div>
<p>overloading use case: play(&lsquo;mySound&rsquo;,&lsquo;/path/to/some.mp3&rsquo;);</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">&amp;&amp;</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">&#182;</a>
</div>
<p>overloading use case, create+play: .play(&lsquo;someID&rsquo;,{url:&lsquo;/path/to.mp3&rsquo;});</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">&#39;.play(): attempting to create &quot;&#39;</span> <span class="o">+</span> <span class="nx">sID</span> <span class="o">+</span> <span class="s1">&#39;&quot;&#39;</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">&#182;</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">&#182;</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">&#39;.stop(&#39;</span> <span class="o">+</span> <span class="nx">sID</span> <span class="o">+</span> <span class="s1">&#39;)&#39;</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">&#182;</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">&#39;.stopAll()&#39;</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">&#182;</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">&#182;</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">&#182;</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">&gt;=</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">&#182;</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">&#182;</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">&gt;=</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;.mute(): Muting all sounds&#39;</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">&gt;=</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">&#39;.mute(): Muting &quot;&#39;</span> <span class="o">+</span> <span class="nx">sID</span> <span class="o">+</span> <span class="s1">&#39;&quot;&#39;</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">&#182;</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">&#182;</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">&#39;.unmute(): Unmuting all sounds&#39;</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">&gt;=</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">&#39;.unmute(): Unmuting &quot;&#39;</span> <span class="o">+</span> <span class="nx">sID</span> <span class="o">+</span> <span class="s1">&#39;&quot;&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&#182;</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">&#39;shutdown&#39;</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">&gt;=</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">&#182;</a>
</div>
<p>fire &ldquo;complete&rdquo;, 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">&#39;load&#39;</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">&#182;</a>
</div>
<p>Determines playability of a MIME type, eg. &lsquo;audio/mp3&rsquo;.</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">&amp;&amp;</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">&#182;</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">&amp;&amp;</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">&gt;</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">&#182;</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">&amp;&amp;</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">&amp;&amp;</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">&#182;</a>
</div>
<p>Determines playability of an HTML DOM &lt;a&gt; object (or similar object literal) based on audio support.</p>
<p>@param {object} oLink an HTML DOM &lt;a&gt; 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">&amp;&amp;</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">&#182;</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">&#39;.getSoundById(): sID is null/_undefined&#39;</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">&#182;</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">&amp;&amp;</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">&#39;&quot;&#39;</span> <span class="o">+</span> <span class="nx">sID</span> <span class="o">+</span> <span class="s1">&#39;&quot; is an invalid sound ID.&#39;</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">&#182;</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">&#182;</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">&#39;onready&#39;</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">&#39;function&#39;</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">&#182;</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">&#39;queue&#39;</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">&#182;</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">&#39;needFunction&#39;</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">&#182;</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">&#39;ontimeout&#39;</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">&#39;function&#39;</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">&#182;</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">&#39;queue&#39;</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">&#182;</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">&#39;needFunction&#39;</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">&#182;</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 &lsquo;info&rsquo;, &lsquo;warn&rsquo; or &lsquo;error&rsquo;, 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">&#182;</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">&#39;soundmanager-debug&#39;</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">&amp;&amp;</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">&amp;&amp;</span> <span class="k">typeof</span> <span class="nx">sType</span> <span class="o">===</span> <span class="s1">&#39;object&#39;</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">&#182;</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">&#39;div&#39;</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">&#39;sm2-alt&#39;</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">&gt;=</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">&#39;bold&#39;</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">&#39;#ff3333&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;sm2-debug=alert&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;currentObj&#39;</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">&lt;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;Destroying &#39;</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">&#39; SMSound objects...&#39;</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">&#182;</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">&gt;=</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">&#182;</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">&#39;flRemoved&#39;</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">&#182;</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">&#39;badRemove&#39;</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">&#182;</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">&#182;</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">&lt;</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">&#182;</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">&#182;</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">&#39;: Rebooting...&#39;</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">&#182;</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">&#182;</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">&#39;usingFlash&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#39;reset&#39;</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">&#182;</a>
</div>
<p>Undocumented: Determines the SM2 flash movie&rsquo;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">&#182;</a>
</div>
<p>Interesting syntax notes&hellip;
Flash/ExternalInterface (ActiveX/NPAPI) bridge methods are not typeof &ldquo;function&rdquo; nor instanceof Function, but are still valid.
Additionally, JSLint dislikes (&lsquo;PercentLoaded&rsquo; in flash)-style syntax and recommends hasOwnProperty(), which does not work in this case.
Furthermore, using (flash &amp;&amp; flash.PercentLoaded) causes IE to throw &ldquo;object doesn&rsquo;t support this property or method&rdquo;.
Thus, &lsquo;in&rsquo; 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">&amp;&amp;</span> <span class="s1">&#39;PercentLoaded&#39;</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">&#182;</a>
</div>
<p>Additional helper for manually invoking SM2&rsquo;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">&#182;</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">&#39;.destruct()&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;: Merged options:&#39;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#39;manURL&#39;</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">&#182;</a>
</div>
<p>ensure we&rsquo;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">&#182;</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">&#39;: load (&#39;</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">&#39;)&#39;</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">&amp;&amp;</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">&amp;&amp;</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">&#39;onURL&#39;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>TODO: If switching from HTML5 &ndash;&gt; 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">&#182;</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">&#182;</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">&#39;manURL&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;: &#39;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;auto&#39;</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">&#182;</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">&#39;auto&#39;</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">&#39;: Ignoring request to load again&#39;</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">&#182;</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">&#39;smError&#39;</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">&#39;onload&#39;</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">&#39;SMSOUND_LOAD_JS_EXCEPTION&#39;</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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>Flash 8/AS2 can&rsquo;t &ldquo;close&rdquo; a stream &ndash; 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">&#39;: unload()&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#39;: Destruct&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;: play(): &#39;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#39; Netstream not connected yet - setting autoPlay&#39;</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">&#182;</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">&amp;&amp;</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">&#39;Already playing (one-shot)&#39;</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">&#39;Already playing (multi-shot)&#39;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&#39;Attempting to load&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>HTML5 hack &ndash; 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">&#39;Could not load - exiting&#39;</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">&#39;Loading - attempting to play...&#39;</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">&amp;&amp;</span> <span class="nx">fV</span> <span class="o">===</span> <span class="mi">9</span> <span class="o">&amp;&amp;</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="o">&amp;&amp;</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">&#182;</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">&#39;Sound at end, resetting to position:0&#39;</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">&#182;</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&rsquo;t started playing yet.
If we just call resume() the onplay() callback will never be called.
So only call resume() if the position is &gt; 0.
Another reason is because options like volume won&rsquo;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">&amp;&amp;</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">&gt;=</span> <span class="mi">0</span> <span class="o">&amp;&amp;</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">&gt;</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">&#182;</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">&#39;Resuming from paused state&#39;</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">&#182;</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">&amp;&amp;</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">&amp;&amp;</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">&amp;&amp;</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">&amp;&amp;</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">&#182;</a>
</div>
<p>sound &ldquo;canplay&rdquo; 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">&#182;</a>
</div>
<p>HTML5 needs to at least have &ldquo;canplay&rdquo; 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">&amp;&amp;</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">&#182;</a>
</div>
<p>this hasn&rsquo;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">&#39;Beginning load for from/to case&#39;</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">&#182;</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">&amp;&amp;</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">loaded</span> <span class="o">&amp;&amp;</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">&#182;</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">&#39;Preloading for from/to case&#39;</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">&#182;</a>
</div>
<p>otherwise, we&rsquo;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">&#39;Starting to play&#39;</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">&amp;&amp;</span> <span class="nx">fV</span> <span class="o">&gt;</span> <span class="mi">8</span> <span class="o">&amp;&amp;</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">&#182;</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">&amp;&amp;</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">&amp;&amp;</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">&amp;&amp;</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">&amp;&amp;</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">&#182;</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">&#39;No sound hardware, or 32-sound ceiling hit&#39;</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">&#182;</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">&#182;</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">&#39;: stop()&#39;</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">&#182;</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">&#182;</a>
</div>
<p>and &ldquo;to&rdquo; 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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;: Autoplay turned &#39;</span> <span class="o">+</span> <span class="p">(</span><span class="nx">autoPlay</span> <span class="o">?</span> <span class="s1">&#39;on&#39;</span> <span class="o">:</span> <span class="s1">&#39;off&#39;</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">&#182;</a>
</div>
<p>only increment the instanceCount if the sound isn&rsquo;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">&amp;&amp;</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">&#39;: Incremented instance count to &#39;</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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>Use the duration from the instance options, if we don&rsquo;t have a track duration yet.
position &gt;= 0 and &lt;= 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">&amp;&amp;</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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>DOM/JS errors/exceptions to watch out for:
if seek is beyond (loaded?) position, &ldquo;DOM exception 11&rdquo;
&ldquo;INDEX<em>SIZE</em>ERR&rdquo;: 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">&#39;: setPosition(&#39;</span><span class="o">+</span><span class="nx">position1K</span><span class="o">+</span><span class="s1">&#39;)&#39;</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">&#182;</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">&#39;: setPosition(&#39;</span> <span class="o">+</span> <span class="nx">position1K</span> <span class="o">+</span> <span class="s1">&#39;) failed: &#39;</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">&#39;: setPosition(&#39;</span> <span class="o">+</span> <span class="nx">position1K</span> <span class="o">+</span> <span class="s1">&#39;): Cannot seek yet, sound not ready&#39;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#39;: pause()&#39;</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">&#182;</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">&#182;</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 &ldquo;resume&rdquo;.
When a paused stream is resumed, we need to trigger the onplay() callback if it
hasn&rsquo;t been called already. In this case since the sound is being played for the
first time, I think it&rsquo;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">&#39;: resume()&#39;</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">&amp;&amp;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&#39;: togglePause()&#39;</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">&amp;&amp;</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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>Note: Setting volume has no effect on iOS &ldquo;special snowflake&rdquo; 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">&amp;&amp;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&lt;</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">&#182;</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">&#182;</a>
</div>
<p>decrement &ldquo;fired&rdquo; 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">&gt;=</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">&gt;=</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">&amp;&amp;</span> <span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">&gt;=</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">&#182;</a>
</div>
<p>reset &ldquo;fired&rdquo; 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">&gt;=</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">&amp;&amp;</span> <span class="nx">nPosition</span> <span class="o">&lt;=</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">&#182;</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">&#182;</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">&#39;: &quot;To&quot; time of &#39;</span> <span class="o">+</span> <span class="nx">t</span> <span class="o">+</span> <span class="s1">&#39; reached.&#39;</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">&#182;</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">&#182;</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">&#39;: Playing &quot;from&quot; &#39;</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">&#182;</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">&amp;&amp;</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">&amp;&amp;</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">&#182;</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">&#182;</a>
</div>
<p>multiShot timing can&rsquo;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">&#182;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&gt;</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">&amp;&amp;</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">&#182;</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">&#182;</a>
</div>
<p>sm2.<em>wD(&lsquo;</em>onTimer: Warn for &ldquo;&rsquo;+s.id+&lsquo;&rdquo;: &rsquo;+(!s._a?&lsquo;Could not find element. &rsquo;:&ldquo;)+(s.playState === 0?&lsquo;playState bad, 0?&rsquo;:&lsquo;playState = &rsquo;+s.playState+&lsquo;, OK&rsquo;));</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">&#182;</a>
</div>
<p>if audio object exists, use its duration &ndash; else, instance option duration (if provided &ndash; it&rsquo;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">&amp;&amp;</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">&amp;&amp;</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">&amp;&amp;</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">&amp;&amp;</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">&#182;</a>
</div>
<p>boolean instead of &quot;loop&rdquo;, for webkit? &ndash; 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">&#182;</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">&amp;&amp;</span> <span class="nx">nLoops</span> <span class="o">&gt;</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">&#39;Note: Native HTML5 looping is infinite.&#39;</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">&#182;</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">&gt;</span> <span class="mi">1</span> <span class="o">?</span> <span class="s1">&#39;loop&#39;</span> <span class="o">:</span> <span class="s1">&#39;&#39;</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">&#182;</a>
</div>
<p>&ldquo;First things first, I, Poppa&hellip;&rdquo; (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">&#182;</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">&#182;</a>
</div>
<p>options URL is the same as the &ldquo;last&rdquo; 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">&amp;&amp;</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">&amp;&amp;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&#182;</a>
</div>
<p>don&rsquo;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">&#182;</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">&#182;</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">&amp;&amp;</span> <span class="nx">opera</span><span class="p">.</span><span class="nx">version</span><span class="p">()</span> <span class="o">&lt;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>standard (&lsquo;none&rsquo; 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">&#39;auto&#39;</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">&#182;</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">&#39;: Removing event listeners&#39;</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">&#182;</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">&#182;</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">&amp;&amp;</span> <span class="nx">fV</span> <span class="o">===</span> <span class="mi">8</span> <span class="o">&amp;&amp;</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">&#182;</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">&#39;: &#39;</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">&#39;onload()&#39;</span> <span class="o">:</span> <span class="s1">&#39;Failed to load? - &#39;</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">&amp;&amp;</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">&#39;noNet&#39;</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">&#39;noLocal&#39;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&amp;&amp;</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">&#39;: Buffer state change: &#39;</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">&#182;</a>
</div>
<p>Playback may have stopped due to buffering, or related reason.
This state can be encountered on iOS &lt; 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">&#39;: Playback suspended&#39;</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">&#182;</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">&#39;: Failures = &#39;</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">&amp;&amp;</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">&#39;: Ignoring failure&#39;</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">&#182;</a>
</div>
<p>store local copy before it gets trashed&hellip;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;: onfinish()&#39;</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">&amp;&amp;</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">&#182;</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">&gt;</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">&#182;</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">&#39;start&#39;</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="s1">&#39;end&#39;</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">&#182;</a>
</div>
<p>allow whileloading to fire even if &ldquo;load&rdquo; 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">&amp;&amp;</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">&#182;</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">&#182;</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">&amp;&amp;</span> <span class="nx">fV</span> <span class="o">&gt;</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">&amp;&amp;</span> <span class="nx">oPeakData</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&amp;&amp;</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">&amp;&amp;</span> <span class="nx">oWaveformDataLeft</span> <span class="o">!==</span> <span class="nx">_undefined</span> <span class="o">&amp;&amp;</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">&#39;,&#39;</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">&#39;,&#39;</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">&amp;&amp;</span> <span class="nx">oEQData</span> <span class="o">&amp;&amp;</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">&#39;,&#39;</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">&amp;&amp;</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">&#39;,&#39;</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">&#182;</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">&amp;&amp;</span> <span class="nx">fV</span> <span class="o">===</span> <span class="mi">8</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">position</span> <span class="o">&amp;&amp;</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">&#182;</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">&#182;</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">&#39;: Caption data received.&#39;</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">&#182;</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">&#39;: Metadata received.&#39;</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">&lt;</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">&#182;</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">&#39;: ID3 data received.&#39;</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">&lt;</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">&#182;</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">&#39;: &#39;</span> <span class="o">+</span> <span class="p">(</span><span class="nx">bSuccess</span> <span class="o">?</span> <span class="s1">&#39;Connected.&#39;</span> <span class="o">:</span> <span class="s1">&#39;Failed to connect? - &#39;</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">&#182;</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">&#182;</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">&gt;</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">&#39;: Data error: &#39;</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">&#182;</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">&#182;</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">&#182;</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">&#39;div&#39;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#39;object&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#39;onready&#39;</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="s1">&#39;ontimeout&#39;</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="s1">&#39;defaultOptions&#39;</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="s1">&#39;flash9Options&#39;</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="s1">&#39;movieStarOptions&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#39;object&#39;</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">&#39;: {...}&#39;</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">&#39;: function() {...}&#39;</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">&#39;setup&#39;</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">&#39;, &#39;</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">&#182;</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">&#182;</a>
</div>
<p>if not an {object} we want to recurse through&hellip;</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">&#39;object&#39;</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">&#182;</a>
</div>
<p>check &ldquo;allowed&rdquo; 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">&amp;&amp;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;setupUndef&#39;</span> <span class="o">:</span> <span class="s1">&#39;setupError&#39;</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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>recursion case, eg., { defaultOptions: { &hellip; } }</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">&#182;</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">&#39;setupUndef&#39;</span> <span class="o">:</span> <span class="s1">&#39;setupError&#39;</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">&#182;</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">&#182;</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">&amp;&amp;</span> <span class="nx">hasFlash</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">ignoreFlash</span> <span class="o">&amp;&amp;</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">&amp;&amp;</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">&#182;</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">&#182;</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">&#39;attachEvent&#39;</span><span class="o">:</span><span class="s1">&#39;addEventListener&#39;</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">&#39;detachEvent&#39;</span><span class="o">:</span><span class="s1">&#39;removeEventListener&#39;</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">&#182;</a>
</div>
<p>normalize &ldquo;on&rdquo; 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">&#182;</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">&#39;on&#39;</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">&gt;</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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>old IE can&rsquo;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">&#39;add&#39;</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">&#39;remove&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">return</span> <span class="p">{</span>
<span class="s1">&#39;add&#39;</span><span class="o">:</span> <span class="nx">add</span><span class="p">,</span>
<span class="s1">&#39;remove&#39;</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">&#182;</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">&#182;</a>
</div>
<p>wrap html5 event handlers so we don&rsquo;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">&#182;</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">&amp;&amp;</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">&#39;: Ignoring &#39;</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">&#39;Ignoring &#39;</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">&#182;</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">&#182;</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">&#39;: abort&#39;</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">&#182;</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">&#182;</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">&#39;: canplay&#39;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&amp;&amp;</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">&#39;: canplay: Setting position to &#39;</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">&#39;: canplay: Setting position of &#39;</span> <span class="o">+</span> <span class="nx">position1K</span> <span class="o">+</span> <span class="s1">&#39; failed: &#39;</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">&#182;</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">&#182;</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 + &#39;: emptied&#39;);</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">&#39;: ended&#39;</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">&#39;: HTML5 error, code &#39;</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">&#182;</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">&#39;: loadeddata&#39;</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">&#182;</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">&amp;&amp;</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">&#39;: loadedmetadata&#39;</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">&#39;: loadstart&#39;</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">&#182;</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">&#39;: play()&#39;</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">&#182;</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">&#39;: playing&#39;</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">&#182;</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">&#182;</a>
</div>
<p>note: can fire repeatedly after &ldquo;loaded&rdquo; 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">&#39;progress&#39;</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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>reset the &ldquo;buffered&rdquo; (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">&amp;&amp;</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">&#182;</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">&#182;</a>
</div>
<p>re-build &ldquo;buffered&rdquo; 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">&lt;</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">&#39;start&#39;</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">&#39;end&#39;</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">&#182;</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">&#182;</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">&#182;</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">&amp;&amp;</span> <span class="nx">ranges</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</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">&lt;</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">&#39;-&#39;</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">&#39;: progress, timeRanges: &#39;</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">&#39;, &#39;</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">&amp;&amp;</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">&#39;: progress, &#39;</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">&#39;% loaded&#39;</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">&#182;</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">&#182;</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">&#182;</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">&amp;&amp;</span> <span class="nx">total</span> <span class="o">&amp;&amp;</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">&#182;</a>
</div>
<p>in case &ldquo;onload&rdquo; doesn&rsquo;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">&#39;: ratechange&#39;</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">&#182;</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">&#39;: suspend&#39;</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">&#39;: stalled&#39;</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">&#182;</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">&#39;: waiting&#39;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&#182;</a>
</div>
<p>Use type, if specified. If HTML5-only mode, no other options, so just give &lsquo;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">&#182;</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 &ldquo; 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">&#182;</a>
</div>
<p>Firefox likes &rdquo; for unload (used to work?) &ndash; however, may request hosting page URL (bad.) Most other UAs dislike &ldquo; 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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>Try to find MIME, test and return truthiness
o = {
url: &rsquo;/path/to/an.mp3',
type: &lsquo;audio/mp3&rsquo;
}</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">&#182;</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">&amp;&amp;</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">&amp;&amp;</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">&#39;\\.(&#39;</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">&#39;|&#39;</span><span class="p">)</span><span class="o">+</span><span class="s1">&#39;)(\\?.*)?$&#39;</span><span class="p">,</span><span class="s1">&#39;i&#39;</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">&#182;</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">&#182;</a>
</div>
<p>audio/mp3 &ndash;&gt; 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">&#39;;&#39;</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">&#182;</a>
</div>
<p>strip &quot;audio/X; codecs&hellip;&rdquo;</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">&#182;</a>
</div>
<p>match the raw extension name &ndash; &ldquo;mp3&rdquo;, 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">&amp;&amp;</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">&#182;</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">&amp;&amp;</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">&#39;audio/&#39;</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">&#182;</a>
</div>
<p>sm2._wD(&lsquo;canPlayType, found result: &rsquo; + 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">&amp;&amp;</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">&amp;&amp;</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">&#182;</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">&#182;</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 &ldquo;null&rdquo; 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">&amp;&amp;</span> <span class="nx">opera</span><span class="p">.</span><span class="nx">version</span><span class="p">()</span> <span class="o">&lt;</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">&#39;function&#39;</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">&#182;</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">&lt;</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">&#182;</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">&amp;&amp;</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">&#39;function&#39;</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">&amp;&amp;</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">&#182;</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">&#39;audio/&#39;</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">&#182;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&gt;=</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">&#182;</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">&#39;audio/&#39;</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">&#182;</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">&#39;Unavailable - wait until onready() has fired.&#39;</span><span class="p">,</span>
<span class="nx">notOK</span><span class="o">:</span> <span class="s1">&#39;Audio support is not available.&#39;</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">&#39;exception caught while appending SWF to DOM.&#39;</span><span class="p">,</span>
<span class="nx">spcWmode</span><span class="o">:</span> <span class="s1">&#39;Removing wmode, preventing known SWF loading issue(s)&#39;</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">&#39;Verify that %s is a valid path.&#39;</span><span class="p">,</span>
<span class="nx">tryDebug</span><span class="o">:</span> <span class="s1">&#39;Try &#39;</span> <span class="o">+</span> <span class="nx">sm</span> <span class="o">+</span> <span class="s1">&#39;.debugFlash = true for more security details (output goes to SWF.)&#39;</span><span class="p">,</span>
<span class="nx">checkSWF</span><span class="o">:</span> <span class="s1">&#39;See SWF output for more debug info.&#39;</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">&#39;Non-HTTP page (&#39;</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">&#39; 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/&#39;</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">&#39;Special case: Waiting for SWF to load with window focus...&#39;</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">&#39;Waiting indefinitely for Flash (will recover if unblocked)...&#39;</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">&#39;Waiting for 100% SWF load...&#39;</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">&#39;Function object expected for %s&#39;</span><span class="p">,</span>
<span class="nx">badID</span><span class="o">:</span> <span class="s1">&#39;Warning: Sound ID &quot;%s&quot; should be a string, starting with a non-numeric character&#39;</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">&#39;_debug(): Current sound objects&#39;</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">&#39;Waiting for window.onload()&#39;</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">&#39;Document already loaded&#39;</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">&#39;initComplete(): calling soundManager.onload()&#39;</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">&#39;.onload() complete&#39;</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">&#39;init(): Already called?&#39;</span><span class="p">,</span>
<span class="nx">secNote</span><span class="o">:</span> <span class="s1">&#39;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&#39;</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">&#39;Failed to remove Flash node.&#39;</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">&#39;.disable(): Shutting down&#39;</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">&#39;Queueing %s handler&#39;</span><span class="p">,</span>
<span class="nx">smError</span><span class="o">:</span> <span class="s1">&#39;SMSound.load(): Exception: JS-Flash communication failed, or JS error.&#39;</span><span class="p">,</span>
<span class="nx">fbTimeout</span><span class="o">:</span> <span class="s1">&#39;No flash response, applying .&#39;</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">&#39; CSS...&#39;</span><span class="p">,</span>
<span class="nx">fbLoaded</span><span class="o">:</span> <span class="s1">&#39;Flash loaded&#39;</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">&#39;Flash movie removed.&#39;</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">&#39;flashBlockHandler()&#39;</span><span class="p">,</span>
<span class="nx">manURL</span><span class="o">:</span> <span class="s1">&#39;SMSound.load(): Using manually-assigned URL&#39;</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">&#39;.load(): current URL already assigned.&#39;</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">&#39;.flashVersion must be 8 or 9. &quot;%s&quot; is invalid. Reverting to %s.&#39;</span><span class="p">,</span>
<span class="nx">as2loop</span><span class="o">:</span> <span class="s1">&#39;Note: Setting stream:false so looping can work (flash 8 limitation)&#39;</span><span class="p">,</span>
<span class="nx">noNSLoop</span><span class="o">:</span> <span class="s1">&#39;Note: Looping not implemented for MovieStar formats&#39;</span><span class="p">,</span>
<span class="nx">needfl9</span><span class="o">:</span> <span class="s1">&#39;Note: Switching to flash 9, required for MP4 formats.&#39;</span><span class="p">,</span>
<span class="nx">mfTimeout</span><span class="o">:</span> <span class="s1">&#39;Setting flashLoadTimeout = 0 (infinite) for off-screen, mobile flash case&#39;</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">&#39;Fatal error: Flash is needed to play some required formats, but is not available.&#39;</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">&#39;Got window focus.&#39;</span><span class="p">,</span>
<span class="nx">policy</span><span class="o">:</span> <span class="s1">&#39;Enabling usePolicyFile for data access&#39;</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">&#39;.setup(): allowed parameters: %s&#39;</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">&#39;.setup(): &quot;%s&quot; cannot be assigned with this method.&#39;</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">&#39;.setup(): Could not find option &quot;%s&quot;&#39;</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">&#39;.setup(): url, flashVersion and html5Test property changes will not take effect until reboot().&#39;</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">&#39;Flash URL required. Call soundManager.setup({url:...}) to get started.&#39;</span><span class="p">,</span>
<span class="nx">sm2Loaded</span><span class="o">:</span> <span class="s1">&#39;SoundManager 2: Ready.&#39;</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">&#39;.reset(): Removing event callbacks&#39;</span><span class="p">,</span>
<span class="nx">mobileUA</span><span class="o">:</span> <span class="s1">&#39;Mobile UA detected, preferring HTML5 by default.&#39;</span><span class="p">,</span>
<span class="nx">globalHTML5</span><span class="o">:</span> <span class="s1">&#39;Using singleton HTML5 Audio() pattern for this device.&#39;</span></pre></div>
</td>
</tr>
<tr id='section-374'>
<td class=docs>
<div class="pilwrap">
<a class="pilcrow" href="#section-374">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#39;&#39;</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">&amp;&amp;</span> <span class="nx">args</span> <span class="o">&amp;&amp;</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">&lt;</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">&#39;%s&#39;</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">&#182;</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">&#182;</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">&amp;&amp;</span> <span class="nx">sOpt</span><span class="p">.</span><span class="nx">loops</span> <span class="o">&gt;</span> <span class="mi">1</span> <span class="o">&amp;&amp;</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">&#39;as2loop&#39;</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">&amp;&amp;</span> <span class="o">!</span><span class="nx">sOpt</span><span class="p">.</span><span class="nx">usePolicyFile</span> <span class="o">&amp;&amp;</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">&#39;&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="s1">&#39;policy&#39;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&amp;&amp;</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">&#39;function&#39;</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">&#182;</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">&#39;.swf?&#39;</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">&#182;</a>
</div>
<p>assume user knows what they&rsquo;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">&#39;/&#39;</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">&#182;</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">&#39;/&#39;</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">&amp;&amp;</span> <span class="nx">smURL</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s1">&#39;/&#39;</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">&#39;/&#39;</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">&#39;./&#39;</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">&#39;?ts=&#39;</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">&#182;</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">&amp;&amp;</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">&#39;badFV&#39;</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">&#182;</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">&#39;_debug.swf&#39;</span><span class="o">:</span><span class="s1">&#39;.swf&#39;</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">&amp;&amp;</span> <span class="o">!</span><span class="nx">sm2</span><span class="p">.</span><span class="nx">html5Only</span> <span class="o">&amp;&amp;</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">&amp;&amp;</span> <span class="nx">fV</span> <span class="o">&lt;</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">&#39;needfl9&#39;</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">&#39; (HTML5-only mode)&#39;</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">&#39; (AS3/Flash 9)&#39;</span><span class="o">:</span><span class="s1">&#39; (AS2/Flash 8)&#39;</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">&#182;</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">&gt;</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">&#182;</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">&#182;</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">&#39;\\.(mp3|&#39;</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">&#39;|&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;)(\\?.*)?$&#39;</span><span class="p">,</span> <span class="s1">&#39;i&#39;</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">&#182;</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">&#39;flash9&#39;</span><span class="o">:</span><span class="s1">&#39;flash8&#39;</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">&#182;</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">&#39;soundmanager2.swf&#39;</span><span class="o">:</span><span class="s1">&#39;soundmanager2_flash9.swf&#39;</span><span class="p">).</span><span class="nx">replace</span><span class="p">(</span><span class="s1">&#39;.swf&#39;</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">&gt;</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">&#182;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&amp;&amp;</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">&#39;div&#39;</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">&#39;-toggle&#39;</span><span class="p">;</span>
<span class="nx">oToggle</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">&#39;position&#39;</span><span class="o">:</span> <span class="s1">&#39;fixed&#39;</span><span class="p">,</span>
<span class="s1">&#39;bottom&#39;</span><span class="o">:</span> <span class="s1">&#39;0px&#39;</span><span class="p">,</span>
<span class="s1">&#39;right&#39;</span><span class="o">:</span> <span class="s1">&#39;0px&#39;</span><span class="p">,</span>
<span class="s1">&#39;width&#39;</span><span class="o">:</span> <span class="s1">&#39;1.2em&#39;</span><span class="p">,</span>
<span class="s1">&#39;height&#39;</span><span class="o">:</span> <span class="s1">&#39;1.2em&#39;</span><span class="p">,</span>
<span class="s1">&#39;lineHeight&#39;</span><span class="o">:</span> <span class="s1">&#39;1.2em&#39;</span><span class="p">,</span>
<span class="s1">&#39;margin&#39;</span><span class="o">:</span> <span class="s1">&#39;2px&#39;</span><span class="p">,</span>
<span class="s1">&#39;textAlign&#39;</span><span class="o">:</span> <span class="s1">&#39;center&#39;</span><span class="p">,</span>
<span class="s1">&#39;border&#39;</span><span class="o">:</span> <span class="s1">&#39;1px solid #999&#39;</span><span class="p">,</span>
<span class="s1">&#39;cursor&#39;</span><span class="o">:</span> <span class="s1">&#39;pointer&#39;</span><span class="p">,</span>
<span class="s1">&#39;background&#39;</span><span class="o">:</span> <span class="s1">&#39;#fff&#39;</span><span class="p">,</span>
<span class="s1">&#39;color&#39;</span><span class="o">:</span> <span class="s1">&#39;#333&#39;</span><span class="p">,</span>
<span class="s1">&#39;zIndex&#39;</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">&#39;-&#39;</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">&#39;Toggle SM2 debug console&#39;</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">&#39;absolute&#39;</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">&#39;hand&#39;</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">&#39;div&#39;</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">&#39;block&#39;</span><span class="o">:</span><span class="s1">&#39;none&#39;</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">&amp;&amp;</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">&#39;domError&#39;</span><span class="p">)</span><span class="o">+</span><span class="s1">&#39; \n&#39;</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">&#182;</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">&#182;</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">&#39;&#39;</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">&#39;-toggle&#39;</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">&#182;</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">&#39;+&#39;</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">&#39;none&#39;</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">&#39;-&#39;</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">&#39;block&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#39; &#39;</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">&#182;</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">&#39;fbHandler&#39;</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">&#39;FLASHBLOCK&#39;</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">&#182;</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">&#39; &#39;</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">&#39; &#39;</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">&#39;: &#39;</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="s1">&#39;fbTimeout&#39;</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">&#39; (&#39;</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="s1">&#39;fbLoaded&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;)&#39;</span> <span class="o">:</span> <span class="s1">&#39;&#39;</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">&#182;</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">&#39;ontimeout&#39;</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">&#182;</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">&#182;</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">&#39;: Unblocked&#39;</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">&#182;</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">&#39; &#39;</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">&#39;&#39;</span><span class="p">)].</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39; &#39;</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">&#39;method&#39;</span><span class="o">:</span> <span class="nx">oMethod</span><span class="p">,</span>
<span class="s1">&#39;scope&#39;</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">&#39;fired&#39;</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">&#182;</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">&#39;onready&#39;</span> <span class="o">:</span> <span class="s1">&#39;ontimeout&#39;</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">&amp;&amp;</span> <span class="nx">oOptions</span> <span class="o">&amp;&amp;</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">&#182;</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">&#39;ontimeout&#39;</span> <span class="o">&amp;&amp;</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">&amp;&amp;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&amp;&amp;</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">&amp;&amp;</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">&lt;</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">&#182;</a>
</div>
<p>sm2._wD(sm + &lsquo;: Firing &rsquo; + queue.length + &lsquo; &rsquo; + oOptions.type + &lsquo;() item&rsquo; + (queue.length === 1 ? &ldquo; : &rsquo;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">&lt;</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">&#182;</a>
</div>
<p>useFlashBlock and SWF timeout case doesn&rsquo;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">&#182;</a>
</div>
<p>call user-defined &quot;onload&rdquo;, 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">&#39;function&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">_wDS</span><span class="p">(</span><span class="s1">&#39;onload&#39;</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">&#39;onloadOK&#39;</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">&#39;load&#39;</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">&#182;</a>
</div>
<p>hat tip: Flash Detect library (BSD, &copy; 2007) by Carl &ldquo;DocYes&rdquo; S. Yestrau &ndash; 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">&#182;</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">&amp;&amp;</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">&#39;application/x-shockwave-flash&#39;</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">&amp;&amp;</span> <span class="nx">types</span><span class="p">[</span><span class="nx">type</span><span class="p">]</span> <span class="o">&amp;&amp;</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">&amp;&amp;</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">&amp;&amp;</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">&#182;</a>
</div>
<p>Windows 8 Store Apps (MSAppHost) are weird (compatibility?) and won&rsquo;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">&#39;ShockwaveFlash.ShockwaveFlash&#39;</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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>iPhone &lt;= 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">&amp;&amp;</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">&#182;</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">&#182;</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">&#39;none&#39;</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">&#39;SoundManager: No HTML5 Audio() support detected.&#39;</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">&#182;</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">&#39;Note: Buggy HTML5 Audio in Safari on this OS X release, see https://bugs.webkit.org/show_bug.cgi?id=32159 - &#39;</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">&#39; would use flash fallback for MP3/MP4, but none detected.&#39;</span> <span class="o">:</span> <span class="s1">&#39;will use flash fallback for MP3/MP4, if available&#39;</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">&#182;</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">&amp;&amp;</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">&amp;&amp;</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">&amp;&amp;</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">&#182;</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">&#182;</a>
</div>
<p>sanity check&hellip;</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">&amp;&amp;</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">useHTML5Audio</span> <span class="o">&amp;&amp;</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">&#182;</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:&lsquo;/path/to/resource&rsquo;, type:&lsquo;audio/mp3&rsquo;} 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">&#182;</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">&lt;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&amp;&amp;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&#182;</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">&gt;=</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">&amp;&amp;</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">&#39;function&#39;</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">&amp;&amp;</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">&#182;</a>
</div>
<p>special case: &ldquo;bad&rdquo; Safari (OS X 10.3 &ndash; 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">&#182;</a>
</div>
<p>doesn&rsquo;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">&#39;mp3&#39;</span> <span class="o">||</span> <span class="nx">item</span> <span class="o">===</span> <span class="s1">&#39;mp4&#39;</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">&#39;: Using flash fallback for &#39;</span> <span class="o">+</span> <span class="nx">item</span> <span class="o">+</span> <span class="s1">&#39; format&#39;</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">&#182;</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">&amp;&amp;</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">&gt;=</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">&#182;</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">&#182;</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">&#39;unknown&#39;</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">&#39;localWithFile&#39;</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">&#39;secNote&#39;</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">&#39;localWithNetwork&#39;</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">&#39;localTrusted&#39;</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">&#182;</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">&#182;</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">&#39;swf&#39;</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">&#39;flashtojs&#39;</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">&#182;</a>
</div>
<p>complain if JS + SWF build/version strings don&rsquo;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">&#39;&#39;</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">&#39;&#39;</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">&#39;: Fatal: JavaScript file build &quot;&#39;</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">&#39;&quot; does not match Flash SWF build &quot;&#39;</span> <span class="o">+</span> <span class="nx">swfVersion</span> <span class="o">+</span> <span class="s1">&#39;&quot; at &#39;</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">&#39;. Ensure both are up-to-date.&#39;</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">&#182;</a>
</div>
<p>escape flash &ndash;&gt; 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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&#182;</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">&#39; + &#39;</span><span class="p">;</span>
<span class="nx">title</span> <span class="o">=</span> <span class="s1">&#39;SoundManager &#39;</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">&amp;&amp;</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">&#39; + HTML5 audio&#39;</span> <span class="o">:</span> <span class="s1">&#39;, no HTML5 audio support&#39;</span><span class="p">)</span> <span class="o">:</span> <span class="s1">&#39;&#39;</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">&#39;preferFlash&#39;</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">&#39;useHighPerformance&#39;</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">&#39;flashPollingInterval (&#39;</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">&#39;ms)&#39;</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">&#39;html5PollingInterval (&#39;</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">&#39;ms)&#39;</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">&#39;wmode (&#39;</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">&#39;)&#39;</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">&#39;debugFlash&#39;</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">&#39;flashBlock&#39;</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">&#39;html5PollingInterval (&#39;</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">&#39;ms)&#39;</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">&#39;, &#39;</span><span class="p">)</span> <span class="o">:</span> <span class="s1">&#39;&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;JS/Flash audio component (SoundManager 2)&#39;</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">&#39;html&#39;</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">&amp;&amp;</span> <span class="nx">html</span><span class="p">.</span><span class="nx">dir</span> <span class="o">&amp;&amp;</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">&#39;&lt;param name=&quot;&#39;</span><span class="o">+</span><span class="nx">name</span><span class="o">+</span><span class="s1">&#39;&quot; value=&quot;&#39;</span><span class="o">+</span><span class="nx">value</span><span class="o">+</span><span class="s1">&#39;&quot; /&gt;&#39;</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">&#182;</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">&amp;&amp;</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">useHighPerformance</span> <span class="o">?</span> <span class="s1">&#39;transparent&#39;</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">&amp;&amp;</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">&amp;&amp;</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">&amp;&amp;</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">&#182;</a>
</div>
<p>extra-special case: movie doesn&rsquo;t load until scrolled into view when using wmode = anything but &lsquo;window&rsquo; 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">&#39;name&#39;</span><span class="o">:</span> <span class="nx">smID</span><span class="p">,</span>
<span class="s1">&#39;id&#39;</span><span class="o">:</span> <span class="nx">smID</span><span class="p">,</span>
<span class="s1">&#39;src&#39;</span><span class="o">:</span> <span class="nx">smURL</span><span class="p">,</span>
<span class="s1">&#39;quality&#39;</span><span class="o">:</span> <span class="s1">&#39;high&#39;</span><span class="p">,</span>
<span class="s1">&#39;allowScriptAccess&#39;</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">&#39;bgcolor&#39;</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">&#39;pluginspage&#39;</span><span class="o">:</span> <span class="nx">http</span><span class="o">+</span><span class="s1">&#39;www.macromedia.com/go/getflashplayer&#39;</span><span class="p">,</span>
<span class="s1">&#39;title&#39;</span><span class="o">:</span> <span class="nx">swfTitle</span><span class="p">,</span>
<span class="s1">&#39;type&#39;</span><span class="o">:</span> <span class="s1">&#39;application/x-shockwave-flash&#39;</span><span class="p">,</span>
<span class="s1">&#39;wmode&#39;</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">&#182;</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">&#39;hasPriority&#39;</span><span class="o">:</span> <span class="s1">&#39;true&#39;</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">&#39;debug=1&#39;</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">&#182;</a>
</div>
<p>don&rsquo;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">&#182;</a>
</div>
<p>IE is &ldquo;special&rdquo;.</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">&#39;div&#39;</span><span class="p">);</span>
<span class="nx">movieHTML</span> <span class="o">=</span> <span class="p">[</span>
<span class="s1">&#39;&lt;object id=&quot;&#39;</span> <span class="o">+</span> <span class="nx">smID</span> <span class="o">+</span> <span class="s1">&#39;&quot; data=&quot;&#39;</span> <span class="o">+</span> <span class="nx">smURL</span> <span class="o">+</span> <span class="s1">&#39;&quot; type=&quot;&#39;</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">&#39;&quot; title=&quot;&#39;</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">&#39;&quot; classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot; codebase=&quot;&#39;</span> <span class="o">+</span> <span class="nx">http</span><span class="o">+</span><span class="s1">&#39;download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot;&gt;&#39;</span><span class="p">,</span>
<span class="nx">param</span><span class="p">(</span><span class="s1">&#39;movie&#39;</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">&#39;AllowScriptAccess&#39;</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">&#39;quality&#39;</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">&#39;wmode&#39;</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">&#39;&#39;</span><span class="p">),</span>
<span class="nx">param</span><span class="p">(</span><span class="s1">&#39;bgcolor&#39;</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">&#39;hasPriority&#39;</span><span class="p">,</span> <span class="s1">&#39;true&#39;</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">&#39;FlashVars&#39;</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">&#39;&#39;</span><span class="p">),</span>
<span class="s1">&#39;&lt;/object&gt;&#39;</span>
<span class="p">].</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;&#39;</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">&#39;embed&#39;</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">&#39;div&#39;</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">&#39; &#39;</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">&#182;</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">&#39;position&#39;</span><span class="o">:</span> <span class="s1">&#39;fixed&#39;</span><span class="p">,</span>
<span class="s1">&#39;width&#39;</span><span class="o">:</span> <span class="s1">&#39;8px&#39;</span><span class="p">,</span>
<span class="s1">&#39;height&#39;</span><span class="o">:</span> <span class="s1">&#39;8px&#39;</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">&#182;</a>
</div>
<blockquote>
<p>= 6px for flash to run fast, &gt;= 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">&#39;bottom&#39;</span><span class="o">:</span> <span class="s1">&#39;0px&#39;</span><span class="p">,</span>
<span class="s1">&#39;left&#39;</span><span class="o">:</span> <span class="s1">&#39;0px&#39;</span><span class="p">,</span>
<span class="s1">&#39;overflow&#39;</span><span class="o">:</span> <span class="s1">&#39;hidden&#39;</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">&#182;</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">&#39;position&#39;</span><span class="o">:</span> <span class="s1">&#39;absolute&#39;</span><span class="p">,</span>
<span class="s1">&#39;width&#39;</span><span class="o">:</span> <span class="s1">&#39;6px&#39;</span><span class="p">,</span>
<span class="s1">&#39;height&#39;</span><span class="o">:</span> <span class="s1">&#39;6px&#39;</span><span class="p">,</span>
<span class="s1">&#39;top&#39;</span><span class="o">:</span> <span class="s1">&#39;-9999px&#39;</span><span class="p">,</span>
<span class="s1">&#39;left&#39;</span><span class="o">:</span> <span class="s1">&#39;-9999px&#39;</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">&#39;px&#39;</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">&#182;</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">&#39;div&#39;</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">&#39;domError&#39;</span><span class="p">)</span><span class="o">+</span><span class="s1">&#39; \n&#39;</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">&#182;</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">&#39; &#39;</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">&#39; &#39;</span><span class="o">+</span><span class="nx">extraClass</span><span class="o">:</span><span class="s1">&#39;&#39;</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">&#39;div&#39;</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">&#182;</a>
</div>
<p>sm2._wD(sm + &lsquo;: Trying to load &rsquo; + smURL + (!overHTTP &amp;&amp; sm2.altURL ? &lsquo; (alternate URL)&rsquo; : &ldquo;), 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">&#182;</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">&#182;</a>
</div>
<p>Something isn&rsquo;t right &ndash; we&rsquo;ve reached init, but the soundManager url property has not been set.
User has not called setup({url: &hellip;}), 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">&#39;noURL&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#39;function&#39;</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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>No SWF url to load (noURL case) &ndash; 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">&#39;load&#39;</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">&amp;&amp;</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">&#182;</a>
</div>
<p>Safari won&rsquo;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">&#39;waitFocus&#39;</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">&gt;</span> <span class="mi">0</span> <span class="o">&amp;&amp;</span> <span class="nx">p</span> <span class="o">&lt;</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">&#182;</a>
</div>
<p>special case: if movie <em>partially</em> loaded, retry until it&rsquo;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">&#39;waitSWF&#39;</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">&#182;</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">&#39;: No Flash response within expected time. Likely causes: &#39;</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">&#39;SWF load failed, &#39;</span><span class="o">:</span><span class="s1">&#39;&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;Flash blocked or JS-Flash security error.&#39;</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">&#39; &#39;</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="s1">&#39;checkSWF&#39;</span><span class="p">)</span><span class="o">:</span><span class="s1">&#39;&#39;</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">&amp;&amp;</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">&#39;localFail&#39;</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">&#39;tryDebug&#39;</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">&#182;</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">&#39;swf404&#39;</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">&#39;flashtojs&#39;</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="s1">&#39;: Timed out&#39;</span> <span class="o">+</span> <span class="nx">overHTTP</span><span class="o">?</span><span class="s1">&#39; (Check flash security or flash blockers)&#39;</span><span class="o">:</span><span class="s1">&#39; (No plugin/missing SWF?)&#39;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#182;</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">&#39;waitForever&#39;</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">&#182;</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">&#39;waitForever&#39;</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">&#182;</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">&#39;ontimeout&#39;</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">&#182;</a>
</div>
<p>flash loaded? Shouldn&rsquo;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">&#39;waitForever&#39;</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">&#39;focus&#39;</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">&#182;</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">&#39;gotFocus&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#39;SoundManager 2: &#39;</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">&#39; &#39;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#39; = &#39;</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">&amp;&amp;</span> <span class="nx">hasFlash</span> <span class="o">&amp;&amp;</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">&#39; (using flash)&#39;</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">&amp;&amp;</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">&amp;&amp;</span> <span class="nx">hasFlash</span> <span class="o">?</span> <span class="s1">&#39; (preferring flash)&#39;</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">&#39; (&#39;</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">&#39;required, &#39;</span><span class="o">:</span><span class="s1">&#39;&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;and no flash support)&#39;</span> <span class="o">:</span> <span class="s1">&#39;&#39;</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">&#39;SoundManager 2 HTML5 support: &#39;</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">&#39;, &#39;</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">&#182;</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">&#182;</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">&#39;sm2Loaded&#39;</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">&#39;onload&#39;</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">&amp;&amp;</span> <span class="nx">sm2</span><span class="p">.</span><span class="nx">flashLoadTimeout</span> <span class="o">&amp;&amp;</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">&amp;&amp;</span> <span class="nx">needsFlash</span> <span class="o">?</span> <span class="s1">&#39;NO_FLASH&#39;</span> <span class="o">:</span> <span class="s1">&#39;INIT_TIMEOUT&#39;</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">&#39;SoundManager 2 &#39;</span> <span class="o">+</span> <span class="p">(</span><span class="nx">disabled</span> <span class="o">?</span> <span class="s1">&#39;failed to load&#39;</span> <span class="o">:</span> <span class="s1">&#39;loaded&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; (&#39;</span> <span class="o">+</span> <span class="p">(</span><span class="nx">disabled</span> <span class="o">?</span> <span class="s1">&#39;Flash security/load error&#39;</span> <span class="o">:</span> <span class="s1">&#39;OK&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;)&#39;</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">&amp;&amp;</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">&#39; &#39;</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">&#39;ontimeout&#39;</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">&#39;onload&#39;</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">&#39;onload&#39;</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">&amp;&amp;</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">&#39;waitOnload&#39;</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">&#39;load&#39;</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">&#182;</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">&amp;&amp;</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">&#39;docLoaded&#39;</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">&#182;</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">&#182;</a>
</div>
<p>apply top-level setupOptions object as local properties, eg., this.setupOptions.flashVersion &ndash;&gt; 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">&#182;</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">&#182;</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">&#182;</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">&#39;didInit&#39;</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">&#39;load&#39;</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">&#182;</a>
</div>
<p>we don&rsquo;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">&#182;</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">&#182;</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">&#182;</a>
</div>
<p>apply user-specified polling interval, OR, if &quot;high performance&rdquo; 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">&#182;</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">&#39;jstoflash&#39;</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">&#182;</a>
</div>
<p>prevent browser from showing cached page state (or rather, restoring &ldquo;suspended&rdquo; 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">&#39;unload&#39;</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">&#39;js/flash exception: &#39;</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">&#39;jstoflash&#39;</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">&#39;JS_TO_FLASH_EXCEPTION&#39;</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">&#182;</a>
</div>
<p>don&rsquo;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">&#182;</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">&#182;</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">&#182;</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">&#39;sm2-usehtml5audio=&#39;</span><span class="p">,</span>
<span class="nx">a2</span> <span class="o">=</span> <span class="s1">&#39;sm2-preferflash=&#39;</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">&amp;&amp;</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">&#39;function&#39;</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">&#39;1&#39;</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">&#39;Enabling &#39;</span><span class="o">:</span><span class="s1">&#39;Disabling &#39;</span><span class="p">)</span><span class="o">+</span><span class="s1">&#39;useHTML5Audio via URL parameter&#39;</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">&#39;useHTML5Audio&#39;</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">&#39;1&#39;</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">&#39;Enabling &#39;</span><span class="o">:</span><span class="s1">&#39;Disabling &#39;</span><span class="p">)</span><span class="o">+</span><span class="s1">&#39;preferFlash via URL parameter&#39;</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">&#39;preferFlash&#39;</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">&#182;</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">&amp;&amp;</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">&#39;SoundManager: No Flash detected&#39;</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">&#39;, enabling HTML5.&#39;</span> <span class="o">:</span> <span class="s1">&#39;. Trying HTML5-only mode.&#39;</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">&#39;useHTML5Audio&#39;</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">&#182;</a>
</div>
<p>make sure we aren&rsquo;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">&#39;preferFlash&#39;</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">&amp;&amp;</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">&#182;</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">&#39;flashLoadTimeout&#39;</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">&#39;DOMContentLoaded&#39;</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">&#39;complete&#39;</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">&#39;onreadystatechange&#39;</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">&#182;</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">&#39;load&#39;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&amp;&amp;</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">&#182;</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() &ndash;&gt; createSound() &ndash;&gt; 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">&#182;</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">&#182;</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">&#182;</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">&#39;focus&#39;</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">&#39;load&#39;</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">&#39;load&#39;</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">&#39;DOMContentLoaded&#39;</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">&#39;onreadystatechange&#39;</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">&#182;</a>
</div>
<p>no add/attachevent support &ndash; safe to assume no JS &ndash;&gt; Flash either</p>
</td>
<td class=code>
<div class='highlight'><pre> <span class="nx">debugTS</span><span class="p">(</span><span class="s1">&#39;onload&#39;</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">&#39;NO_DOM2_EVENTS&#39;</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">&#182;</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">&#182;</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>