Skip to content

Commit 18a91c5

Browse files
committed
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.
1 parent 0b27ccd commit 18a91c5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

howler.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
node.currentTime = pos;
397397
node.muted = Howler._muted;
398398
node.volume = self._volume * Howler.volume();
399-
node.play();
399+
setTimeout(function() { node.play(); }, 0);
400400
} else {
401401
self._clearEndTimer(timerId);
402402

@@ -1126,4 +1126,4 @@
11261126
window.Howler = Howler;
11271127
window.Howl = Howl;
11281128
}
1129-
})();
1129+
})();

0 commit comments

Comments
 (0)