W3cubDocs

/Web APIs

AudioContext: sinkchange event

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The sinkchange event of the AudioContext interface is fired when the output audio device (and therefore, the AudioContext.sinkId) has changed.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

addEventListener("sinkchange", (event) => { })

onsinkchange = (event) => { }

Event type

Event.

Examples

A sinkchange event listener can be used to report a change of audio output device. Note that if sinkId contains an AudioSinkInfo object, it indicates that the audio has been changed to not play on any output device.

audioCtx.addEventListener("sinkchange", () => {
  if (typeof audioCtx.sinkId === "object" && audioCtx.sinkId.type === "none") {
    console.log("Audio changed to not play on any device");
  } else {
    console.log(`Audio output device changed to ${audioCtx.sinkId}`);
  }
});

See our SetSinkId test example for working code (also check out the source code).

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
sinkchange_event 110 110 No 96 No 110 No 74 No 21.0 110 No

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/sinkchange_event