You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once setup is complete, we can get directly to loading and playing sounds. It is important to know, however,
118
-
that SoundJS uses a number of plugins to playback audio in different browsers. There are no additional steps to
119
-
initialize the plugins, and the default plugin set (Web Audio and HTML Elements) will work in the majority of
120
-
modern browsers. For this tutorial, the default plugin set will be fine.
118
+
that SoundJS uses a number of plugins to enable audio playback in different browsers. There are no additional
119
+
steps to initialize the plugins, and the default plugin set (Web Audio and HTML Elements) will work in the
120
+
majority of modern browsers. For this tutorial, the default plugin set will be fine.
121
121
</p>
122
122
<p>
123
123
Plugin selection will happen automatically the first time audio is preloaded or played, however if you need to
@@ -137,7 +137,7 @@ <h2>Internal Preloading</h2>
137
137
</header>
138
138
<p>
139
139
It is a best practice to preload audio so it is ready for immediate playback. We have an <ahref="../SoundJS%20and%20PreloadJS/index.html" target="_blank">
140
-
excellent tutorial on preloading techniques</a>, but for this example we'll only be doing a basic internal
140
+
excellent tutorial on preloading techniques</a>, but for this example we'll only be using a basic internal
<!-- TODO replace loadComplete event with current fileload when updated -->
165
165
<p>
166
-
With our audio comfortably defined in a manifest, let's move on to loading the audio. SoundJS introduced an
167
-
Event model in 0.4.0, and we can add an event listener for the <ahref="http://www.createjs.com/Docs/SoundJS/classes/Sound.html#event_fileload" target="_blank">
168
-
<code>fileload</code> event</a> (Note that SoundJS 0.4.0 uses a inconsistently-named <code>loadComplete</code>
169
-
event instead). It is a best practice to add this <em>before</em> we begin loading the audio to avoid a race
166
+
With our audio comfortably defined in a manifest, let's move on to loading the audio. SoundJS uses an
167
+
Event model, so we can add an event listener for the <ahref="http://www.createjs.com/Docs/SoundJS/classes/Sound.html#event_fileload" target="_blank">
168
+
<code>fileload</code> event</a>. It is a best practice to add this <em>before</em> we begin loading the audio to avoid a race
170
169
condition where audio can load from cache immediately. The second parameter of the listener is the function to
171
170
call back. Once this is ready, the audio load can be kicked off using the <ahref="http://www.createjs.com/Docs/SoundJS/classes/Sound.html#method_registerManifest" target="_blank">
172
171
<code>registerManifest</code> method</a>. Our deceptively simple and clean code should look like this:
more essential step: Currently, our <code>handleLoad</code> function is not called in the MyApp scope. That
319
325
means it will not have access to the MyApp object (this), and that the audio is not played inside of the touch
320
326
scope. We need this function to execute in our application scope to fix these problems, which we do using the
321
-
handy <code>createjs.proxy</code> method. This function uses <ahref="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply" target="_blank">
322
-
<code>Function.apply</code></a> to set the scope that a function executes in, which sets the "this" reference.
323
-
Function scope is a very important topic with JavaScript application development, so invest some time in
0 commit comments