|
1 | 1 | /*!
|
2 |
| - * howler.js v2.1.1 |
| 2 | + * howler.js v2.1.2 |
3 | 3 | * howlerjs.com
|
4 | 4 | *
|
5 |
| - * (c) 2013-2018, James Simpson of GoldFire Studios |
| 5 | + * (c) 2013-2019, James Simpson of GoldFire Studios |
6 | 6 | * goldfirestudios.com
|
7 | 7 | *
|
8 | 8 | * MIT License
|
|
282 | 282 | _unlockAudio: function() {
|
283 | 283 | var self = this || Howler;
|
284 | 284 |
|
285 |
| - // Only run this on certain browsers/devices. |
286 |
| - var shouldUnlock = /iPhone|iPad|iPod|Android|BlackBerry|BB10|Silk|Mobi|Chrome|Safari/i.test(self._navigator && self._navigator.userAgent); |
287 |
| - if (self._audioUnlocked || !self.ctx || !shouldUnlock) { |
| 285 | + // Only run this if Web Audio is supported and it hasn't already been unlocked. |
| 286 | + if (self._audioUnlocked || !self.ctx) { |
288 | 287 | return;
|
289 | 288 | }
|
290 | 289 |
|
|
314 | 313 | // This must occur before WebAudio setup or the source.onended
|
315 | 314 | // event will not fire.
|
316 | 315 | for (var i=0; i<self.html5PoolSize; i++) {
|
317 |
| - var audioNode = new Audio(); |
| 316 | + try { |
| 317 | + var audioNode = new Audio(); |
318 | 318 |
|
319 |
| - // Mark this Audio object as unlocked to ensure it can get returned |
320 |
| - // to the unlocked pool when released. |
321 |
| - audioNode._unlocked = true; |
| 319 | + // Mark this Audio object as unlocked to ensure it can get returned |
| 320 | + // to the unlocked pool when released. |
| 321 | + audioNode._unlocked = true; |
322 | 322 |
|
323 |
| - // Add the audio node to the pool. |
324 |
| - self._releaseHtml5Audio(audioNode); |
| 323 | + // Add the audio node to the pool. |
| 324 | + self._releaseHtml5Audio(audioNode); |
| 325 | + } catch (e) { |
| 326 | + self.noAudio = true; |
| 327 | + } |
325 | 328 | }
|
326 | 329 |
|
327 | 330 | // Loop through any assigned audio nodes and unlock them.
|
|
934 | 937 | }
|
935 | 938 | };
|
936 | 939 |
|
| 940 | + // If this is streaming audio, make sure the src is set and load again. |
| 941 | + if (node.src === 'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA') { |
| 942 | + node.src = self._src; |
| 943 | + node.load(); |
| 944 | + } |
| 945 | + |
937 | 946 | // Play immediately if ready, or wait for the 'canplaythrough'e vent.
|
938 | 947 | var loadedNoReadyState = (window && window.ejecta) || (!node.readyState && Howler._navigator.isCocoonJS);
|
939 | 948 | if (node.readyState >= 3 || loadedNoReadyState) {
|
|
1084 | 1093 | } else if (!isNaN(sound._node.duration) || sound._node.duration === Infinity) {
|
1085 | 1094 | sound._node.currentTime = sound._start || 0;
|
1086 | 1095 | sound._node.pause();
|
| 1096 | + |
| 1097 | + // If this is a live stream, stop download once the audio is stopped. |
| 1098 | + if (sound._node.duration === Infinity) { |
| 1099 | + self._clearSound(sound._node); |
| 1100 | + } |
1087 | 1101 | }
|
1088 | 1102 | }
|
1089 | 1103 |
|
|
1699 | 1713 | // Remove the source or disconnect.
|
1700 | 1714 | if (!self._webAudio) {
|
1701 | 1715 | // Set the source to 0-second silence to stop any downloading (except in IE).
|
1702 |
| - var checkIE = /MSIE |Trident\//.test(Howler._navigator && Howler._navigator.userAgent); |
1703 |
| - if (!checkIE) { |
1704 |
| - sounds[i]._node.src = 'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA'; |
1705 |
| - } |
| 1716 | + self._clearSound(sounds[i]._node); |
1706 | 1717 |
|
1707 | 1718 | // Remove any event listeners.
|
1708 | 1719 | sounds[i]._node.removeEventListener('error', sounds[i]._errorFn, false);
|
|
2120 | 2131 | node.bufferSource = null;
|
2121 | 2132 |
|
2122 | 2133 | return self;
|
| 2134 | + }, |
| 2135 | + |
| 2136 | + /** |
| 2137 | + * Set the source to a 0-second silence to stop any downloading (except in IE). |
| 2138 | + * @param {Object} node Audio node to clear. |
| 2139 | + */ |
| 2140 | + _clearSound: function(node) { |
| 2141 | + var checkIE = /MSIE |Trident\//.test(Howler._navigator && Howler._navigator.userAgent); |
| 2142 | + if (!checkIE) { |
| 2143 | + node.src = 'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA'; |
| 2144 | + } |
2123 | 2145 | }
|
2124 | 2146 | };
|
2125 | 2147 |
|
|
2479 | 2501 | /*!
|
2480 | 2502 | * Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
|
2481 | 2503 | *
|
2482 |
| - * howler.js v2.1.1 |
| 2504 | + * howler.js v2.1.2 |
2483 | 2505 | * howlerjs.com
|
2484 | 2506 | *
|
2485 |
| - * (c) 2013-2018, James Simpson of GoldFire Studios |
| 2507 | + * (c) 2013-2019, James Simpson of GoldFire Studios |
2486 | 2508 | * goldfirestudios.com
|
2487 | 2509 | *
|
2488 | 2510 | * MIT License
|
|
0 commit comments