diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-07-24 18:20:51 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-07-24 18:20:51 -0700 |
commit | 5739787049a07e1bf478af4bffad9e8906fb1e4b (patch) | |
tree | 4a5a7132d20d0f6712dff3e6fa8c2c5e31f17ad8 /src/library_browser.js | |
parent | 7fc38afc4fab96f77ac63fe790e4f5e4778caf1b (diff) |
finally found a working workaround for chromium bug 124926
Diffstat (limited to 'src/library_browser.js')
-rw-r--r-- | src/library_browser.js | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index dbfb42d8..3ff5c310 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -121,14 +121,13 @@ mergeInto(LibraryManager.library, { if (done) return; done = true; Module["preloadedAudios"][name] = audio; - audio['oncanplaythrough'] = null; if (onload) onload(byteArray); } if (Browser.hasBlobConstructor) { var b = new Blob([byteArray], { type: getMimetype(name) }); var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this! var audio = new Audio(); - audio['oncanplaythrough'] = function() { finish(audio) }; // XXX string for closure + audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926 audio.onerror = function(event) { if (done) return; console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach'); @@ -159,16 +158,6 @@ mergeInto(LibraryManager.library, { audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray); finish(audio); // we don't wait for confirmation this worked - but it's worth trying }; - // One of oncanplaythrough, onerror should definitely fire. if not, the browser is misbehaving, try - // to work around this issue (chromium bug 124926) - setTimeout(function() { - if (done) return; - if (!audioPlugin.shownWarning) { - audioPlugin.shownWarning = true; - alert('Your browser is having trouble loading audio files. Sound effects may not work properly.'); - } - finish(audio); // try to continue normally, the sound might be ok if the oncanplaythrough callback just didn't fire - }, 5000); audio.src = url; } else { Module["preloadedAudios"][name] = new Audio(); // empty shim |