Skip to content

Commit

Permalink
v2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
goldfire committed Dec 4, 2016
1 parent e5f3429 commit 8c80aea
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 57 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 2.0.2 (December 4, 2016)
- `FIXED` Wait to begin playback until AudioContext has resumed ([#643](https://github.com/goldfire/howler.js/issues/643)).
- `FIXED` Run `noAudio` check on initial setup instead of waiting for first `Howl` ([#619](https://github.com/goldfire/howler.js/issues/619)).
- `FIXED` Add `play` event to start of queue when `autoplay` is used ([#659](https://github.com/goldfire/howler.js/issues/659)).
- `FIXED` Make sure `seek` and `duration` are always >= 0 to prevent errors ([#682](https://github.com/goldfire/howler.js/pull/652)).
- `FIXED` Audio test wouldn't work in IE11 Enhanced Security Mode ([#631](https://github.com/goldfire/howler.js/pull/631)).
- `FIXED` Ensure AudioContext exists on `unload` ([#646](https://github.com/goldfire/howler.js/pull/646)).
- `FIXED` Always fire pause event even if sound is already paused ([#639](https://github.com/goldfire/howler.js/issues/639)).

## 2.0.1 (October 14, 2016)
- `ADDED` Support for FLAC audio files.
- `FIXED` Improve fading performance when short fade times are used ([#621](https://github.com/goldfire/howler.js/issues/621)).
Expand Down
4 changes: 2 additions & 2 deletions dist/howler.core.min.js

Large diffs are not rendered by default.

112 changes: 63 additions & 49 deletions dist/howler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* howler.js v2.0.1
* howler.js v2.0.2
* howlerjs.com
*
* (c) 2013-2016, James Simpson of GoldFire Studios
Expand Down Expand Up @@ -155,7 +155,7 @@
}

// Create a new AudioContext to make sure it is fully reset.
if (self.usingWebAudio && typeof self.ctx.close !== 'undefined') {
if (self.usingWebAudio && self.ctx && typeof self.ctx.close !== 'undefined') {
self.ctx.close();
self.ctx = null;
setupAudioContext();
Expand Down Expand Up @@ -186,6 +186,33 @@
// Automatically begin the 30-second suspend process
self._autoSuspend();

// Check if audio is available.
if (!self.usingWebAudio) {
// No audio is available on this system if noAudio is set to true.
if (typeof Audio !== 'undefined') {
try {
var test = new Audio();

// Check if the canplaythrough event is available.
if (typeof test.oncanplaythrough === 'undefined') {
self._canPlayEvent = 'canplay';
}
} catch(e) {
self.noAudio = true;
}
} else {
self.noAudio = true;
}
}

// Test to make sure audio isn't disabled in Internet Explorer.
try {
var test = new Audio();
if (test.muted) {
self.noAudio = true;
}
} catch (e) {}

// Check for supported codecs.
if (!self.noAudio) {
self._setupCodecs();
Expand All @@ -200,7 +227,14 @@
*/
_setupCodecs: function() {
var self = this || Howler;
var audioTest = (typeof Audio !== 'undefined') ? new Audio() : null;
var audioTest = null;

// Must wrap in a try/catch because IE11 in server mode throws an error.
try {
audioTest = (typeof Audio !== 'undefined') ? new Audio() : null;
} catch (err) {
return self;
}

if (!audioTest || typeof audioTest.canPlayType !== 'function') {
return self;
Expand Down Expand Up @@ -363,6 +397,11 @@
self.state = 'resuming';
self.ctx.resume().then(function() {
self.state = 'running';

// Emit to all Howls that the audio has resumed.
for (var i=0; i<self._howls.length; i++) {
self._howls[i]._emit('resume');
}
});

if (self._suspendTimer) {
Expand Down Expand Up @@ -444,6 +483,7 @@
self._onvolume = o.onvolume ? [{fn: o.onvolume}] : [];
self._onrate = o.onrate ? [{fn: o.onrate}] : [];
self._onseek = o.onseek ? [{fn: o.onseek}] : [];
self._onresume = [];

// Web Audio or HTML5 Audio?
self._webAudio = Howler.usingWebAudio && !self._html5;
Expand All @@ -456,6 +496,16 @@
// Keep track of this Howl group in the global controller.
Howler._howls.push(self);

// If they selected autoplay, add a play event to the load queue.
if (self._autoplay) {
self._queue.push({
event: 'play',
action: function() {
self.play();
}
});
}

// Load the source file unless otherwise specified.
if (self._preload) {
self.load();
Expand Down Expand Up @@ -624,8 +674,8 @@
}

// Determine how long to play for and where to start playing.
var seek = sound._seek > 0 ? sound._seek : self._sprite[sprite][0] / 1000;
var duration = ((self._sprite[sprite][0] + self._sprite[sprite][1]) / 1000) - seek;
var seek = Math.max(0, sound._seek > 0 ? sound._seek : self._sprite[sprite][0] / 1000);
var duration = Math.max(0, ((self._sprite[sprite][0] + self._sprite[sprite][1]) / 1000) - seek);
var timeout = (duration * 1000) / Math.abs(sound._rate);

// Update the parameters of the sound
Expand Down Expand Up @@ -668,11 +718,12 @@
}
};

if (self._state === 'loaded') {
var isRunning = (Howler.state === 'running');
if (self._state === 'loaded' && isRunning) {
playWebAudio();
} else {
// Wait for the audio to load and then begin playback.
self.once('load', playWebAudio, sound._id);
self.once(isRunning ? 'load' : 'resume', playWebAudio, isRunning ? sound._id : null);

// Cancel the end timer.
self._clearTimer(sound._id);
Expand Down Expand Up @@ -779,11 +830,11 @@
sound._node.pause();
}
}
}

// Fire the pause event, unless `true` is passed as the 2nd argument.
if (!arguments[1]) {
self._emit('pause', sound._id);
}
// Fire the pause event, unless `true` is passed as the 2nd argument.
if (!arguments[1]) {
self._emit('pause', sound ? sound._id : null);
}
}

Expand Down Expand Up @@ -1948,10 +1999,6 @@
parent._loadQueue();
}

if (parent._autoplay) {
parent.play();
}

// Clear the event listener.
self._node.removeEventListener(Howler._canPlayEvent, self._loadFn, false);
}
Expand Down Expand Up @@ -2069,19 +2116,12 @@
self._emit('load');
self._loadQueue();
}

// Begin playback if specified.
if (self._autoplay) {
self.play();
}
};

/**
* Setup the audio context when available, or switch to HTML5 Audio mode.
*/
var setupAudioContext = function() {
Howler.noAudio = false;

// Check if we are using Web Audio and setup the AudioContext if we are.
try {
if (typeof AudioContext !== 'undefined') {
Expand All @@ -2095,32 +2135,6 @@
Howler.usingWebAudio = false;
}

if (!Howler.usingWebAudio) {
// No audio is available on this system if noAudio is set to true.
if (typeof Audio !== 'undefined') {
try {
var test = new Audio();

// Check if the canplaythrough event is available.
if (typeof test.oncanplaythrough === 'undefined') {
Howler._canPlayEvent = 'canplay';
}
} catch(e) {
Howler.noAudio = true;
}
} else {
Howler.noAudio = true;
}
}

// Test to make sure audio isn't disabled in Internet Explorer
try {
var test = new Audio();
if (test.muted) {
Howler.noAudio = true;
}
} catch (e) {}

// Check if a webview is being used on iOS8 or earlier (rather than the browser).
// If it is, disable Web Audio as it causes crashing.
var iOS = (/iP(hone|od|ad)/.test(Howler._navigator && Howler._navigator.platform));
Expand Down Expand Up @@ -2178,7 +2192,7 @@
/*!
* Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
*
* howler.js v2.0.1
* howler.js v2.0.2
* howlerjs.com
*
* (c) 2013-2016, 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.1",
"version": "2.0.2",
"license": {
"type": "MIT",
"url": "https://raw.githubusercontent.com/goldfire/howler.js/master/LICENSE.md"
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.1
* howler.js v2.0.2
* howlerjs.com
*
* (c) 2013-2016, 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.1
* howler.js v2.0.2
* howlerjs.com
*
* (c) 2013-2016, James Simpson of GoldFire Studios
Expand Down

0 comments on commit 8c80aea

Please sign in to comment.