|
1 | 1 | /*! |
2 | | - * howler.js v2.0.9 |
| 2 | + * howler.js v2.0.10 |
3 | 3 | * howlerjs.com |
4 | 4 | * |
5 | 5 | * (c) 2013-2018, James Simpson of GoldFire Studios |
|
782 | 782 | self._emit('play', sound._id); |
783 | 783 | } |
784 | 784 |
|
| 785 | + // Setting rate before playing won't work in IE, so we set it again here. |
| 786 | + node.playbackRate = sound._rate; |
| 787 | + |
785 | 788 | // If the node is still paused, then we can assume there was a playback issue. |
786 | 789 | if (node.paused) { |
787 | 790 | self._emit('playerror', sound._id, 'Playback was unable to start. This is most commonly an issue ' + |
|
790 | 793 | } |
791 | 794 |
|
792 | 795 | // Setup the end timer on sprites or listen for the ended event. |
793 | | - if (sprite !== '__default') { |
| 796 | + if (sprite !== '__default' || sound._loop) { |
794 | 797 | self._endTimers[sound._id] = setTimeout(self._ended.bind(self, sound), timeout); |
795 | 798 | } else { |
796 | 799 | self._endTimers[sound._id] = function() { |
|
2309 | 2312 | /*! |
2310 | 2313 | * Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported. |
2311 | 2314 | * |
2312 | | - * howler.js v2.0.9 |
| 2315 | + * howler.js v2.0.10 |
2313 | 2316 | * howlerjs.com |
2314 | 2317 | * |
2315 | 2318 | * (c) 2013-2018, James Simpson of GoldFire Studios |
|
2325 | 2328 | // Setup default properties. |
2326 | 2329 | HowlerGlobal.prototype._pos = [0, 0, 0]; |
2327 | 2330 | HowlerGlobal.prototype._orientation = [0, 0, -1, 0, 1, 0]; |
2328 | | - |
| 2331 | + |
2329 | 2332 | /** Global Methods **/ |
2330 | 2333 | /***************************************************************************/ |
2331 | 2334 |
|
|
2373 | 2376 |
|
2374 | 2377 | if (typeof x === 'number') { |
2375 | 2378 | self._pos = [x, y, z]; |
2376 | | - self.ctx.listener.setPosition(self._pos[0], self._pos[1], self._pos[2]); |
| 2379 | + |
| 2380 | + if (typeof self.ctx.listener.positionX !== 'undefined') { |
| 2381 | + self.ctx.listener.positionX.setTargetAtTime(self._pos[0], Howler.ctx.currentTime, 0.1); |
| 2382 | + self.ctx.listener.positionY.setTargetAtTime(self._pos[1], Howler.ctx.currentTime, 0.1); |
| 2383 | + self.ctx.listener.positionZ.setTargetAtTime(self._pos[2], Howler.ctx.currentTime, 0.1); |
| 2384 | + } else { |
| 2385 | + self.ctx.listener.setPosition(self._pos[0], self._pos[1], self._pos[2]); |
| 2386 | + } |
2377 | 2387 | } else { |
2378 | 2388 | return self._pos; |
2379 | 2389 | } |
|
2413 | 2423 |
|
2414 | 2424 | if (typeof x === 'number') { |
2415 | 2425 | self._orientation = [x, y, z, xUp, yUp, zUp]; |
2416 | | - self.ctx.listener.setOrientation(x, y, z, xUp, yUp, zUp); |
| 2426 | + |
| 2427 | + if (typeof self.ctx.listener.forwardX !== 'undefined') { |
| 2428 | + self.ctx.listener.forwardX.setTargetAtTime(x, Howler.ctx.currentTime, 0.1); |
| 2429 | + self.ctx.listener.forwardY.setTargetAtTime(y, Howler.ctx.currentTime, 0.1); |
| 2430 | + self.ctx.listener.forwardZ.setTargetAtTime(z, Howler.ctx.currentTime, 0.1); |
| 2431 | + self.ctx.listener.upX.setTargetAtTime(x, Howler.ctx.currentTime, 0.1); |
| 2432 | + self.ctx.listener.upY.setTargetAtTime(y, Howler.ctx.currentTime, 0.1); |
| 2433 | + self.ctx.listener.upZ.setTargetAtTime(z, Howler.ctx.currentTime, 0.1); |
| 2434 | + } else { |
| 2435 | + self.ctx.listener.setOrientation(x, y, z, xUp, yUp, zUp); |
| 2436 | + } |
2417 | 2437 | } else { |
2418 | 2438 | return or; |
2419 | 2439 | } |
|
2519 | 2539 | } |
2520 | 2540 |
|
2521 | 2541 | if (pannerType === 'spatial') { |
2522 | | - sound._panner.setPosition(pan, 0, 0); |
| 2542 | + sound._panner.positionX.setValueAtTime(pan, Howler.ctx.currentTime); |
| 2543 | + sound._panner.positionY.setValueAtTime(0, Howler.ctx.currentTime); |
| 2544 | + sound._panner.positionZ.setValueAtTime(0, Howler.ctx.currentTime); |
2523 | 2545 | } else { |
2524 | 2546 | sound._panner.pan.setValueAtTime(pan, Howler.ctx.currentTime); |
2525 | 2547 | } |
|
2593 | 2615 | setupPanner(sound, 'spatial'); |
2594 | 2616 | } |
2595 | 2617 |
|
2596 | | - sound._panner.setPosition(x, y, z); |
| 2618 | + sound._panner.positionX.setValueAtTime(x, Howler.ctx.currentTime); |
| 2619 | + sound._panner.positionY.setValueAtTime(y, Howler.ctx.currentTime); |
| 2620 | + sound._panner.positionZ.setValueAtTime(z, Howler.ctx.currentTime); |
2597 | 2621 | } |
2598 | 2622 |
|
2599 | 2623 | self._emit('pos', sound._id); |
|
2671 | 2695 | setupPanner(sound, 'spatial'); |
2672 | 2696 | } |
2673 | 2697 |
|
2674 | | - sound._panner.setOrientation(x, y, z); |
| 2698 | + sound._panner.orientationX.setValueAtTime(x, Howler.ctx.currentTime); |
| 2699 | + sound._panner.orientationY.setValueAtTime(y, Howler.ctx.currentTime); |
| 2700 | + sound._panner.orientationZ.setValueAtTime(z, Howler.ctx.currentTime); |
2675 | 2701 | } |
2676 | 2702 |
|
2677 | 2703 | self._emit('orientation', sound._id); |
|
2711 | 2737 | * with `inverse` and `exponential`. |
2712 | 2738 | * panningModel - ('HRTF' by default) Determines which spatialization algorithm is used to position audio. |
2713 | 2739 | * Can be `HRTF` or `equalpower`. |
2714 | | - * |
| 2740 | + * |
2715 | 2741 | * @return {Howl/Object} Returns self or current panner attributes. |
2716 | 2742 | */ |
2717 | 2743 | Howl.prototype.pannerAttr = function() { |
|
2886 | 2912 | sound._panner.refDistance = sound._pannerAttr.refDistance; |
2887 | 2913 | sound._panner.rolloffFactor = sound._pannerAttr.rolloffFactor; |
2888 | 2914 | sound._panner.panningModel = sound._pannerAttr.panningModel; |
2889 | | - sound._panner.setPosition(sound._pos[0], sound._pos[1], sound._pos[2]); |
2890 | | - sound._panner.setOrientation(sound._orientation[0], sound._orientation[1], sound._orientation[2]); |
| 2915 | + sound._panner.positionX.setValueAtTime(sound._pos[0], Howler.ctx.currentTime); |
| 2916 | + sound._panner.positionY.setValueAtTime(sound._pos[1], Howler.ctx.currentTime); |
| 2917 | + sound._panner.positionZ.setValueAtTime(sound._pos[2], Howler.ctx.currentTime); |
| 2918 | + sound._panner.orientationX.setValueAtTime(sound._orientation[0], Howler.ctx.currentTime); |
| 2919 | + sound._panner.orientationY.setValueAtTime(sound._orientation[1], Howler.ctx.currentTime); |
| 2920 | + sound._panner.orientationZ.setValueAtTime(sound._orientation[2], Howler.ctx.currentTime); |
2891 | 2921 | } else { |
2892 | 2922 | sound._panner = Howler.ctx.createStereoPanner(); |
2893 | 2923 | sound._panner.pan.setValueAtTime(sound._stereo, Howler.ctx.currentTime); |
|
0 commit comments