tesselode / kira

Library for expressive game audio.
https://crates.io/crates/kira
Apache License 2.0
855 stars 43 forks source link

No sound played on wasm #43

Closed lazytiger closed 1 year ago

lazytiger commented 1 year ago

When I play the sound using AudioManager::play, the console prints the following message:

      The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.

How should I play a sound on wasm? Is there an example?

NiklasEi commented 1 year ago

This is a common issue, because some browsers require a user interaction before you are allowed to play sound. There is a js script you can use to automatically start the audiocontext as soon as the first user interaction happens. See e.g. NiklasEi/bevy_kira_audio#83

lazytiger commented 1 year ago

Thanks for the reply, this approach is much better.