Audio Session API
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Want more browser support for this feature? Tell us why.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The Audio Session API provides a mechanism for web applications to control how their audio interacts with other audio playing on a device.
Concepts and usage
People increasingly consume media through the web: it is now a primary channel for accessing audio and video content. However, media on the web often lacks seamless integration with underlying platforms. The Audio Session API addresses this gap by allowing developers to specify how the audio produced by their web applications interacts with audio from other applications on the device — for example, playing along with other audio, ducking it (reducing its volume), or pausing it so their audio can play on its own.
A web page can perform audio processing in various ways using APIs such as HTMLMediaElement and the Web Audio API. An audio session represents the aggregated audio produced by a web page, enabling it to express the general nature of its audio output.
Audio session types
The API supports several audio session types, which specify the type of audio an application is producing:
"auto"— The default. The user agent automatically chooses the best type based on the audio APIs being used."playback"— For media playback such as music or video. This type should not mix with other audio playback."transient"— For short sounds like notifications. This type usually plays on top of other audio."transient-solo"— For audio that should play exclusively, pausing all other audio (such as voice prompts)."ambient"— For audio that can mix with other audio sources."play-and-record"— For applications that both play and record audio, such as video conferencing.