The WebAudioSoundManager will now detect if the Audio Context enters a 'suspended' or 'interrupted' state as part of its update loop and if so it'll try to resume the context. This can happen if you change or disable the audio device, such as plugging in headphones with built-in audio drivers then disconnecting them, or swapping tabs on iOS. Fix #5353

This commit is contained in:
Richard Davey 2022-11-22 18:38:49 +00:00
parent ee2b5f5e35
commit 320317c884

View file

@ -345,7 +345,7 @@ var WebAudioSoundManager = new Class({
{
var context = this.context;
if ((context.state === 'suspended' || context.state === 'interrupted') && !this.locked)
if (context && !this.locked && (context.state === 'suspended' || context.state === 'interrupted'))
{
context.resume();
}
@ -367,13 +367,8 @@ var WebAudioSoundManager = new Class({
{
BaseSoundManager.prototype.update.call(this, time, delta);
var context = this.context;
// Resume interrupted audio on iOS
if (context && context.state === 'interrupted')
{
context.resume();
}
this.onFocus();
},
/**