navigator.audioSession is a read-only property that returns the document’s AudioSession object (MDN). Use it to tell the platform how your page’s audio should coexist with other device audio.
Read the notes below before you rely on this property. Prefer feature detection when support is limited.
Syntax
Use navigator.audioSession. Start with this line.
JavaScript
navigator.audioSession
Call
What it does
navigator.audioSession
Primary signature.
Built into the browser. Read navigator.audioSession on Navigator — no import required.
Library declarations
JavaScript
navigator.audioSession
Parameters
Parameter
Description
"audioSession" in navigator
Required. Feature detect
Return Value
Return Value
Description
*
AudioSession (read-only property)
JavaScript Examples
Example 1 — Feature Detect
Check support and log the current type when available.
JavaScript
if ("audioSession" in navigator) {
console.log("supported");
console.log("type:", navigator.audioSession.type);
} else {
console.log("audioSession missing");
}
audioSession missing
/* or: supported + type: auto */
How It Works
Use in. Safe check before touching the property.
Read type. Default is often "auto".
Fallback. If missing, keep using normal media APIs.
No side effects. Detection alone does not change audio routing.
Example 2 — Set "playback"
Signal music/video-style media before you play.
JavaScript
if ("audioSession" in navigator) {
navigator.audioSession.type = "playback";
console.log("type set to", navigator.audioSession.type);
}
// Then play your media as usual:
// audioElement.play();
Detect first. Skip the assignment when unsupported.
Set type."playback" means long-form media (music/video).
Then play. Start your <audio> / <video> afterward.
Platform decides. Other apps may pause or duck depending on OS policy.
Example 3 — "play-and-record" for Calls
Hint that you need mic capture plus remote audio together.
JavaScript
async function startCallPreview() {
if ("audioSession" in navigator) {
navigator.audioSession.type = "play-and-record";
}
// Pattern only — this demo does not open the mic.
console.log("ready for getUserMedia + remote media");
// const stream = await navigator.mediaDevices.getUserMedia({
// audio: true, video: true
// });
}
startCallPreview();
Set early. Assign type before capture when supported.
Use play-and-record. Matches simultaneous speak + listen.
Then media APIs.getUserMedia / remote streams as usual.
Demo safety. This snippet skips the permission prompt on purpose.
Compatibility
Browser Support
navigator.audioSession is marked Experimental on MDN with limited availability — not Baseline. Support is incomplete across major browsers.
✓ Experimental · Limited
Navigator.audioSession
Returns AudioSession for declaring audio intent (type) and reading session state. Feature-detect; treat as optional enhancement.
LimitedNot Baseline
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
audioSessionCheck MDN
Bottom line: Safe to use behind a feature check as progressive enhancement. Do not require it for core playback or calling — mediaDevices and media elements still work without it.
Frequently Asked Questions
It is a read-only Navigator property that returns the AudioSession object for the current document. You use that object to declare how your page's audio should interact with other audio on the device.
Yes. MDN marks it Experimental and not Baseline (limited availability). Always feature-detect before using it, and check compatibility before production.
Assign navigator.audioSession.type to a string such as "playback", "transient", "transient-solo", "ambient", or "play-and-record". The default is "auto".
For video calls or any flow that needs simultaneous playback and microphone capture. Set the type before starting getUserMedia or remote media when possible.
No. The property is read-only and returns an AudioSession. You change behavior by setting AudioSession.type on that object.
Your audio still works with normal media APIs. The platform simply will not receive your Audio Session type hint. Feature-detect and treat the API as an optional enhancement.