Skip to content

Commit

Permalink
Always wait to play until sound has loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
goldfire committed Jun 2, 2017
1 parent 3eba98e commit 85f0813
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/howler.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,13 +653,14 @@
sprite = sound._sprite || '__default';
}

// If we have no sprite and the sound hasn't loaded, we must wait
// for the sound to load to get our audio's duration.
if (self._state !== 'loaded' && !self._sprite[sprite]) {
// If If the sound hasn't loaded, we must wait to get the audio's duration.
// We also need to wait to make sure we don't run into race conditions with
// the order of function calls.
if (self._state !== 'loaded') {
self._queue.push({
event: 'play',
action: function() {
self.play(self._soundById(sound._id) ? sound._id : undefined);
self.play(sprite, internal);
}
});

Expand Down

0 comments on commit 85f0813

Please sign in to comment.