increpare / PuzzleScript

Open Source HTML5 Puzzle Game Engine
MIT License
903 stars 159 forks source link

Chrome autoplay restrictions kill all audio in PuzzleScript games #438

Closed chz16 closed 3 years ago

chz16 commented 6 years ago

Just making an official ticket for this thing, oh boy.

Chrome now doesn't let Web Audio contexts make noises until the user "interacts" with the page (which seems to mean a click or touch): https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

So audio no longer works in games on puzzlescript.net and exported standalone files that aren't wrapped in a click barrier, because it sets up the audio context before the user clicks anything. And the user may not ever click anything, so there may never be sound!

I guess the approaches would be to:

  1. Add a click-to-play screen at the start of the game and then either create the context or .resume() it after that

  2. Run the game as normal but add a message that sound won't play until the user clicks, and add a handler on the first click that sets up the audio context if they ever do

Seems to be related to #419, except everywhere now

chz16 commented 6 years ago

This has apparently been undone in the latest version of Chrome, but will be reapplied in version 70 (October): https://bugs.chromium.org/p/chromium/issues/detail?id=840866#c103

increpare commented 3 years ago

all good now I think