Skip to content

Commit

Permalink
fix(html5-playback): remove setTimeout() call that caused loss of cal…
Browse files Browse the repository at this point in the history
…l stack

On mobile, the play event needs to be triggered by a user gesture. By setting a timeout the call
stack containing the user tap gesture is lost. Since this was added way back to support something in
Firefox 13 it could most likely be removed without negative impact.

  goldfire#609
  • Loading branch information
marcusstenbeck committed Jan 20, 2017
1 parent 96e8a96 commit 602ce76
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/howler.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,18 +736,16 @@
node.volume = sound._volume * Howler.volume();
node.playbackRate = sound._rate;

setTimeout(function() {
node.play();
node.play();

// Setup the new end timer.
if (timeout !== Infinity) {
self._endTimers[sound._id] = setTimeout(self._ended.bind(self, sound), timeout);
}
// Setup the new end timer.
if (timeout !== Infinity) {
self._endTimers[sound._id] = setTimeout(self._ended.bind(self, sound), timeout);
}

if (!internal) {
self._emit('play', sound._id);
}
}, 0);
if (!internal) {
self._emit('play', sound._id);
}
};

// Play immediately if ready, or wait for the 'canplaythrough'e vent.
Expand Down

0 comments on commit 602ce76

Please sign in to comment.