Skip to content

Commit

Permalink
v2.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
goldfire committed Dec 15, 2017
1 parent ee3d0ae commit 5c024f9
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 30 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 2.0.6 (December 15, 2017)
- `FIXED` Replaced deprecated `gain.value` and `gain.pan.value` with `setValueAtTime` ([#856](https://github.com/goldfire/howler.js/issues/856)).
- `FIXED` Audio sprites weren't ending correctly in Internet Explorer 11 ([#841](https://github.com/goldfire/howler.js/issues/841)).
- `FIXED` Correctly set group volume when fading ([#539](https://github.com/goldfire/howler.js/issues/539)).
- `FIXED` Cancel `fade` on sound when `mute` is called ([#666](https://github.com/goldfire/howler.js/issues/666)).
- `FIXED` Uncaught error when play() request was interrupted by a call to pause() ([#835](https://github.com/goldfire/howler.js/pull/835)).
- `FIXED` Incorrect reference to global `_scratchBuffer` ([#834](https://github.com/goldfire/howler.js/pull/834)).

## 2.0.5 (October 6, 2017)
- `ADDED` Add support for `withCredentials` to Web Audio XHR requests ([#610](https://github.com/goldfire/howler.js/pull/610)).
- `ADDED` Add `playerror` event for when mobile HTML5 audio is unable to play ([#774](https://github.com/goldfire/howler.js/issues/774)).
Expand Down
4 changes: 2 additions & 2 deletions dist/howler.core.min.js

Large diffs are not rendered by default.

68 changes: 48 additions & 20 deletions dist/howler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* howler.js v2.0.5
* howler.js v2.0.6
* howlerjs.com
*
* (c) 2013-2017, James Simpson of GoldFire Studios
Expand Down Expand Up @@ -81,7 +81,7 @@

// When using Web Audio, we just need to adjust the master gain.
if (self.usingWebAudio) {
self.masterGain.gain.value = vol;
self.masterGain.gain.setValueAtTime(vol, Howler.ctx.currentTime);
}

// Loop through and change volume for all HTML5 audio nodes.
Expand Down Expand Up @@ -123,7 +123,7 @@

// With Web Audio, we just need to mute the master gain.
if (self.usingWebAudio) {
self.masterGain.gain.value = muted ? 0 : self._volume;
self.masterGain.gain.setValueAtTime(muted ? 0 : self._volume, Howler.ctx.currentTime);
}

// Loop through and mute all HTML5 Audio nodes.
Expand Down Expand Up @@ -483,6 +483,7 @@
self._sounds = [];
self._endTimers = {};
self._queue = [];
self._playLock = false;

// Setup event listeners.
self._onend = o.onend ? [{fn: o.onend}] : [];
Expand Down Expand Up @@ -764,7 +765,19 @@

// Mobile browsers will throw an error if this is called without user interaction.
try {
node.play();
var play = node.play();

// Support older browsers that don't support promises, and thus don't have this issue.
if (typeof Promise !== 'undefined' && play instanceof Promise) {
// Implements a lock to prevent DOMException: The play() request was interrupted by a call to pause().
self._playLock = true;

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

// If the node is still paused, then we can assume there was a playback issue.
if (node.paused) {
Expand Down Expand Up @@ -816,8 +829,8 @@
pause: function(id) {
var self = this;

// If the sound hasn't loaded, add it to the load queue to pause when capable.
if (self._state !== 'loaded') {
// If the sound hasn't loaded or a play() promise is pending, add it to the load queue to pause when capable.
if (self._state !== 'loaded' || self._playLock) {
self._queue.push({
event: 'pause',
action: function() {
Expand Down Expand Up @@ -986,6 +999,11 @@
if (sound) {
sound._muted = muted;

// Cancel active fade and set the volume to the end value.
if (sound._interval) {
self._stopFade(sound._id);
}

if (self._webAudio && sound._node) {
sound._node.gain.setValueAtTime(muted ? 0 : sound._volume, Howler.ctx.currentTime);
} else if (sound._node) {
Expand Down Expand Up @@ -1129,7 +1147,7 @@
sound._node.gain.linearRampToValueAtTime(to, end);
}

self._startFadeInterval(sound, from, to, len, ids[i]);
self._startFadeInterval(sound, from, to, len, ids[i], typeof id === 'undefined');
}
}

Expand All @@ -1143,8 +1161,9 @@
* @param {Number} to The volume to fade to (0.0 to 1.0).
* @param {Number} len Time in milliseconds to fade.
* @param {Number} id The sound id to fade.
* @param {Boolean} isGroup If true, set the volume on the group.
*/
_startFadeInterval: function(sound, from, to, len, id) {
_startFadeInterval: function(sound, from, to, len, id, isGroup) {
var self = this;
var vol = from;
var dir = from > to ? 'out' : 'in';
Expand All @@ -1158,6 +1177,10 @@
stepLen = 4;
}

// Store the value being faded to.
sound._fadeTo = to;

// Update the volume value on each interval tick.
sound._interval = setInterval(function() {
// Update the volume amount, but only if the volume should change.
if (steps > 0) {
Expand All @@ -1173,19 +1196,21 @@

// Change the volume.
if (self._webAudio) {
if (typeof id === 'undefined') {
self._volume = vol;
}

sound._volume = vol;
} else {
self.volume(vol, sound._id, true);
}

// Set the group's volume.
if (isGroup) {
self._volume = vol;
}

// When the fade is complete, stop it and fire event.
if ((to < from && vol <= to) || (to > from && vol >= to)) {
clearInterval(sound._interval);
sound._interval = null;
sound._fadeTo = null;
self.volume(to, sound._id);
self._emit('fade', sound._id);
}
Expand All @@ -1209,6 +1234,8 @@

clearInterval(sound._interval);
sound._interval = null;
self.volume(sound._fadeTo, id);
sound._fadeTo = null;
self._emit('fade', id);
}

Expand Down Expand Up @@ -1706,7 +1733,8 @@
// If we are using IE and there was network latency we may be clipping
// audio before it completes playing. Lets check the node to make sure it
// believes it has completed, before ending the playback.
if (!self._webAudio && sound._node && !sound._node.paused) {
const ended = sound._node.currentTime >= sound._stop;
if (!self._webAudio && sound._node && !sound._node.paused && !sound._node.ended && !ended) {
setTimeout(self._ended.bind(self, sound), 100);
return self;
}
Expand Down Expand Up @@ -1908,10 +1936,10 @@
_cleanBuffer: function(node) {
var self = this;

if (self._scratchBuffer) {
if (Howler._scratchBuffer) {
node.bufferSource.onended = null;
node.bufferSource.disconnect(0);
try { node.bufferSource.buffer = self._scratchBuffer; } catch(e) {}
try { node.bufferSource.buffer = Howler._scratchBuffer; } catch(e) {}
}
node.bufferSource = null;

Expand Down Expand Up @@ -2210,7 +2238,7 @@
// Create and expose the master GainNode when using Web Audio (useful for plugins or advanced usage).
if (Howler.usingWebAudio) {
Howler.masterGain = (typeof Howler.ctx.createGain === 'undefined') ? Howler.ctx.createGainNode() : Howler.ctx.createGain();
Howler.masterGain.gain.value = Howler._muted ? 0 : 1;
Howler.masterGain.gain.setValueAtTime(Howler._muted ? 0 : 1, Howler.ctx.currentTime);
Howler.masterGain.connect(Howler.ctx.destination);
}

Expand Down Expand Up @@ -2252,7 +2280,7 @@
/*!
* Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
*
* howler.js v2.0.5
* howler.js v2.0.6
* howlerjs.com
*
* (c) 2013-2017, James Simpson of GoldFire Studios
Expand Down Expand Up @@ -2464,7 +2492,7 @@
if (pannerType === 'spatial') {
sound._panner.setPosition(pan, 0, 0);
} else {
sound._panner.pan.value = pan;
sound._panner.pan.setValueAtTime(pan, Howler.ctx.currentTime);
}
}

Expand Down Expand Up @@ -2833,7 +2861,7 @@
sound._panner.setOrientation(sound._orientation[0], sound._orientation[1], sound._orientation[2]);
} else {
sound._panner = Howler.ctx.createStereoPanner();
sound._panner.pan.value = sound._stereo;
sound._panner.pan.setValueAtTime(sound._stereo, Howler.ctx.currentTime);
}

sound._panner.connect(sound._node);
Expand All @@ -2843,4 +2871,4 @@
sound._parent.pause(sound._id, true).play(sound._id);
}
};
})();
})();
6 changes: 3 additions & 3 deletions dist/howler.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 5c024f9

Please sign in to comment.