|
573 | 573 | init: function(o) { |
574 | 574 | var self = this; |
575 | 575 |
|
576 | | - // If we don't have an AudioContext created yet, run the setup. |
577 | | - if (!Howler.ctx) { |
578 | | - setupAudioContext(); |
579 | | - } |
580 | | - |
581 | 576 | // Setup user-defined default properties. |
582 | 577 | self._autoplay = o.autoplay || false; |
583 | 578 | self._format = (typeof o.format !== 'string') ? o.format : [o.format]; |
|
596 | 591 | withCredentials: o.xhr && o.xhr.withCredentials ? o.xhr.withCredentials : false, |
597 | 592 | }; |
598 | 593 |
|
| 594 | + if (!self._html5) { |
| 595 | + // If we're not forcing HTML5 and we don't have an AudioContext created yet, run the setup. |
| 596 | + if (!Howler.ctx) { |
| 597 | + // sets Howler.usingWebAudio |
| 598 | + setupAudioContext(); |
| 599 | + } |
| 600 | + } else { |
| 601 | + Howler.usingWebAudio = false; |
| 602 | + } |
| 603 | + self._webAudio = Howler.usingWebAudio; |
| 604 | + |
599 | 605 | // Setup all other default properties. |
600 | 606 | self._duration = 0; |
601 | 607 | self._state = 'unloaded'; |
|
620 | 626 | self._onunlock = o.onunlock ? [{fn: o.onunlock}] : []; |
621 | 627 | self._onresume = []; |
622 | 628 |
|
623 | | - // Web Audio or HTML5 Audio? |
624 | | - self._webAudio = Howler.usingWebAudio && !self._html5; |
625 | | - |
626 | 629 | // Automatically try to enable audio. |
627 | 630 | if (typeof Howler.ctx !== 'undefined' && Howler.ctx && Howler.autoUnlock) { |
628 | 631 | Howler._unlockAudio(); |
|
2167 | 2170 | var self = this; |
2168 | 2171 | var isIOS = Howler._navigator && Howler._navigator.vendor.indexOf('Apple') >= 0; |
2169 | 2172 |
|
| 2173 | + if (!node.bufferSource) { |
| 2174 | + return self; |
| 2175 | + } |
| 2176 | + |
2170 | 2177 | if (Howler._scratchBuffer && node.bufferSource) { |
2171 | 2178 | node.bufferSource.onended = null; |
2172 | 2179 | node.bufferSource.disconnect(0); |
|
2543 | 2550 |
|
2544 | 2551 | // Create and expose the master GainNode when using Web Audio (useful for plugins or advanced usage). |
2545 | 2552 | if (Howler.usingWebAudio) { |
| 2553 | + // note: this part breaks iOS 13.3+ ControlCenter notification |
2546 | 2554 | Howler.masterGain = (typeof Howler.ctx.createGain === 'undefined') ? Howler.ctx.createGainNode() : Howler.ctx.createGain(); |
2547 | 2555 | Howler.masterGain.gain.setValueAtTime(Howler._muted ? 0 : Howler._volume, Howler.ctx.currentTime); |
2548 | 2556 | Howler.masterGain.connect(Howler.ctx.destination); |
|
3099 | 3107 | panningModel: typeof o.panningModel !== 'undefined' ? o.panningModel : pa.panningModel |
3100 | 3108 | }; |
3101 | 3109 |
|
3102 | | - // Update the panner values or create a new panner if none exists. |
| 3110 | + // Create a new panner node if one doesn't already exist. |
3103 | 3111 | var panner = sound._panner; |
3104 | | - if (panner) { |
3105 | | - panner.coneInnerAngle = pa.coneInnerAngle; |
3106 | | - panner.coneOuterAngle = pa.coneOuterAngle; |
3107 | | - panner.coneOuterGain = pa.coneOuterGain; |
3108 | | - panner.distanceModel = pa.distanceModel; |
3109 | | - panner.maxDistance = pa.maxDistance; |
3110 | | - panner.refDistance = pa.refDistance; |
3111 | | - panner.rolloffFactor = pa.rolloffFactor; |
3112 | | - panner.panningModel = pa.panningModel; |
3113 | | - } else { |
| 3112 | + if (!panner) { |
3114 | 3113 | // Make sure we have a position to setup the node with. |
3115 | 3114 | if (!sound._pos) { |
3116 | 3115 | sound._pos = self._pos || [0, 0, -0.5]; |
3117 | 3116 | } |
3118 | 3117 |
|
3119 | 3118 | // Create a new panner node. |
3120 | 3119 | setupPanner(sound, 'spatial'); |
| 3120 | + panner = sound._panner |
3121 | 3121 | } |
| 3122 | + |
| 3123 | + // Update the panner values or create a new panner if none exists. |
| 3124 | + panner.coneInnerAngle = pa.coneInnerAngle; |
| 3125 | + panner.coneOuterAngle = pa.coneOuterAngle; |
| 3126 | + panner.coneOuterGain = pa.coneOuterGain; |
| 3127 | + panner.distanceModel = pa.distanceModel; |
| 3128 | + panner.maxDistance = pa.maxDistance; |
| 3129 | + panner.refDistance = pa.refDistance; |
| 3130 | + panner.rolloffFactor = pa.rolloffFactor; |
| 3131 | + panner.panningModel = pa.panningModel; |
3122 | 3132 | } |
3123 | 3133 | } |
3124 | 3134 |
|
|
0 commit comments