[mediacapture-main] enumerateDevices() should request permission (#874)

bradisbell has just created a new issue for https://github.com/w3c/mediacapture-main:

== enumerateDevices() should request permission ==
Currently, to get a media device list we must first make a call to `getUserMedia()`.  This creates UX headaches for use cases where the user needs to pick a device first, and capture from it second.  The current flow looks like this:

1. Application awaits `getUserMedia()` before calling `enumerateDevices()`.
2. User is confused about why the application is requesting a camera and/or microphone, and hopefully approves the request.
3. Application receives the stream from `getUserMedia()`.
4. Application stops all tracks.
5. Application proceeds with `enumerateDevices()`, and shows the user a selection of devices to choose from.
6. User chooses what they want.
7. Application makes final call to `getUserMedia()` to get the stream.

What would be more desirable:

1. Application awaits `enumerateDevices()`.
2. User is prompted to approve access to cameras and/or microphones, and hopefully approves.
3. Application shows a user a selection of devices to choose from.
4. User chooses what they want.
5. Application calls `getUserMedia()` and gets a stream, without requiring additional approval from the user.

In other words, if the browsing context doesn't yet have audio/video capture permission before calling `enumerateDevices()`, that permission should be requested before `enumerateDevices()` resolves.  And, the same permission gate for `getUserMedia()` should be used, so that if/when we eventually do call `getUserMedia()`, it's already been approved.

`enumerateDevices()` is already promise-based, so this seems mostly compatible with existing APIs.

Ideally, `enumerateDevices()` would also contain a filter option (https://github.com/w3c/mediacapture-main/issues/522) so that if an application only needed audio or video permission, they could request just what is needed.

This type of flow is important, particularly for applications where several tracks are used simultaneously.  I understand in the past that there was a desire to have the user agent control device selection, but this is not a good user experience for anything outside of the a basic single-stream video conferencing application.



Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/874 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 23 March 2022 22:17:14 UTC