Skip to content

Commit

Permalink
v2.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
goldfire committed Feb 10, 2018
1 parent bf83277 commit f7d7bc2
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 31 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.0.9 (February 10, 2018)
- `FIXED` More accurate HTML5 Audio `end` timer and fix for Firefox streams ending early ([#883](https://github.com/goldfire/howler.js/issues/883)).
- `FIXED` Prevent `play` events from duplicating in certain instances ([#899](https://github.com/goldfire/howler.js/issues/899)).
- `FIXED` Add second parameter to HTML5 Audio playback promise to fix Safari error ([#896](https://github.com/goldfire/howler.js/pull/896)).
- `FIXED` Refactored the internal queue system to fix various edge cases.

## 2.0.8 (January 19, 2018)
- `CHANGED` Fades now use elapsed time to be more accurate when intervals are inconsistent ([#885](https://github.com/goldfire/howler.js/issues/885)).
- `CHANGED` Improve timing of short fades ([#884](https://github.com/goldfire/howler.js/issues/884)).
Expand Down
4 changes: 2 additions & 2 deletions dist/howler.core.min.js

Large diffs are not rendered by default.

82 changes: 59 additions & 23 deletions dist/howler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* howler.js v2.0.8
* howler.js v2.0.9
* howlerjs.com
*
* (c) 2013-2018, James Simpson of GoldFire Studios
Expand Down Expand Up @@ -689,9 +689,7 @@
if (id && !sound._paused) {
// Trigger the play event, in order to keep iterating through queue.
if (!internal) {
setTimeout(function() {
self._emit('play', sound._id);
}, 0);
self._loadQueue('play');
}

return sound._id;
Expand Down Expand Up @@ -773,10 +771,15 @@
self._playLock = true;

// Releases the lock and executes queued actions.
play.then(function () {
var runLoadQueue = function() {
self._playLock = false;
self._loadQueue();
});
if (!internal) {
self._emit('play', sound._id);
}
};
play.then(runLoadQueue, runLoadQueue);
} else if (!internal) {
self._emit('play', sound._id);
}

// If the node is still paused, then we can assume there was a playback issue.
Expand All @@ -786,13 +789,18 @@
return;
}

// Setup the new end timer.
if (timeout !== Infinity) {
// Setup the end timer on sprites or listen for the ended event.
if (sprite !== '__default') {
self._endTimers[sound._id] = setTimeout(self._ended.bind(self, sound), timeout);
}

if (!internal) {
self._emit('play', sound._id);
} else {
self._endTimers[sound._id] = function() {
// Fire ended on this audio node.
self._ended(sound);

// Clear this listener.
node.removeEventListener('ended', self._endTimers[sound._id], false);
};
node.addEventListener('ended', self._endTimers[sound._id], false);
}
} catch (err) {
self._emit('playerror', sound._id, err);
Expand All @@ -801,7 +809,7 @@

// Play immediately if ready, or wait for the 'canplaythrough'e vent.
var loadedNoReadyState = (window && window.ejecta) || (!node.readyState && Howler._navigator.isCocoonJS);
if (node.readyState === 4 || loadedNoReadyState) {
if (node.readyState >= 3 || loadedNoReadyState) {
playHtml5();
} else {
var listener = function() {
Expand Down Expand Up @@ -1353,7 +1361,7 @@

// Change the playback rate.
if (self._webAudio && sound._node && sound._node.bufferSource) {
sound._node.bufferSource.playbackRate.setValueAtTime(rate, Howler.ctx.currentTime);;
sound._node.bufferSource.playbackRate.setValueAtTime(rate, Howler.ctx.currentTime);
} else if (sound._node) {
sound._node.playbackRate = rate;
}
Expand Down Expand Up @@ -1455,7 +1463,19 @@
sound._node.currentTime = seek;
}

self._emit('seek', id);
// Wait for the play lock to be unset before emitting (HTML5 Audio).
if (playing && !self._webAudio) {
var emitSeek = function() {
if (!self._playLock) {
self._emit('seek', id);
} else {
setTimeout(emitSeek, 0);
}
};
setTimeout(emitSeek, 0);
} else {
self._emit('seek', id);
}
} else {
if (self._webAudio) {
var realTime = self.playing(id) ? Howler.ctx.currentTime - sound._playStart : 0;
Expand Down Expand Up @@ -1676,6 +1696,7 @@

// Loop through event store and fire all functions.
for (var i=events.length-1; i>=0; i--) {
// 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 All @@ -1688,6 +1709,9 @@
}
}

// Pass the event type into load queue so that it can continue stepping.
self._loadQueue(event);

return self;
},

Expand All @@ -1697,19 +1721,22 @@
* after the previous has finished executing (even if async like play).
* @return {Howl}
*/
_loadQueue: function() {
_loadQueue: function(event) {
var self = this;

if (self._queue.length > 0) {
var task = self._queue[0];

// don't move onto the next task until this one is done
self.once(task.event, function() {
// Remove this task if a matching event was passed.
if (task.event === event) {
self._queue.shift();
self._loadQueue();
});
}

task.action();
// Run the task if no event type is passed.
if (!event) {
task.action();
}
}

return self;
Expand Down Expand Up @@ -1786,7 +1813,16 @@
var self = this;

if (self._endTimers[id]) {
clearTimeout(self._endTimers[id]);
// Clear the timeout or remove the ended listener.
if (typeof self._endTimers[id] !== 'function') {
clearTimeout(self._endTimers[id]);
} else {
var sound = self._soundById(id);
if (sound && sound._node) {
sound._node.removeEventListener('ended', self._endTimers[id], false);
}
}

delete self._endTimers[id];
}

Expand Down Expand Up @@ -2273,7 +2309,7 @@
/*!
* Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
*
* howler.js v2.0.8
* howler.js v2.0.9
* howlerjs.com
*
* (c) 2013-2018, James Simpson of GoldFire Studios
Expand Down
4 changes: 2 additions & 2 deletions dist/howler.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/howler.spatial.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "howler",
"version": "2.0.8",
"version": "2.0.9",
"description": "Javascript audio library for the modern web.",
"homepage": "https://howlerjs.com",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion src/howler.core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* howler.js v2.0.8
* howler.js v2.0.9
* howlerjs.com
*
* (c) 2013-2018, James Simpson of GoldFire Studios
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/howler.spatial.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
*
* howler.js v2.0.8
* howler.js v2.0.9
* howlerjs.com
*
* (c) 2013-2018, James Simpson of GoldFire Studios
Expand Down

0 comments on commit f7d7bc2

Please sign in to comment.