From 18a91c5f8af1fdfb49196c0bde4cf05c3d78f9c5 Mon Sep 17 00:00:00 2001 From: Alex Dong Date: Sat, 6 Jul 2013 17:55:36 +1200 Subject: [PATCH] Make `node.play` async when not using webAudio It took me half day to figure out why Howler is not working in the latest Firefox release. If I manually load the `.ogg` file in the browser, Howler.play works beautifully but if the file is not loaded, there was no sound coming out. By wrapping the `node.play` in a `setTimeout(func, 0)` wrapper, we force the `play` event to wait till the current loading event is finished. Please note that Firefox's default setting for `media.webaudio.enabled` is `false`, which is why `self._webAudio` code path wasn't selected. --- howler.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/howler.js b/howler.js index 7355ca8c..eb3f5a90 100644 --- a/howler.js +++ b/howler.js @@ -396,7 +396,7 @@ node.currentTime = pos; node.muted = Howler._muted; node.volume = self._volume * Howler.volume(); - node.play(); + setTimeout(function() { node.play(); }, 0); } else { self._clearEndTimer(timerId); @@ -1126,4 +1126,4 @@ window.Howler = Howler; window.Howl = Howl; } -})(); \ No newline at end of file +})();