godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.89k stars 21.04k forks source link

Chrome does not allow applications to play audio #22036

Closed GustavoMarciano closed 5 years ago

GustavoMarciano commented 6 years ago

Godot version: All

OS/device including version: Mobile Browsers

Issue description: Chrome does not allow applications to play HTML5 audio without an explicit "action" by the user but even with user actions no audio is played: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

Minimal reproduction project: https://dexpace.itch.io/ultra-gravity-switch

chandujr commented 5 years ago

I don't think this is a Godot issue. The link you provided clearly says it's a Chrome policy. I don't think any browser today plays audio without user interaction. Developers usually overcome this by placing a button, something like "ENTER", to actually start the game. In that button click listener, just play some click sound or start background music. Any other audio will play from there on.

GustavoMarciano commented 5 years ago

I don't think this is a Godot issue. The link you provided clearly says it's a Chrome policy. I don't think any browser today plays audio without user interaction. Developers usually overcome this by placing a button, something like "ENTER", to actually start the game. In that button click listener, just play some click sound or start background music. Any other audio will play from there on.

Well in Defold engine this is already done in the export.

bojidar-bg commented 5 years ago

Well, adding a hard-to-customize "Run" button to exported games won't be much better IMO.

On the other hand, if HTML5 audio does not play even after interacting with the game, that might be a bug.

GustavoMarciano commented 5 years ago

Well, adding a hard-to-customize "Run" button to exported games won't be much better IMO.

On the other hand, if HTML5 audio does not play even after interacting with the game, that might be a bug.

Then this is a bug and I have no idea how it can be solved, I updated the issue description so it gets less confusing