← Back to release summary

Audio Output Devices API: setPreferredSinkId()

Category
WebRTC
Type
New or changed feature
Status
In developer trial (Behind a flag) (Chrome In developer trial (Behind a flag))
Intent stage
None

Summary

Adds setPreferredSinkId() to MediaDevices, which enables a top-level frame to override the default audio output device for all audio renderers in the top-level frame and its child frames, including cross-origin child frames. Audio renderers include HTML <media> elements and web audio contexts.

Motivation

Without setPreferredSinkId(), a top-level frame has no mechanism to change the default audio output device in its cross-origin child frames. A top-level frame cannot use setSinkId() in a cross-origin child frame due to security boundaries. Instead, the top-level frame and cross-origin child frame must collaborate using postMessage() to change the audio output device. This limitation leads to an inconsistent, disjointed user experience in composable multimedia apps that include embedded video players and embedded slideshows. Each cross-origin child frame may independently choose the audio output device, potentially causing multiple audio output devices to play at the same time. Similarly, if the top-level frame changes its audio output device, the cross-origin child frame's audio does not change, disrupting the user's expectations for audio playback. Lastly, for developer convenience, when changing audio output, setPreferredSinkId() eliminates the need to call setSinkId() on every audio renderer, including new audio renderers created in the future.

Standards & signals

Docs: https://docs.google.com/document/d/1xVn0VwLa8w7jwXl6aeOfYn0mYK7zEc4pSmHelHAbi2g/edit?usp=sharing

Samples: https://stevebeckermsft.github.io/repro_pages/set_preferred_sink_id/sample.html

Explainers: https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/SetPreferredSinkId/explainer.md

View on chromestatus.com