Re. Chrome AutoPlay Policy Changes.
If you create your
AudioContext
on page load, you’ll have to callresume()
at some time after the user interacted with the page (e.g., user clicked a button). Alternatively, theAudioContext
will be resumed after a user gesture ifstart()
is called on any attached node.
Resume the context from a user gesture
Phaser CE does this automatically, so this is for v2.6.2 only.
var snd = this.sound;
if (snd.usingWebAudio && snd.context.state !== 'running') {
this.input.onDown.addOnce(function () {
snd.context.resume();
});
}
Play a sound from a user gesture
The browser resumes the context automatically.
var audio = this.add.audio('KEY');
this.input.onDown.addOnce(function () {
audio.play();
});
I’m surprise onDown
works for these, but — it seems to.