HTML and CSS Reference
In-Depth Information
if(! || ! return;
if( return;
if(debounce) {
Q.activeSound = true
setTimeout(function() { = null;
sound = sound.replace(/\.[a-z0-9]+$/,"");
if( &&[sound]) {
var startTime =[sound].start - 0.05,
endDelay =[sound].end - startTime; = startTime;;
clearTimeout(; = setTimeout(,
endDelay*1000 + 500);
This method first checks if the device is an iOS device using userAgent matching. This is not an ideal
method (user agent matching never is) but it's the only way to put in a specific file-type workaround for iOS.
Next is the Q.audioSprites method, which is used to pass in the JSON data asset that provides position
and length information about the sprites. It stores the filename to load and the sprites inside of the
object. It also binds to the first touch event on Q.el (the Canvas element) to start the audio system. This is the
trick that allows the system to start playing the sprite sound.
Next, it sets Q.options.sound to false , which has the effect of telling the loading system in Quintus
not to try to load any sound files in the normal Q.load process. This needs to be done to prevent the engine
from trying to load sound files because these files will never trigger their canplaythrough callbacks due to
mobile preloading restrictions.
The method is the default callback that ensures that when no other sounds are playing,
the audio element continues to loop over the first 500 milliseconds of the sprite, which are known to be silent.
The method is called on the first touch event. Because it's triggered by a user event, it
can set up and load a sound file. When the canplaythrough event triggers, it calls play and starts the silence
Next, the system loads the sound file into the audio spritesheet at . On iOS devices, al-
though mobile Safari has support for a number of different sound formats, only the .caf file format (when
encoded with the IMA-ADPCM codec) can be played natively without using iTunes to do the actual playing.
Using iTunes to play sounds causes a noticeable delay and stutter inside of mobile Safari.
Finally, turns off the touchstart callback to prevent it from being called twice.
After handling debouncing much in the same way as on the desktop, the method itself has the job to
find the sprite in the object. It first removes any file extensions off the sound name (the
Search WWH ::

Custom Search