Browsers block Web Audio from starting until the user interacts with the page. Inside an iframe on a portal, add allow=”autoplay” to the iframe tag and, in your game code, call resume() on the AudioContext after the first click, tap or key press.
At a glance
| Fact | Value | Source |
|---|---|---|
| AudioContext resumes on interaction plus source start | two conditions required | developer.chrome.com |
| Iframe needs autoplay permission attribute | allow=”autoplay” | developers.google.com |
| Muted or zero-volume media generally allowed to autoplay | no interaction needed | developer.mozilla.org |
Web Audio will not start on page load. An AudioContext is resumed automatically only once two things have happened: the user has interacted with the page, and a source node’s start() method has been called (Chrome for Developers). Your code must explicitly call audioContext.resume() after the first click, tap or key press, then start playback. When your game runs inside an iframe on a portal, add the permission on the iframe tag itself: <iframe src="..." allow="autoplay">, otherwise the autoplay permission never reaches your game’s document (Google Ad Placement API docs).
Building the game with an AI coding agent? Playgama MCP gives the agent the developer-cabinet actions – creating the game entry, uploading the build, publishing a sandbox link to playtest – while you or the agent still write the actual autoplay-unlock code.
Practical checklist
- Do not call
start()at boot. Wait for a real user gesture (menu click, tap-to-play button) before creating or resuming the context. - Muted or zero-volume playback is generally allowed without interaction, so a muted intro loop can start immediately; unmute on the first gesture.
- Mobile browsers may also disable programmatic volume control and pre-buffering, so test the unlock on mobile, not just desktop (MDN).
- Engines like Phaser already try to resume the context on the first click/tap; check your engine’s audio docs before writing custom unlock code (Phaser audio docs).
- If you host on your own domain and players arrive via same-origin navigation from a page that already had audio, playback may never be blocked – test on the actual portal iframe, not just your own site.
Sources
- Web Audio, Autoplay Policy and Games – Chrome for Developers
- HTML5 game structure – Ad Placement API
- Autoplay guide for media and Web Audio APIs – MDN
- Audio for Web games – MDN
- Audio – Phaser docs
- Playgama MCP
Related questions
Does muting audio bypass the autoplay block?
Yes – muted or zero-volume media is generally allowed to autoplay without user interaction; unmute the audio after the first click or tap instead.
Why does my game’s audio work standalone but not on a portal?
The portal wraps your game in an iframe. Without allow=”autoplay” on that iframe tag, the autoplay permission does not reach your game’s document.
Do I need web Audio specifically, or does the
Both are subject to autoplay blocking; the same rule applies – playback started without a prior user gesture is generally blocked for any media with audio.
Last updated: 30 September 2026