w3c / mediacapture-output

API to manage the rendering of audio on any audio output device
https://w3c.github.io/mediacapture-output/
Other
26 stars 25 forks source link

Persisting deviceIds Across Sessions #127

Closed Jamie0 closed 6 months ago

Jamie0 commented 2 years ago

I develop web applications used by broadcasters. For many of our users, the ability to use multiple audio outputs simultaneously is crucial.

In the current version of the spec, selectAudioOutput doesn't appear to be designed to allow an application to persistently store the deviceId e.g. as a preference.

According to the spec, if I call selectAudioOutput and provide a deviceId that was previously authorised by the user, the user agent may decide to re-authorise this, without prompting the user to select an output device.

In Firefox's current implementation, the user agent does not do this, and every time the user launches the application they need to re-select audio outputs.

Appreciating this is an implementation decision at Mozilla, I don't feel like this specification is really designed to account for scenarios like I've described that are common in the broadcast world. By requiring the browser persist explicitlyGrantedAudioOutputDevices, this would immediately solve this issue.

I note that other Web Audio specs, such as getUserMedia and WebMidi, are not as restrictive in prohibiting access to a previously authorised device.

jan-ivar commented 6 months ago

Firefox fixed this in bug 1712892. Here's a demo page. This is definitely a use case the spec wants to solve.

By requiring the browser persist explicitlyGrantedAudioOutputDevices, this would immediately solve this issue.

I think the gold standard here is getUserMedia, which also shies away from requiring persistence. The MAY language reflects the user agent ultimately being in charge of this decision for privacy reasons, e.g. if cookies are cleared. Therefore a web page can never rely on there not being a prompt.