Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome may suspend the Web Audio context absent a user gesture #437

Closed
samme opened this issue Jan 14, 2018 · 2 comments
Closed

Chrome may suspend the Web Audio context absent a user gesture #437

samme opened this issue Jan 14, 2018 · 2 comments

Comments

@samme
Copy link
Collaborator

samme commented Jan 14, 2018

An AudioContext must be created or resumed after the document received a user gesture to enable audio playback.

I get this warning in Chrome Canary (M65) on, eg, http://phaser.io/examples/v2/audio/fade-in (iframe), and on my localhost (no iframe) when I open a game tab in the background and then focus it. But I don't get it when doing the same on https://samme.github.io/phaser-examples-mirror/audio/fade%20in.html. Not sure why.

The audio context is created but with a suspended state. Playback appears to go normally but there's no audio output.

A workaround would be

if (game.sound.usingWebAudio &&
    game.sound.context.state === 'suspended')
{
  game.input.onTap.addOnce(game.sound.context.resume, game.sound.context);
}

Suspended audio context in Chrome

@samme
Copy link
Collaborator Author

samme commented Mar 1, 2018

The AudioContext was not allowed to start. It must be [resumed] (or created) after a user gesture on the page. https://goo.gl/7K7WLu

https://samme.github.io/phaser-examples-mirror/audio/fade%20in.html

@samme samme closed this as completed in 98d49c4 Mar 14, 2018
@samme
Copy link
Collaborator Author

samme commented May 8, 2018

Phaser can try to resume the audio context via mouseout, which is wrong and will fail.

@samme samme reopened this May 8, 2018
@samme samme closed this as completed in 0147198 May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant