JavaScript Navigator audioSession Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

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
CallWhat it does
navigator.audioSessionPrimary signature.

Built into the browser. Read navigator.audioSession on Navigator — no import required.

Library declarations
JavaScript
navigator.audioSession

Parameters

ParameterDescription
"audioSession" in navigatorRequired. Feature detect

Return Value

Return ValueDescription
*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");
}
Try It Yourself

How It Works

  1. Use in. Safe check before touching the property.
  2. Read type. Default is often "auto".
  3. Fallback. If missing, keep using normal media APIs.
  4. 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();
Try It Yourself

How It Works

  1. Detect first. Skip the assignment when unsupported.
  2. Set type. "playback" means long-form media (music/video).
  3. Then play. Start your <audio> / <video> afterward.
  4. 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();
Try It Yourself

How It Works

  1. Set early. Assign type before capture when supported.
  2. Use play-and-record. Matches simultaneous speak + listen.
  3. Then media APIs. getUserMedia / remote streams as usual.
  4. Demo safety. This snippet skips the permission prompt on purpose.

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.

Limited Not Baseline
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
audioSession Check 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.

Next: bluetooth

Learn the related Navigator bluetooth property.

bluetooth tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

7 people found this page helpful