Skip to content

Commit 04e6662

Browse files
Uninenxtrombone
authored andcommitted
Fix iOS control center notification in html5 mode
goldfire#1530
1 parent baa332c commit 04e6662

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/howler.core.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,6 @@
580580
init: function(o) {
581581
var self = this;
582582

583-
// If we don't have an AudioContext created yet, run the setup.
584-
if (!Howler.ctx) {
585-
setupAudioContext();
586-
}
587-
588583
// Setup user-defined default properties.
589584
self._autoplay = o.autoplay || false;
590585
self._format = (typeof o.format !== 'string') ? o.format : [o.format];
@@ -603,6 +598,17 @@
603598
withCredentials: o.xhr && o.xhr.withCredentials ? o.xhr.withCredentials : false,
604599
};
605600

601+
if (!self._html5) {
602+
// If we're not forcing HTML5 and we don't have an AudioContext created yet, run the setup.
603+
if (!Howler.ctx) {
604+
// sets Howler.usingWebAudio
605+
setupAudioContext();
606+
}
607+
} else {
608+
Howler.usingWebAudio = false;
609+
}
610+
self._webAudio = Howler.usingWebAudio;
611+
606612
// Setup all other default properties.
607613
self._duration = 0;
608614
self._state = 'unloaded';
@@ -627,9 +633,6 @@
627633
self._onunlock = o.onunlock ? [{fn: o.onunlock}] : [];
628634
self._onresume = [];
629635

630-
// Web Audio or HTML5 Audio?
631-
self._webAudio = Howler.usingWebAudio && !self._html5;
632-
633636
// Automatically try to enable audio.
634637
if (typeof Howler.ctx !== 'undefined' && Howler.ctx && Howler.autoUnlock) {
635638
Howler._unlockAudio();
@@ -2584,6 +2587,7 @@
25842587

25852588
// Create and expose the master GainNode when using Web Audio (useful for plugins or advanced usage).
25862589
if (Howler.usingWebAudio) {
2590+
// note: this part breaks iOS 13.3+ ControlCenter notification
25872591
Howler.masterGain = (typeof Howler.ctx.createGain === 'undefined') ? Howler.ctx.createGainNode() : Howler.ctx.createGain();
25882592
Howler.masterGain.gain.setValueAtTime(Howler._muted ? 0 : Howler._volume, Howler.ctx.currentTime);
25892593
Howler.masterGain.connect(Howler.ctx.destination);

0 commit comments

Comments
 (0)