Skip to content

Commit

Permalink
Make node.play async when not using webAudio
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexdong committed Jul 6, 2013
1 parent 0b27ccd commit 18a91c5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions howler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -1126,4 +1126,4 @@
window.Howler = Howler;
window.Howl = Howl;
}
})();
})();

0 comments on commit 18a91c5

Please sign in to comment.