Skip to content

Commit

Permalink
Force load queue events to only emit internally
Browse files Browse the repository at this point in the history
Fixes #899
  • Loading branch information
goldfire committed Feb 9, 2018
1 parent 09de619 commit 4c70500
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/howler.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@
// Trigger the play event, in order to keep iterating through queue.
if (!internal) {
setTimeout(function() {
self._emit('play', sound._id);
self._emit('play', 'queue');
}, 0);
}

Expand Down Expand Up @@ -773,13 +773,11 @@
self._playLock = true;

// Releases the lock and executes queued actions.
play.then(function () {
var runLoadQueue = function() {
self._playLock = false;
self._loadQueue();
}, function () {
self._playLock = false;
self._loadQueue();
});
};
play.then(runLoadQueue);
}

// If the node is still paused, then we can assume there was a playback issue.
Expand Down Expand Up @@ -1679,6 +1677,12 @@

// Loop through event store and fire all functions.
for (var i=events.length-1; i>=0; i--) {
// Don't fire listener on non-queue events if this is a queued event.
if (id === 'queue' && events[i].id === id) {
continue;
}

// Only fire the listener if the correct ID is used.
if (!events[i].id || events[i].id === id || event === 'load') {
setTimeout(function(fn) {
fn.call(this, id, msg);
Expand Down Expand Up @@ -1710,7 +1714,7 @@
self.once(task.event, function() {
self._queue.shift();
self._loadQueue();
});
}, 'queue');

task.action();
}
Expand Down

0 comments on commit 4c70500

Please sign in to comment.