ONESHOTGEMS

For game developers

Let the player start sound intentionally

A game that assumes sound has started may show a mute icon while remaining silent. Browsers commonly restrict script-initiated audio until a user gesture, and a media play request can reject or resolve after a delay. Design the first interaction to establish the player's audio choice, then update the interface from the actual playback result. This improves predictability and avoids surprising someone with sound they did not expect.

Make sound part of a clear first action

Offer a visible start or sound control that a player can activate. Start or resume the audio context in response to that action, and present the chosen state immediately while handling any rejected playback promise. If sound is optional, let the game proceed silently and make an explicit control available to turn it on later.

Test both a fresh page load and a return from another tab. Try a browser configuration that blocks autoplay, a muted system, and a slow audio asset. Confirm that the game's visual start is not held hostage by an optional sound effect and that the control label stays truthful if audio has not begun.

Keep feedback and audio state aligned

Do not equate a successful call to play() with instant audible output. The promise may settle asynchronously and a browser may ask for permission. Handle rejection, expose a retry action where useful, and do not report an error that implies the whole game has failed when only sound is unavailable.

Separate user preference from runtime permission: a saved mute choice is the player's intent, while whether playback is currently allowed is a browser condition. Test mute, unmute, pause, resume, and scene transitions independently so effects are not accidentally restarted at full volume after a state change.

Questions about browser game audio startup

Can I autoplay game music after the page loads?

Do not assume it will work. Autoplay rules can block audible media and Web Audio started outside user input; offer a deliberate action and handle playback failure.

What should the sound button show if playback is blocked?

Show an honest state such as sound off or an action to enable sound, based on the result you observed. MDN recommends responding to the play() promise instead of assuming playback began.

Sources and further reading

Report a correction · How these guides are made

Follow your curiosity