在捕获停滞的事件并重新加载后不要重新申请

时间:2016-02-26 16:17:22

标签: javascript html5 audio soundmanager2

当尝试使用soundmanager2播放一首歌而另一首歌仍在加载时,我的状态会停滞不前。这个问题主要发生在Mac Yosemite上,但也出现在其他浏览器/机器上。

soundManager.play(soundId);

        if(soundManager.sounds[soundId] != undefined)
        {
soundManager.sounds[soundId]._a.addEventListener("stalled",function(){
               var audio = soundManager.sounds[soundId]._a;
               soundManager.unload(soundId);
               audio.load();
               audio.play();
            });
        }

我得到的控制台消息是:

soundmanager2.js:1295 playSound3976: Ignoring abort
soundmanager2.js:1295 playSound3973: abort
soundmanager2.js:1295 playSound3973: waiting
soundmanager2.js:1295 playSound3976: Ignoring loadstart
soundmanager2.js:1295 playSound3976: Ignoring error
soundmanager2.js:1295 playSound3973: loadstart
soundmanager2.js:1295 playSound3973: stalled
soundmanager2.js:1295 playSound3973: unload()
soundmanager2.js:1295 playSound3973: Ignoring loadstart
soundmanager2.js:1295 playSound3973: Ignoring error
soundmanager2.js:1295 playSound3973: Ignoring play
soundmanager2.js:1295 playSound3973: Ignoring waiting

0 个答案:

没有答案