Skip to content

Commit

Permalink
v2.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
goldfire committed Jun 9, 2017
1 parent d3236c5 commit 273394e
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 44 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 2.0.4 (June 9, 2017)
- `CHANGED` Removed the `resuming` state, which wasn't actually being used and was leading to a bug on Android ([#679](https://github.com/goldfire/howler.js/pull/679)).
- `CHANGED` Any playback initiated before the sound has loaded will now go into the queue to fix various race conditions ([#714](https://github.com/goldfire/howler.js/pull/714)).
- `FIXED` Correctly initialize an AudioContext with the global mute status ([#714](https://github.com/goldfire/howler.js/pull/714)).
- `FIXED` AudioContext unlocks on user interaction within a cross-domain iframe on Android Chrome ([#756](https://github.com/goldfire/howler.js/pull/756)).
- `FIXED` Stopping/pausing a group of sounds now behaves as expected in edge cases ([#734](https://github.com/goldfire/howler.js/pull/734)).
- `FIXED` Sound ID's now start at 1000 instead of 0 to avoid `rate` collisions ([#764](https://github.com/goldfire/howler.js/issues/764)).
- `FIXED` Prevent unknown mime errors on Internet Explorer when unloading a sound ([#720](https://github.com/goldfire/howler.js/pull/720)).
- `FIXED` Correctly clean up error event listeners ([#720](https://github.com/goldfire/howler.js/pull/720)).
- `FIXED` Audio clipping in Internet Explorer when network latency is present with HTML5 Audio ([#720](https://github.com/goldfire/howler.js/pull/720)).
- `FIXED` Allow passing just an event and ID to turn off listener ([#767](https://github.com/goldfire/howler.js/issues/767)).
- `FIXED` `npm` warning caused by invalid license definition ([#763](https://github.com/goldfire/howler.js/pull/763)).

## 2.0.3 (March 11, 2017)
- `CHANGED` Unloading a sound no longer fires the `end` event ([#675](https://github.com/goldfire/howler.js/pull/675)).
- `FIXED` Remove `setTimeout` wrapper on HTML5 `play` call to fix issues on mobile browsers ([#694](https://github.com/goldfire/howler.js/pull/694)).
Expand Down
4 changes: 2 additions & 2 deletions dist/howler.core.min.js

Large diffs are not rendered by default.

98 changes: 62 additions & 36 deletions dist/howler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* howler.js v2.0.3
* howler.js v2.0.4
* howlerjs.com
*
* (c) 2013-2017, James Simpson of GoldFire Studios
Expand Down Expand Up @@ -31,7 +31,7 @@
var self = this || Howler;

// Create a global ID counter.
self._counter = 0;
self._counter = 1000;

// Internal properties.
self._codecs = {};
Expand Down Expand Up @@ -303,6 +303,9 @@
// then check if the audio actually played to determine if
// audio has now been unlocked on iOS, Android, etc.
var unlock = function() {
// Fix Android can not play in suspend state.
Howler._autoResume();

// Create an empty buffer.
var source = self.ctx.createBufferSource();
source.buffer = self._scratchBuffer;
Expand All @@ -315,6 +318,11 @@
source.start(0);
}

// Calling resume() on a stack initiated by user gesture is what actually unlocks the audio on Android Chrome >= 55.
if (typeof self.ctx.resume === 'function') {
self.ctx.resume();
}

// Setup a timeout to check that we are unlocked on the next event loop.
source.onended = function() {
source.disconnect(0);
Expand Down Expand Up @@ -397,7 +405,6 @@
clearTimeout(self._suspendTimer);
self._suspendTimer = null;
} else if (self.state === 'suspended') {
self.state = 'resuming';
self.ctx.resume().then(function() {
self.state = 'running';

Expand Down Expand Up @@ -651,17 +658,26 @@
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 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') {
// Set the sprite value on this sound.
sound._sprite = sprite;

// Makr this sounded as not ended in case another sound is played before this one loads.
sound._ended = false;

// Add the sound to the queue to be played on load.
var soundId = sound._id;
self._queue.push({
event: 'play',
action: function() {
self.play(self._soundById(sound._id) ? sound._id : undefined);
self.play(soundId);
}
});

return sound._id;
return soundId;
}

// Don't play the sound if an id was passed and it is already playing.
Expand Down Expand Up @@ -819,9 +835,9 @@

if (sound._node) {
if (self._webAudio) {
// make sure the sound has been created
// Make sure the sound has been created.
if (!sound._node.bufferSource) {
return self;
continue;
}

if (typeof sound._node.bufferSource.stop === 'undefined') {
Expand Down Expand Up @@ -890,32 +906,26 @@

if (sound._node) {
if (self._webAudio) {
// make sure the sound has been created
if (!sound._node.bufferSource) {
if (!internal) {
self._emit('stop', sound._id);
// Make sure the sound's AudioBufferSourceNode has been created.
if (sound._node.bufferSource) {
if (typeof sound._node.bufferSource.stop === 'undefined') {
sound._node.bufferSource.noteOff(0);
} else {
sound._node.bufferSource.stop(0);
}

return self;
}

if (typeof sound._node.bufferSource.stop === 'undefined') {
sound._node.bufferSource.noteOff(0);
} else {
sound._node.bufferSource.stop(0);
// Clean up the buffer source.
self._cleanBuffer(sound._node);
}

// Clean up the buffer source.
self._cleanBuffer(sound._node);
} else if (!isNaN(sound._node.duration) || sound._node.duration === Infinity) {
sound._node.currentTime = sound._start || 0;
sound._node.pause();
}
}
}

if (sound && !internal) {
self._emit('stop', sound._id);
if (!internal) {
self._emit('stop', sound._id);
}
}
}

Expand Down Expand Up @@ -1478,8 +1488,11 @@

// Remove the source or disconnect.
if (!self._webAudio) {
// Set the source to 0-second silence to stop any downloading.
sounds[i]._node.src = 'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA';
// Set the source to 0-second silence to stop any downloading (except in IE).
var checkIE = /MSIE |Trident\//.test(Howler._navigator && Howler._navigator.userAgent);
if (!checkIE) {
sounds[i]._node.src = 'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA';
}

// Remove any event listeners.
sounds[i]._node.removeEventListener('error', sounds[i]._errorFn, false);
Expand Down Expand Up @@ -1554,10 +1567,17 @@
var events = self['_on' + event];
var i = 0;

if (fn) {
// Allow passing just an event and ID.
if (typeof fn === 'number') {
id = fn;
fn = null;
}

if (fn || id) {
// Loop through event store and remove the passed function.
for (i=0; i<events.length; i++) {
if (fn === events[i].fn && id === events[i].id) {
var isId = (id === events[i].id);
if (fn === events[i].fn && isId || !fn && isId) {
events.splice(i, 1);
break;
}
Expand Down Expand Up @@ -1655,6 +1675,14 @@
var self = this;
var sprite = sound._sprite;

// 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 && self._node && !self._node.ended) {
setTimeout(self._ended.bind(self, sound), 100);
return self;
}

// Should this sound loop?
var loop = !!(sound._loop || self._sprite[sprite][2]);

Expand Down Expand Up @@ -1887,7 +1915,6 @@
self._muted = parent._muted;
self._loop = parent._loop;
self._volume = parent._volume;
self._muted = parent._muted;
self._rate = parent._rate;
self._seek = 0;
self._paused = true;
Expand Down Expand Up @@ -1956,7 +1983,6 @@
self._muted = parent._muted;
self._loop = parent._loop;
self._volume = parent._volume;
self._muted = parent._muted;
self._rate = parent._rate;
self._seek = 0;
self._rateSeek = 0;
Expand All @@ -1980,7 +2006,7 @@
self._parent._emit('loaderror', self._id, self._node.error ? self._node.error.code : 0);

// Clear the event listener.
self._node.removeEventListener('error', self._errorListener, false);
self._node.removeEventListener('error', self._errorFn, false);
},

/**
Expand Down Expand Up @@ -2155,7 +2181,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 = 1;
Howler.masterGain.gain.value = Howler._muted ? 0 : 1;
Howler.masterGain.connect(Howler.ctx.destination);
}

Expand Down Expand Up @@ -2197,7 +2223,7 @@
/*!
* Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
*
* howler.js v2.0.3
* howler.js v2.0.4
* howlerjs.com
*
* (c) 2013-2017, 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
Expand Up @@ -28,7 +28,7 @@
"uglify-js": "2.x"
},
"main": "dist/howler.js",
"version": "2.0.3",
"version": "2.0.4",
"license": "MIT",
"files": [
"src",
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.3
* howler.js v2.0.4
* howlerjs.com
*
* (c) 2013-2017, 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.3
* howler.js v2.0.4
* howlerjs.com
*
* (c) 2013-2017, James Simpson of GoldFire Studios
Expand Down

0 comments on commit 273394e

Please sign in to comment.