225 lines
24 KiB
HTML
225 lines
24 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
||
|
<title>mpc.js</title>
|
||
|
<meta name="robots" content="noindex" />
|
||
|
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id='container'>
|
||
|
<div id="background"></div>
|
||
|
<div id="jump_to">
|
||
|
Jump To …
|
||
|
<div id="jump_wrapper">
|
||
|
<div id="jump_page">
|
||
|
<a class="source" href="../../360-player/script/360player.html">360player.js</a>
|
||
|
<a class="source" href="../../flashblock/flashblock.html">flashblock.css</a>
|
||
|
<a class="source" href="../../mp3-player-button/script/mp3-player-button.html">mp3-player-button.js</a>
|
||
|
<a class="source" href="mpc.html">mpc.js</a>
|
||
|
<a class="source" href="../../page-player/script/page-player.html">page-player.js</a>
|
||
|
<a class="source" href="../../play-mp3-links/script/inlineplayer.html">inlineplayer.js</a>
|
||
|
<a class="source" href="../../../script/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>mpc.js</h1></th>
|
||
|
<th class=code></th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<tr id='section-1'>
|
||
|
<td class=docs>
|
||
|
<div class="pilwrap">
|
||
|
<a class="pilcrow" href="#section-1">¶</a>
|
||
|
</div>
|
||
|
<p>SoundManager 2: MPC (Drum Machine) demo</p>
|
||
|
</td>
|
||
|
<td class=code>
|
||
|
<div class='highlight'><pre><span class="kd">var</span> <span class="nx">MPC</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">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
|
||
|
<span class="k">this</span><span class="p">.</span><span class="nx">idPrefix</span> <span class="o">=</span> <span class="s1">'btn-'</span><span class="p">;</span> <span class="c1">// HTML ID prefix</span>
|
||
|
<span class="k">this</span><span class="p">.</span><span class="nx">statusWidth</span> <span class="o">=</span> <span class="mi">6</span><span class="p">;</span>
|
||
|
<span class="k">this</span><span class="p">.</span><span class="nx">progressWidth</span> <span class="o">=</span> <span class="mi">256</span><span class="p">;</span>
|
||
|
<span class="k">this</span><span class="p">.</span><span class="nx">keys</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'1'</span><span class="o">:</span><span class="mi">0</span><span class="p">,</span><span class="s1">'2'</span><span class="o">:</span><span class="mi">1</span><span class="p">,</span><span class="s1">'3'</span><span class="o">:</span><span class="mi">2</span><span class="p">,</span><span class="s1">'4'</span><span class="o">:</span><span class="mi">3</span><span class="p">,</span><span class="s1">'q'</span><span class="o">:</span><span class="mi">4</span><span class="p">,</span><span class="s1">'w'</span><span class="o">:</span><span class="mi">5</span><span class="p">,</span><span class="s1">'e'</span><span class="o">:</span><span class="mi">6</span><span class="p">,</span><span class="s1">'r'</span><span class="o">:</span><span class="mi">7</span><span class="p">,</span><span class="s1">'a'</span><span class="o">:</span><span class="mi">8</span><span class="p">,</span><span class="s1">'s'</span><span class="o">:</span><span class="mi">9</span><span class="p">,</span><span class="s1">'d'</span><span class="o">:</span><span class="mi">10</span><span class="p">,</span><span class="s1">'f'</span><span class="o">:</span><span class="mi">11</span><span class="p">,</span><span class="s1">'z'</span><span class="o">:</span><span class="mi">12</span><span class="p">,</span><span class="s1">'x'</span><span class="o">:</span><span class="mi">13</span><span class="p">,</span><span class="s1">'c'</span><span class="o">:</span><span class="mi">14</span><span class="p">,</span><span class="s1">'v'</span><span class="o">:</span><span class="mi">15</span><span class="p">}</span></pre></div>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr id='section-2'>
|
||
|
<td class=docs>
|
||
|
<div class="pilwrap">
|
||
|
<a class="pilcrow" href="#section-2">¶</a>
|
||
|
</div>
|
||
|
<p>scope within these event handler methods: “this” = SMSound() object instance (see SMSound() in soundmanager.js for reference) </p>
|
||
|
</td>
|
||
|
<td class=code>
|
||
|
<div class='highlight'><pre> <span class="k">this</span><span class="p">.</span><span class="nx">showProgress</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-3'>
|
||
|
<td class=docs>
|
||
|
<div class="pilwrap">
|
||
|
<a class="pilcrow" href="#section-3">¶</a>
|
||
|
</div>
|
||
|
<p>sound is loading, update bytes received using this.bytesLoaded / this.bytesTotal</p>
|
||
|
</td>
|
||
|
<td class=code>
|
||
|
<div class='highlight'><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">_getButton</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">id</span><span class="p">).</span><span class="nx">className</span> <span class="o">!=</span> <span class="s1">'loading'</span><span class="p">)</span> <span class="nx">self</span><span class="p">.</span><span class="nx">_getButton</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">id</span><span class="p">).</span><span class="nx">className</span> <span class="o">=</span> <span class="s1">'loading'</span><span class="p">;</span> <span class="c1">// a bit inefficient here..</span>
|
||
|
<span class="nx">self</span><span class="p">.</span><span class="nx">_showStatus</span><span class="p">(</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">bytesLoaded</span><span class="p">,</span><span class="k">this</span><span class="p">.</span><span class="nx">bytesTotal</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="p">{</span>
|
||
|
<span class="nx">soundManager</span><span class="p">.</span><span class="nx">_writeDebug</span><span class="p">(</span><span class="s1">'mpc.onid3()'</span><span class="p">);</span>
|
||
|
<span class="kd">var</span> <span class="nx">oName</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
|
||
|
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">oName</span> <span class="k">in</span> <span class="k">this</span><span class="p">.</span><span class="nx">id3</span><span class="p">)</span> <span class="p">{</span>
|
||
|
<span class="nx">soundManager</span><span class="p">.</span><span class="nx">_writeDebug</span><span class="p">(</span><span class="nx">oName</span><span class="o">+</span><span class="s1">': '</span><span class="o">+</span><span class="k">this</span><span class="p">.</span><span class="nx">id3</span><span class="p">[</span><span class="nx">oName</span><span class="p">])</span> <span class="c1">// write out name/value ID3 pairs (eg. "artist: Beck")</span>
|
||
|
<span class="p">}</span>
|
||
|
<span class="p">}</span>
|
||
|
|
||
|
<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="p">{</span>
|
||
|
<span class="kd">var</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="nx">self</span><span class="p">.</span><span class="nx">_getButton</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">id</span><span class="p">).</span><span class="nx">className</span> <span class="o">=</span> <span class="s1">''</span><span class="p">;</span>
|
||
|
<span class="nx">self</span><span class="p">.</span><span class="nx">_getButton</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">id</span><span class="p">).</span><span class="nx">title</span> <span class="o">=</span> <span class="p">(</span><span class="s1">'Sound ID: '</span><span class="o">+</span><span class="k">this</span><span class="p">.</span><span class="nx">id</span><span class="o">+</span><span class="s1">' ('</span><span class="o">+</span><span class="k">this</span><span class="p">.</span><span class="nx">url</span><span class="o">+</span><span class="s1">')'</span><span class="p">);</span>
|
||
|
<span class="p">}</span>
|
||
|
|
||
|
<span class="k">this</span><span class="p">.</span><span class="nx">onfinish</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
||
|
<span class="nx">self</span><span class="p">.</span><span class="nx">_getButton</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">id</span><span class="p">).</span><span class="nx">className</span> <span class="o">=</span> <span class="s1">''</span><span class="p">;</span>
|
||
|
<span class="nx">self</span><span class="p">.</span><span class="nx">_reset</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">id</span><span class="p">);</span>
|
||
|
<span class="p">}</span>
|
||
|
|
||
|
<span class="k">this</span><span class="p">.</span><span class="nx">onplay</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
||
|
<span class="nx">self</span><span class="p">.</span><span class="nx">_getButton</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">id</span><span class="p">).</span><span class="nx">className</span> <span class="o">=</span> <span class="s1">'active'</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="p">{</span>
|
||
|
<span class="nx">self</span><span class="p">.</span><span class="nx">_showStatus</span><span class="p">(</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">position</span><span class="p">,</span><span class="k">this</span><span class="p">.</span><span class="nx">duration</span><span class="p">);</span>
|
||
|
<span class="p">}</span>
|
||
|
|
||
|
<span class="k">this</span><span class="p">.</span><span class="nx">_keyHandler</span> <span class="o">=</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">oEvt</span> <span class="o">=</span> <span class="nx">e</span><span class="o">?</span><span class="nx">e</span><span class="o">:</span><span class="nx">event</span><span class="p">;</span>
|
||
|
<span class="kd">var</span> <span class="nx">sChar</span> <span class="o">=</span> <span class="nb">String</span><span class="p">.</span><span class="nx">fromCharCode</span><span class="p">(</span><span class="nx">oEvt</span><span class="p">.</span><span class="nx">keyCode</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="k">typeof</span> <span class="nx">self</span><span class="p">.</span><span class="nx">keys</span><span class="p">[</span><span class="nx">sChar</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">'undefined'</span><span class="p">)</span> <span class="nx">soundManager</span><span class="p">.</span><span class="nx">play</span><span class="p">(</span><span class="s1">'s'</span><span class="o">+</span><span class="nx">self</span><span class="p">.</span><span class="nx">keys</span><span class="p">[</span><span class="nx">sChar</span><span class="p">]);</span>
|
||
|
<span class="p">}</span>
|
||
|
|
||
|
<span class="k">this</span><span class="p">.</span><span class="nx">_showStatus</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">n1</span><span class="p">,</span><span class="nx">n2</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">self</span><span class="p">.</span><span class="nx">_getButton</span><span class="p">(</span><span class="nx">sID</span><span class="p">).</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">'div'</span><span class="p">)[</span><span class="mi">0</span><span class="p">];</span>
|
||
|
<span class="kd">var</span> <span class="nx">offX</span> <span class="o">=</span> <span class="p">(</span><span class="nx">n2</span><span class="o">></span><span class="mi">0</span><span class="o">?</span><span class="p">(</span><span class="o">-</span><span class="nx">self</span><span class="p">.</span><span class="nx">progressWidth</span><span class="o">+</span><span class="nb">parseInt</span><span class="p">((</span><span class="nx">n1</span><span class="o">/</span><span class="nx">n2</span><span class="p">)</span><span class="o">*</span><span class="nx">o</span><span class="p">.</span><span class="nx">offsetWidth</span><span class="p">))</span><span class="o">:-</span><span class="nx">self</span><span class="p">.</span><span class="nx">progressWidth</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">backgroundPosition</span> <span class="o">=</span> <span class="nx">offX</span><span class="o">+</span><span class="s1">'px 0px'</span><span class="p">;</span>
|
||
|
<span class="p">}</span>
|
||
|
|
||
|
<span class="k">this</span><span class="p">.</span><span class="nx">_getButton</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="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">idPrefix</span><span class="o">+</span><span class="nx">sID</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="nx">sID</span><span class="p">)</span> <span class="p">{</span>
|
||
|
<span class="kd">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">sID</span><span class="p">;</span>
|
||
|
<span class="nx">self</span><span class="p">.</span><span class="nx">_showStatus</span><span class="p">(</span><span class="nx">sID</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</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="nx">self</span><span class="p">.</span><span class="nx">_showStatus</span><span class="p">(</span><span class="nx">sID</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">);},</span><span class="mi">200</span><span class="p">);</span>
|
||
|
<span class="p">}</span>
|
||
|
|
||
|
<span class="k">this</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>
|
||
|
<span class="nb">document</span><span class="p">.</span><span class="nx">onkeydown</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">_keyHandler</span><span class="p">;</span>
|
||
|
<span class="p">}</span>
|
||
|
|
||
|
<span class="p">}</span>
|
||
|
|
||
|
<span class="kd">var</span> <span class="nx">mpc</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">MPC</span><span class="p">();</span>
|
||
|
|
||
|
<span class="nx">soundManager</span><span class="p">.</span><span class="nx">flashVersion</span> <span class="o">=</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">toString</span><span class="p">().</span><span class="nx">match</span><span class="p">(</span><span class="sr">/#flash8/i</span><span class="p">)</span><span class="o">?</span><span class="mi">8</span><span class="o">:</span><span class="mi">9</span><span class="p">);</span>
|
||
|
<span class="k">if</span> <span class="p">(</span><span class="nx">soundManager</span><span class="p">.</span><span class="nx">flashVersion</span> <span class="o">!=</span> <span class="mi">8</span><span class="p">)</span> <span class="p">{</span>
|
||
|
<span class="nx">soundManager</span><span class="p">.</span><span class="nx">useHighPerformance</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
|
||
|
<span class="p">}</span>
|
||
|
|
||
|
<span class="nx">soundManager</span><span class="p">.</span><span class="nx">setup</span><span class="p">({</span>
|
||
|
<span class="nx">url</span><span class="o">:</span> <span class="s1">'../../swf/'</span><span class="p">,</span> <span class="c1">// path to load SWF from (overriding default)</span>
|
||
|
<span class="nx">bgColor</span><span class="o">:</span> <span class="s1">'#333333'</span><span class="p">,</span>
|
||
|
<span class="nx">wmode</span><span class="o">:</span> <span class="s1">'transparent'</span><span class="p">,</span>
|
||
|
<span class="nx">debugMode</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
|
||
|
<span class="nx">consoleOnly</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
|
||
|
<span class="nx">useFlashBlock</span><span class="o">:</span> <span class="kc">true</span>
|
||
|
<span class="p">});</span>
|
||
|
|
||
|
<span class="nx">soundManager</span><span class="p">.</span><span class="nx">onready</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-4'>
|
||
|
<td class=docs>
|
||
|
<div class="pilwrap">
|
||
|
<a class="pilcrow" href="#section-4">¶</a>
|
||
|
</div>
|
||
|
<p>This is the “onload” equivalent which is called when SoundManager has been initialised (sounds can be created, etc.)</p>
|
||
|
</td>
|
||
|
<td class=code>
|
||
|
<div class='highlight'><pre> <span class="nx">mpc</span><span class="p">.</span><span class="nx">init</span><span class="p">();</span></pre></div>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr id='section-5'>
|
||
|
<td class=docs>
|
||
|
<div class="pilwrap">
|
||
|
<a class="pilcrow" href="#section-5">¶</a>
|
||
|
</div>
|
||
|
<p>set up some default options / event handlers – so all sounds created are given these handlers</p>
|
||
|
</td>
|
||
|
<td class=code>
|
||
|
<div class='highlight'><pre> <span class="nx">soundManager</span><span class="p">.</span><span class="nx">setup</span><span class="p">({</span>
|
||
|
<span class="nx">defaultOptions</span><span class="o">:</span> <span class="p">{</span>
|
||
|
<span class="nx">autoLoad</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
|
||
|
<span class="nx">whileloading</span><span class="o">:</span> <span class="nx">mpc</span><span class="p">.</span><span class="nx">showProgress</span><span class="p">,</span>
|
||
|
<span class="nx">onid3</span><span class="o">:</span> <span class="nx">mpc</span><span class="p">.</span><span class="nx">onid3</span><span class="p">,</span>
|
||
|
<span class="nx">onload</span><span class="o">:</span> <span class="nx">mpc</span><span class="p">.</span><span class="nx">onload</span><span class="p">,</span>
|
||
|
<span class="nx">onplay</span><span class="o">:</span> <span class="nx">mpc</span><span class="p">.</span><span class="nx">onplay</span><span class="p">,</span>
|
||
|
<span class="nx">whileplaying</span><span class="o">:</span> <span class="nx">mpc</span><span class="p">.</span><span class="nx">whileplaying</span><span class="p">,</span>
|
||
|
<span class="nx">onfinish</span><span class="o">:</span> <span class="nx">mpc</span><span class="p">.</span><span class="nx">onfinish</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">soundManager</span><span class="p">.</span><span class="nx">html5</span><span class="p">.</span><span class="nx">needsFlash</span><span class="p">)</span> <span class="p">{</span>
|
||
|
<span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'isHTML5'</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">'inline'</span><span class="p">;</span>
|
||
|
<span class="p">}</span>
|
||
|
<span class="kd">var</span> <span class="nx">soundURLs</span> <span class="o">=</span> <span class="s1">'AMB_BD_1,AMB_FTM2,AMB_HHCL,AMB_HHOP,AMB_HHPD,AMB_HTM,AMB_LTM2,AMB_MTM,AMB_RIM1,AMB_SN13,AMB_SN_5,CHINA_1,CRASH_1,CRASH_5,CRASH_6,RIDE_1'</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">','</span><span class="p">);</span>
|
||
|
<span class="k">for</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="nx">i</span><span class="o"><</span><span class="nx">soundURLs</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="nx">soundManager</span><span class="p">.</span><span class="nx">createSound</span><span class="p">(</span><span class="s1">'s'</span><span class="o">+</span><span class="nx">i</span><span class="p">,</span> <span class="s1">'audio/'</span><span class="o">+</span><span class="nx">soundURLs</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="o">+</span><span class="s1">'.mp3'</span><span class="p">);</span>
|
||
|
<span class="p">}</span></pre></div>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr id='section-6'>
|
||
|
<td class=docs>
|
||
|
<div class="pilwrap">
|
||
|
<a class="pilcrow" href="#section-6">¶</a>
|
||
|
</div>
|
||
|
<p>createSound options can also be set on a per-file basis, with specific option overrides.
|
||
|
(Options not specified here will inherit defaults as defined in soundManager.defaultOptions.)</p>
|
||
|
|
||
|
<p>eg.</p>
|
||
|
|
||
|
<p>soundManager.createSound({
|
||
|
id: ‘mySound’,
|
||
|
url: ‘/path/to/some.mp3’,
|
||
|
stream: true,
|
||
|
autoPlay: true,
|
||
|
multiShot: false,
|
||
|
whileloading: function() { alert(‘sound ’+this.id+‘: ’+this.bytesLoaded+‘ of ’+this.bytesTotal+‘ bytes loaded.’); } // event handler: “this” is scoped to SMSound() object instance for easy access to methods/properties
|
||
|
});</p>
|
||
|
|
||
|
<ul>
|
||
|
<li>OR –</li>
|
||
|
</ul>
|
||
|
|
||
|
<p>If you just want a sound with all default options, you can also specify just the required id and URL as string parameters:</p>
|
||
|
|
||
|
<p>soundManager.createSound(‘mySound’,‘/path/to/some.mp3’);</p>
|
||
|
|
||
|
</td>
|
||
|
<td class=code>
|
||
|
<div class='highlight'><pre><span class="p">});</span></pre></div>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
</body>
|