HTML and CSS Reference
In-Depth Information
this is not an exact science, it's important that there are delays of at least 1 second between effects to ensure one
effect doesn't accidentally start playing the sound after it.
To see how the code that does this looks, fill in the stub of the enableMobileSound method in quin-
tus_audio.js with the code in Listing 25-2 .
Listing 25-2: The enableMobileSound method
Q.audio.enableMobileSound = function() {
var isiOS = navigator.userAgent.match(/iPad|iPod|iPhone/i) != null;
Q.audioSprites = function(asset) {
if(_.isString(asset)) asset = Q.asset(asset);
Q.audio.spriteFile = asset['resources'][0].replace(/\.[a-z]+$/
,"");
Q.audio.sprites = asset['spritemap'];
Q.el.on("touchstart",Q.audio.start);
}
// Turn off normal sound loading and processing
Q.options.sound = false;
Q.audio.timer = function() {
Q.audio.sheet.currentTime = 0;
Q.audio.sheet.play();
Q.audio.silenceTimer = setTimeout(Q.audio.timer,500);
};
Q.audio.start = function() {
Q.audio.sheet = new Audio();
Q.audio.sheet.preload = true;
Q.audio.sheet.addEventListener("canplaythrough", function() {
Q.audio.sheet.play();
Q.audio.silenceTimer = setTimeout(Q.audio.timer,500);
});
var spriteFilename = Q.options.audioPath + Q.audio.spriteFile;
if(isiOS) {
Q.audio.sheet.src = spriteFilename + ".caf";
} else {
Q.audio.sheet.src = spriteFilename + ".mp3";
}
Q.audio.sheet.load();
Q.el.off("touchstart",Q.audio.start);
};
Q.play = function(sound,debounce) {
 
Search WWH ::




Custom Search