Audio
Last updated
Was this helpful?
Last updated
Was this helpful?
Legends of Learning has deprecated the audio interfaces we provided in the past.
Instead, developers should treat audio like any other concern, using vanilla JS or Javascript plugins as needed. We recommend (but do not require) for Audio. gives you greater control over sound, as well as reduce the level of complexity of working with cross-browser support of WebAudio. It can be loaded from a CDN or via a package manager like npm.
General Javascript Organization
We suggest script tags after visible content and CSS, to make user-visible aspects load first
We suggest using the defer
and async
attributes of the script tag to make game rendering happen as early as possible. For more information see
For Unity games, it is also acceptable to handle audio within Unity's audio system. Keep in mind that audio in WebGL is handled differently and is more limited than other Unity platforms. For more information see .
For Javascript and Construct2 games, your game still needs to listen for state changes and adjust game sound accordingly.
See or for implementation details.
PlaySound
StopSound
ConfigureSound