Skip to content

Commit 949aee0

Browse files
committed
Fix resuming Web Audio in iOS 17 and 18
1 parent 9e07ba3 commit 949aee0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/sound/SoundManager.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,12 +848,24 @@ Phaser.SoundManager.prototype = {
848848
*/
849849
gameResumed: function ()
850850
{
851-
this.resumeWebAudio();
852-
853851
if (this.muteOnPause)
854852
{
855853
this.unsetMute();
856854
}
855+
856+
if (this.usingWebAudio && this.context.state !== 'running')
857+
{
858+
var _this = this;
859+
860+
// Needed to handle resuming audio on iOS17/iOS18+ if you hide the browser, press the home button, etc. <https://github.com/phaserjs/phaser/issues/6829>
861+
setTimeout(function ()
862+
{
863+
if (!_this.context) { return; }
864+
865+
_this.context.suspend();
866+
_this.context.resume();
867+
}, 100);
868+
}
857869
},
858870

859871
/**

0 commit comments

Comments
 (0)