NiklasEi/bevy_kira_audio

Support WASM AudioContext autoplay constraints

axelmagn opened this issue · 2 comments

When running bevy as a WASM target, many browsers (such as chrome) require the user to interact with the app before it can play sound. At the moment, the only way to make this play nice with bevy_kira_audio is to perform all initialization of AudioContext before the wasm init() function is called. Currently I have to create a separate static splash screen placeholder that hot-swaps out when wasm init() is called, which is a hassle.

Interacting with web-sys::AudioContext is a fairly well lit path outside of bevy, but I haven't found a way to manage it explicitly from within bevy_kira_audio. It would be nice if bevy_kira_audio was aware of this edge case, and could initialize AudioContext correctly following a user click.

saw that this was addressed in previous (closed) issues.

Might be worth adding to the readme, but closing this issue for now.

For reference, I guess you saw #83

I'll add a note in the readme. Thank you for raising this, it should definitely be mentioned.