dimanche 8 février 2015

Leaving a webpage with SoundJS causes Google Chrome to crash

I have a webpage index.php which contains a link to sound.php. On sound.php, sound is played using SoundJS.


When I navigate from sound.php to index.php, Google Chrome usually (but not always) displays an error message ("Aw, Snap!"): http://ift.tt/1eNGrmh


I'm using Chrome 40 for Mac OS. It doesn't matter whether I use a link or the browser's back button.


Here's my code:


sound.php calls a JS function that's using SoundJS:



<script type="text/javascript">
var int = [0, 7];
prepareAudio();
</script>


As soon as I delete this code, the browser doesn't crash anymore.


prepareAudio() is in an external file:



function prepareAudio() {

// Try WebAudio or HTMLAudio
createjs.Sound.initializeDefaultPlugins();

// Try flash otherwise
if (!createjs.Sound.isReady()) {
// Flash plug-in is not default
createjs.FlashPlugin.swfPath = "../audio/";

// Enable flash support
$.getScript("../../js/flashplugin-0.6.0.min.js");

// Prefer WebAudio over HTMLAudio. Prefer HTMLAudio over Flash.
createjs.Sound.registerPlugins([createjs.WebAudioPlugin, createjs.HTMLAudioPlugin, createjs.FlashPlugin]);
}

// Get audio files
var audioPath = "../audio/";

var manifest = [];
for (var i = 0; i< audioFiles.length; i++)
manifest.push({id: audioFiles[i], src: audioPath + audioFiles[i] + ".ogg"});

// Play audio
var queue = new createjs.LoadQueue();
createjs.Sound.alternateExtensions = ["mp3"];
queue.installPlugin(createjs.Sound);
queue.addEventListener("complete", function() {playTask(int);});
queue.loadManifest(manifest);
createjs.Sound.registerSounds(manifest, audioPath);
}


There's some more code involved. I play sounds using



createjs.Sound.play(mySound);


Audio playback is fine in Chrome and other browsers.


Aucun commentaire:

Enregistrer un commentaire