Last week I attended the Web Audio Conference hosted at Ircam in Paris. It was fantastic to hear about novel applications of web audio technology and to experience the many performances, many of which used networking to allow for audience participation through everyone’s own devices. I noticed that many applications showed messages along the lines of “Remember to unmute your phone“, which won’t be any stranger to those familiar with sites using Web Audio API.
We see these displays because iOS users regularly experience no audio when the hardware mute switch is enabled. This switch silences calls but can also affect Web Audio API output. One solution to this problem can be to play a looping silent audio file in an HTMLAudioElement but an alternative solution can be found in the AudioSession specification that the W3C Media Working Group is working on. In this post, we outline how a tiny amount of code can mitigate this annoying experience for iOS users. But first of all, there’s an important caveat which is that the AudioSession API is not at the W3C Recommendation stage even if it offers a solution today.
So here is said solution:
if ('audioSession' in navigator) {
navigator.audioSession.type = 'playback';
}What does this do? It tells the browser what the audio session type should be - in other words, an indication of what audio features might exist on a website. This allows the browser to render the audio on the platform better according to the developer’s intent. There is some documentation for the available types:
enum AudioSessionType {
"auto",
"playback",
"transient",
"transient-solo",
"ambient",
"play-and-record"
};
I haven’t experimented yet with all of these types but playback is a good place to start when your needs are mostly for audio playback. If your audio features might involve microphone usage or audio input then you might wish to explore play-and-record. The default type is auto.
Show description of types available for AudioSession (quoting the spec)
playback- Playback audio, which is used for video or music playback, podcasts, etc. They should not mix with other playback audio. (Maybe) they should pause all other audio indefinitely.
transient- Transient audio, such as a notification ping. They usually should play on top of playback audio (and maybe also "duck" persistent audio).
transient-solo- Transient solo audio, such as driving directions. They should pause/mute all other audio and play exclusively. When a transient-solo audio ended, it should resume the paused/muted audio.
ambient- Ambient audio, which is mixable with other types of audio. This is useful in some special cases such as when the user wants to mix audios from multiple pages.
play-and-record- Play and record audio, which is used for recording audio. This is useful in cases microphone is being used or in video conferencing applications.
auto- Auto lets the user agent choose the best audio session type according the use of audio by the web page. This is the default type of
AudioSession.
According to a comment by a WebKit engineer on this issue in the WebKit bug tracker, the auto type is initially ambient in Safari. This leaves the audio affected by the ringer mute switch and causes all sorts of user confusion and bug reports on projects. Users won’t understand why this is happening as native applications can emit audio regardless of the mute switch and they might not wish to unmute given their preference for the ringer to be muted. From some conversations I’ve had with engineers who use the Web Audio API, many aren’t aware of this. The silent audio file hack likely works because it is simple for the user agent to interpret that music playback will be intended when it sees an audio element.
As of November 2025 the AudioSession API is published as an Editor’s Draft and only Safari has implemented it. The shape and status of the API is liable to change, so we should ensure that it exists on the navigator object so that we don’t cause errors.
So voilà, add those three lines of code to your application and your users may never need to do the iOS unmute dance!