mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
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:
parent
ee2b5f5e35
commit
320317c884
1 changed files with 2 additions and 7 deletions
|
@ -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();
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue