Skip to content

Fix iOS control center notification in html5 mode #1530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/howler.core.min.js

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions dist/howler.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,6 @@
init: function(o) {
var self = this;

// If we don't have an AudioContext created yet, run the setup.
if (!Howler.ctx) {
setupAudioContext();
}

// Setup user-defined default properties.
self._autoplay = o.autoplay || false;
self._format = (typeof o.format !== 'string') ? o.format : [o.format];
Expand All @@ -596,6 +591,17 @@
withCredentials: o.xhr && o.xhr.withCredentials ? o.xhr.withCredentials : false,
};

if (!self._html5) {
// If we're not forcing HTML5 and we don't have an AudioContext created yet, run the setup.
if (!Howler.ctx) {
// sets Howler.usingWebAudio
setupAudioContext();
}
} else {
Howler.usingWebAudio = false;
}
self._webAudio = Howler.usingWebAudio;

// Setup all other default properties.
self._duration = 0;
self._state = 'unloaded';
Expand All @@ -620,9 +626,6 @@
self._onunlock = o.onunlock ? [{fn: o.onunlock}] : [];
self._onresume = [];

// Web Audio or HTML5 Audio?
self._webAudio = Howler.usingWebAudio && !self._html5;

// Automatically try to enable audio.
if (typeof Howler.ctx !== 'undefined' && Howler.ctx && Howler.autoUnlock) {
Howler._unlockAudio();
Expand Down Expand Up @@ -2543,6 +2546,7 @@

// Create and expose the master GainNode when using Web Audio (useful for plugins or advanced usage).
if (Howler.usingWebAudio) {
// note: this part breaks iOS 13.3+ ControlCenter notification
Howler.masterGain = (typeof Howler.ctx.createGain === 'undefined') ? Howler.ctx.createGainNode() : Howler.ctx.createGain();
Howler.masterGain.gain.setValueAtTime(Howler._muted ? 0 : Howler._volume, Howler.ctx.currentTime);
Howler.masterGain.connect(Howler.ctx.destination);
Expand Down
2 changes: 1 addition & 1 deletion dist/howler.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"url": "git://github.com/goldfire/howler.js.git"
},
"scripts": {
"build": "VERSION=`printf 'v' && node -e 'console.log(require(\"./package.json\").version)'` && sed -i '' '2s/.*/ * howler.js '\"$VERSION\"'/' src/howler.core.js && sed -i '' '4s/.*/ * howler.js '\"$VERSION\"'/' src/plugins/howler.spatial.js && uglifyjs --preamble \"/*! howler.js $VERSION | (c) 2013-2020, James Simpson of GoldFire Studios | MIT License | howlerjs.com */\" src/howler.core.js -c -m --screw-ie8 -o dist/howler.core.min.js && uglifyjs --preamble \"/*! howler.js $VERSION | Spatial Plugin | (c) 2013-2020, James Simpson of GoldFire Studios | MIT License | howlerjs.com */\" src/plugins/howler.spatial.js -c -m --screw-ie8 -o dist/howler.spatial.min.js && awk 'FNR==1{echo \"\"}1' dist/howler.core.min.js dist/howler.spatial.min.js | sed '3s~.*~/*! Spatial Plugin */~' | perl -pe 'chomp if eof' > dist/howler.min.js && awk '(NR>1 && FNR==1){printf (\"\\n\\n\")};1' src/howler.core.js src/plugins/howler.spatial.js > dist/howler.js",
"build": "VERSION=`printf 'v' && node -e 'console.log(require(\"./package.json\").version)'` && sed '2s/.*/ * howler.js '\"$VERSION\"'/' src/howler.core.js && sed '4s/.*/ * howler.js '\"$VERSION\"'/' src/plugins/howler.spatial.js && uglifyjs --preamble \"/*! howler.js $VERSION | (c) 2013-2020, James Simpson of GoldFire Studios | MIT License | howlerjs.com */\" src/howler.core.js -c -m --screw-ie8 -o dist/howler.core.min.js && uglifyjs --preamble \"/*! howler.js $VERSION | Spatial Plugin | (c) 2013-2020, James Simpson of GoldFire Studios | MIT License | howlerjs.com */\" src/plugins/howler.spatial.js -c -m --screw-ie8 -o dist/howler.spatial.min.js && awk 'FNR==1{echo \"\"}1' dist/howler.core.min.js dist/howler.spatial.min.js | sed '3s~.*~/*! Spatial Plugin */~' | perl -pe 'chomp if eof' > dist/howler.min.js && awk '(NR>1 && FNR==1){printf (\"\\n\\n\")};1' src/howler.core.js src/plugins/howler.spatial.js > dist/howler.js",
"release": "VERSION=`printf 'v' && node -e 'console.log(require(\"./package.json\").version)'` && git tag $VERSION && git push && git push origin $VERSION && npm publish"
},
"devDependencies": {
Expand Down
20 changes: 12 additions & 8 deletions src/howler.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,6 @@
init: function(o) {
var self = this;

// If we don't have an AudioContext created yet, run the setup.
if (!Howler.ctx) {
setupAudioContext();
}

// Setup user-defined default properties.
self._autoplay = o.autoplay || false;
self._format = (typeof o.format !== 'string') ? o.format : [o.format];
Expand All @@ -596,6 +591,17 @@
withCredentials: o.xhr && o.xhr.withCredentials ? o.xhr.withCredentials : false,
};

if (!self._html5) {
// If we're not forcing HTML5 and we don't have an AudioContext created yet, run the setup.
if (!Howler.ctx) {
// sets Howler.usingWebAudio
setupAudioContext();
}
} else {
Howler.usingWebAudio = false;
}
self._webAudio = Howler.usingWebAudio;

// Setup all other default properties.
self._duration = 0;
self._state = 'unloaded';
Expand All @@ -620,9 +626,6 @@
self._onunlock = o.onunlock ? [{fn: o.onunlock}] : [];
self._onresume = [];

// Web Audio or HTML5 Audio?
self._webAudio = Howler.usingWebAudio && !self._html5;

// Automatically try to enable audio.
if (typeof Howler.ctx !== 'undefined' && Howler.ctx && Howler.autoUnlock) {
Howler._unlockAudio();
Expand Down Expand Up @@ -2543,6 +2546,7 @@

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