Skip to content

[enhancement] built-in click-to-start in index.html? #20084

Open
@icculus

Description

@icculus

We get bug reports from time to time in SDL, that audio isn't working in Emscripten, and of course the problem is not in SDL or Emscripten, but always that the user needs to interact with the page before the browser will allow audio to play.

While it's not a perfect fit for everything, a common solution in games is to put up a "click/tap here to start!" thing in front of the canvas, so the user has to interact with the page before the code even hits main(), so no Emscripten-specific magic has to go into the app itself to deal with audio management.

It would be extremely helpful if the default index.html that emcc outputs has this click-to-start built in, perhaps gated behind a setting in Module to enable/disable it.

It can be extremely daunting to hook into index.html and Module, especially to C programmers that aren't really familiar with HTML or Javascript, especially since index.html is something that seems to magically appear as linker output to the untrained eyes, so I think it would be super-helpful if Emscripten offered this.

(Failing that, I would also be happy with a page in the documentation that says "here's a barebones template you could paste into your index.html to add click-to-play support, and maybe extend youself to make it fancier if you're up to it.")

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions