Update WebAudioSoundManager.js

This commit is contained in:
Richard Davey 2021-03-26 10:05:47 +00:00
parent 058e81937b
commit d3d73d4c09

View file

@ -343,7 +343,32 @@ var WebAudioSoundManager = new Class({
{ {
var context = this.context; var context = this.context;
if (context.state === 'suspended' || context.state === 'interrupted' || !this.locked) if ((context.state === 'suspended' || context.state === 'interrupted') && !this.locked)
{
context.resume();
}
},
/**
* Update method called on every game step.
* Removes destroyed sounds and updates every active sound in the game.
*
* @method Phaser.Sound.WebAudioSoundManager#update
* @protected
* @fires Phaser.Sound.Events#UNLOCKED
* @since 3.0.0
*
* @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
* @param {number} delta - The delta time elapsed since the last frame.
*/
update: function (time, delta)
{
BaseSoundManager.prototype.update.call(this, time, delta);
var context = this.context;
// Resume interrupted audio on iOS
if (context && context.state === 'interrupted')
{ {
context.resume(); context.resume();
} }