Skip to content

Commit

Permalink
v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
goldfire committed May 17, 2020
1 parent a7ad26c commit a093f49
Show file tree
Hide file tree
Showing 20 changed files with 103 additions and 53 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 2.2.0 (May 17, 2020)
- `ADDED` New `xhr` property that allows setting custom headers (such as for auth), changing the `withCredentials` setting and specifying the HTTP method for the request. These only apply to Web Audio ([#997](https://github.com/goldfire/howler.js/pull/997)).
- `ADDED` New `Howler.stop()` global stop method to stop all sounds at once ([#1308](https://github.com/goldfire/howler.js/issues/1308)).
- `ADDED` Support for `m48` audio format ([#1170](https://github.com/goldfire/howler.js/pull/1170)).
- `CHANGED` Allow passing `metadata` string to `preload` option to only preload the metadata ([#1140](https://github.com/goldfire/howler.js/pull/1140)).
- `FIXED` Correctly handle AudioContext interrupted state causing stuck `suspending` state ([#1106](https://github.com/goldfire/howler.js/pull/1106)).
- `FIXED` The `volume` method would sometimes return incorrect values when using very short `fade` lengths ([#1045](https://github.com/goldfire/howler.js/pull/1045)).
- `FIXED` Error that `HowlerGlobal` was not defined when using `jsdom-global` ([#1331](https://github.com/goldfire/howler.js/pull/1331)).
- `FIXED` Memory leak in Safari when an audio context can't be unlocked ([#1338](https://github.com/goldfire/howler.js/pull/1338)).

### Breaking Changes
* The `xhrWithCredentials` property is now included in the `xhr` property object with key `withCredentials`.

## 2.1.3 (December 24, 2019)
- `FIXED` Don't try to obtain HTML5 audio if there is no audio support ([#1191](https://github.com/goldfire/howler.js/issues/1191)).
- `FIXED` The x/y/z orientations for the top of the listener weren't being set properly ([#1221](https://github.com/goldfire/howler.js/pull/1221)).
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013-2019 James Simpson and GoldFire Studios, Inc.
Copyright (c) 2013-2020 James Simpson and GoldFire Studios, Inc.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,6 @@ ffmpeg -i sound1.wav -dash 1 sound1.webm

### License

Copyright (c) 2013-2019 [James Simpson](https://twitter.com/GoldFireStudios) and [GoldFire Studios, Inc.](http://goldfirestudios.com)
Copyright (c) 2013-2020 [James Simpson](https://twitter.com/GoldFireStudios) and [GoldFire Studios, Inc.](http://goldfirestudios.com)

Released under the [MIT License](https://github.com/goldfire/howler.js/blob/master/LICENSE.md).
4 changes: 2 additions & 2 deletions dist/howler.core.min.js

Large diffs are not rendered by default.

97 changes: 67 additions & 30 deletions dist/howler.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*!
* howler.js v2.1.3
* howler.js v2.2.0
* howlerjs.com
*
* (c) 2013-2019, James Simpson of GoldFire Studios
* (c) 2013-2020, James Simpson of GoldFire Studios
* goldfirestudios.com
*
* MIT License
Expand Down Expand Up @@ -150,6 +150,20 @@
return self;
},

/**
* Handle stopping all sounds globally.
*/
stop: function() {
var self = this || Howler;

// Loop through all Howls and stop them.
for (var i=0; i<self._howls.length; i++) {
self._howls[i].stop();
}

return self;
},

/**
* Unload and destroy all currently loaded Howl objects.
* @return {Howler}
Expand Down Expand Up @@ -263,6 +277,7 @@
aac: !!audioTest.canPlayType('audio/aac;').replace(/^no$/, ''),
caf: !!audioTest.canPlayType('audio/x-caf;').replace(/^no$/, ''),
m4a: !!(audioTest.canPlayType('audio/x-m4a;') || audioTest.canPlayType('audio/m4a;') || audioTest.canPlayType('audio/aac;')).replace(/^no$/, ''),
m4b: !!(audioTest.canPlayType('audio/x-m4b;') || audioTest.canPlayType('audio/m4b;') || audioTest.canPlayType('audio/aac;')).replace(/^no$/, ''),
mp4: !!(audioTest.canPlayType('audio/x-mp4;') || audioTest.canPlayType('audio/mp4;') || audioTest.canPlayType('audio/aac;')).replace(/^no$/, ''),
weba: !!audioTest.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, ''),
webm: !!audioTest.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, ''),
Expand Down Expand Up @@ -312,7 +327,7 @@
// to the WebAudio API which only needs a single activation.
// This must occur before WebAudio setup or the source.onended
// event will not fire.
for (var i=0; i<self.html5PoolSize; i++) {
while (self._html5AudioPool.length < self.html5PoolSize) {
try {
var audioNode = new Audio();

Expand All @@ -324,6 +339,7 @@
self._releaseHtml5Audio(audioNode);
} catch (e) {
self.noAudio = true;
break;
}
}

Expand Down Expand Up @@ -466,14 +482,20 @@

self._suspendTimer = null;
self.state = 'suspending';
self.ctx.suspend().then(function() {

// Handle updating the state of the audio context after suspending.
var handleSuspension = function() {
self.state = 'suspended';

if (self._resumeAfterSuspend) {
delete self._resumeAfterSuspend;
self._autoResume();
}
});
};

// Either the state gets suspended or it is interrupted.
// Either way, we need to update the state to suspended.
self.ctx.suspend().then(handleSuspension, handleSuspension);
}, 30000);

return self;
Expand All @@ -490,10 +512,10 @@
return;
}

if (self.state === 'running' && self._suspendTimer) {
if (self.state === 'running' && self.ctx.state !== 'interrupted' && self._suspendTimer) {
clearTimeout(self._suspendTimer);
self._suspendTimer = null;
} else if (self.state === 'suspended') {
} else if (self.state === 'suspended' || self.state === 'running' && self.ctx.state === 'interrupted') {
self.ctx.resume().then(function() {
self.state = 'running';

Expand Down Expand Up @@ -557,12 +579,16 @@
self._muted = o.mute || false;
self._loop = o.loop || false;
self._pool = o.pool || 5;
self._preload = (typeof o.preload === 'boolean') ? o.preload : true;
self._preload = (typeof o.preload === 'boolean' || o.preload === 'metadata') ? o.preload : true;
self._rate = o.rate || 1;
self._sprite = o.sprite || {};
self._src = (typeof o.src !== 'string') ? o.src : [o.src];
self._volume = o.volume !== undefined ? o.volume : 1;
self._xhrWithCredentials = o.xhrWithCredentials || false;
self._xhr = {
method: o.xhr && o.xhr.method ? o.xhr.method : 'GET',
headers: o.xhr && o.xhr.headers ? o.xhr.headers : null,
withCredentials: o.xhr && o.xhr.withCredentials ? o.xhr.withCredentials : false,
};

// Setup all other default properties.
self._duration = 0;
Expand Down Expand Up @@ -610,7 +636,7 @@
}

// Load the source file unless otherwise specified.
if (self._preload) {
if (self._preload && self._preload !== 'none') {
self.load();
}

Expand Down Expand Up @@ -721,8 +747,8 @@
// Use the default sound sprite (plays the full audio length).
sprite = '__default';

// Check if there is a single paused sound that isn't ended.
// If there is, play that sound. If not, continue as usual.
// Check if there is a single paused sound that isn't ended.
// If there is, play that sound. If not, continue as usual.
if (!self._playLock) {
var num = 0;
for (var i=0; i<self._sounds.length; i++) {
Expand Down Expand Up @@ -851,7 +877,7 @@
}
};

if (Howler.state === 'running') {
if (Howler.state === 'running' && Howler.ctx.state !== 'interrupted') {
playWebAudio();
} else {
self._playLock = true;
Expand Down Expand Up @@ -1273,8 +1299,8 @@
}

// Make sure the to/from/len values are numbers.
from = parseFloat(from);
to = parseFloat(to);
from = Math.min(Math.max(0, parseFloat(from)), 1);
to = Math.min(Math.max(0, parseFloat(to)), 1);
len = parseFloat(len);

// Set the volume to the start position.
Expand Down Expand Up @@ -1337,8 +1363,11 @@
vol += diff * tick;

// Make sure the volume is in the right bounds.
vol = Math.max(0, vol);
vol = Math.min(1, vol);
if (diff < 0) {
vol = Math.max(to, vol);
} else {
vol = Math.min(to, vol);
}

// Round to within 2 decimal points.
vol = Math.round(vol * 100) / 100;
Expand Down Expand Up @@ -2215,7 +2244,7 @@

// Setup the new audio node.
self._node.src = parent._src;
self._node.preload = 'auto';
self._node.preload = parent._preload === true ? 'auto' : parent._preload;
self._node.volume = volume * Howler.volume();

// Begin loading the source.
Expand Down Expand Up @@ -2324,9 +2353,17 @@
} else {
// Load the buffer from the URL.
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.withCredentials = self._xhrWithCredentials;
xhr.open(self._xhr.method, url, true);
xhr.withCredentials = self._xhr.withCredentials;
xhr.responseType = 'arraybuffer';

// Apply any custom headers to the request.
if (self._xhr.headers) {
Object.keys(self._xhr.headers).forEach(function(key) {
xhr.setRequestHeader(key, self._xhr.headers[key]);
});
}

xhr.onload = function() {
// Make sure we get a successful response back.
var code = (xhr.status + '')[0];
Expand Down Expand Up @@ -2450,7 +2487,7 @@
var version = appVersion ? parseInt(appVersion[1], 10) : null;
if (iOS && version && version < 9) {
var safari = /safari/.test(Howler._navigator && Howler._navigator.userAgent.toLowerCase());
if (Howler._navigator && Howler._navigator.standalone && !safari || Howler._navigator && !Howler._navigator.standalone && !safari) {
if (Howler._navigator && !safari) {
Howler.usingWebAudio = false;
}
}
Expand Down Expand Up @@ -2482,28 +2519,28 @@
exports.Howl = Howl;
}

// Define globally in case AMD is not available or unused.
if (typeof window !== 'undefined') {
window.HowlerGlobal = HowlerGlobal;
window.Howler = Howler;
window.Howl = Howl;
window.Sound = Sound;
} else if (typeof global !== 'undefined') { // Add to global in Node.js (for testing, etc).
// Add to global in Node.js (for testing, etc).
if (typeof global !== 'undefined') {
global.HowlerGlobal = HowlerGlobal;
global.Howler = Howler;
global.Howl = Howl;
global.Sound = Sound;
} else if (typeof window !== 'undefined') { // Define globally in case AMD is not available or unused.
window.HowlerGlobal = HowlerGlobal;
window.Howler = Howler;
window.Howl = Howl;
window.Sound = Sound;
}
})();


/*!
* Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
*
* howler.js v2.1.3
* howler.js v2.2.0
* howlerjs.com
*
* (c) 2013-2019, James Simpson of GoldFire Studios
* (c) 2013-2020, James Simpson of GoldFire Studios
* goldfirestudios.com
*
* MIT License
Expand Down
4 changes: 2 additions & 2 deletions dist/howler.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit a093f49

Please sign in to comment.