Operating systems commonly allow users to specify that audio should be played from speakers, a Bluetooth headset, or some other audio output device. This API allows applications to provide this same functionality from within a web page.
Even if allowed by a permission policy, access to a particular audio output device still requires explicit user permission, as the user may be in a location where playing audio through some output devices is not appropriate.
The API provides the Permissions-Policy
HTTP header for the document.
The selected device then has user permission, allowing it to be enumerated with HTMLMediaElement.setSinkId()
.
Audio devices may arbitrarily connect and disconnect.
Applications that wish to react to this kind of change can listen to the enumerateDevices()
to determine if sinkId
is present in the returned devices.
This might trigger, for example, pausing or unpausing playback.