Learn · Web Audio
Why Web Audio goes silent on iPhone, and the fixes
By Anand “Andy” Padia · 30 November 2026 · 5 min read
In short
- On iPhone, Web Audio follows the ringer switch by default. With the phone on silent, your page plays nothing.
- Audio can only start inside a tap, before any await. Resume the context and play a one-sample buffer right there.
- You cannot set volume on an audio element in iOS Safari. Route everything through a GainNode instead.
The first time I tested mutd on an iPhone, nothing played. No error, no warning, the visualiser moving, and silence. The code was fine on every desktop browser. It took four separate fixes to get sound reliably on iOS Safari, and they are all in src/lib/engine.ts.
1. The ringer switch mutes Web Audio
iOS treats Web Audio as “ambient” audio, the same category as game sound effects, so the ring/silent switch mutes it. Plenty of people keep their phones on silent, so for them the page simply never made a sound. Safari 16.4 and later expose the Audio Session API, which lets the page declare that it is a player:
if (navigator.audioSession) {
try { navigator.audioSession.type = "playback"; } catch {}
}With the type set to playback, audio ignores the silent switch, like a music app. The comment in the engine notes the second benefit: it also helps the page keep playing when the screen locks.
2. Start inside the tap, before any await
Mobile browsers only let audio start while a user gesture is “live”. In practice that means synchronously inside the click handler. If you await a fetch first and then call resume(), the gesture has expired and the context stays suspended. So the engine's resume() does its work immediately, with no awaits:
const ctx = this.ensure();
if (ctx.state !== "running") ctx.resume().catch(() => {});
if (!this.unlocked) {
// classic iOS unlock: play one silent sample inside the gesture
const b = ctx.createBuffer(1, 1, ctx.sampleRate);
const src = ctx.createBufferSource();
src.buffer = b;
src.connect(ctx.destination);
src.start(0);
this.unlocked = true;
}Playing a single silent sample inside the gesture is an old trick, and still the most reliable way to get older iOS versions to unlock. After that, sounds can load and start whenever they are ready.
3. Audio element volume is read-only
On iOS, HTMLMediaElement.volume is read-only; setting it does nothing. A mixer that relies on it has sliders that do not work. In mutd every sound, whether synthesised, decoded or streamed, goes through its own GainNode and then a master gain. Gain nodes work everywhere and can ramp smoothly, which is also how sounds fade in over 0.9 seconds instead of popping on.
4. Streaming long files through the graph
Short files are decoded into memory and looped sample-accurately. Long recordings would hold minutes of decoded audio in a phone's memory, so they stream through an <audio> element connected into the graph with createMediaElementSource. For that to work on iOS:
- Set
crossOrigin = "anonymous", or the browser will not let the page process audio from another domain and outputs silence. - Set the
playsinlineattribute. - Call
play()synchronously, still inside the tap, and only then wait for it to start. - If
play()rejects withNotAllowedError, do not retry with a fallback URL: the problem is the gesture, not the file.
Native apps
A browser tab will always have limits in the background. The mutd iOS and Android apps, coming soon, keep playing with the screen locked and work offline. Get notified when they launch.The streamed files have to come from somewhere fast and close to the listener. That is self-hosting audio on a CDN.
Hear it
Everything here is playing in mutd right now.
373 sounds, 23 one-tap moods, no account. Free in your browser; the iOS and Android apps are coming soon.