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

The user gets confused because we have to request a camera/microphone stream before we can even prompt them for *which* camera/microphone they want to use.  This isn't a hypothetical... it's a common source of confusion for our users.  And, having to turn around and stop the stream we just opened is a source of further problems.  Webcam light may turn on briefly, then off.  System may run slower for a few seconds.  Sometimes closing and re-opening cameras repeatedly can be problematic.  Having to open a camera before getting a camera list is a hack.  We're forced to use it because of this standard.

> 3. This is not really backward compatible since enumerateDevices is called by many web pages that do not expect user prompts.

Calls to `enumerateDevices()` are basically useless until permission is granted.  And, backwards compatibility on this very API has been broken in the past.  `enumerateDevices()` used to return a full device list, even without permission.  Prompting for permission would have been a better resolution at the time, and I believe it is the best resolution to this problem today.

Regardless, an alternative is to add some other way to request permission as an independent step to capturing or enumerating.  Then, this is solved by something like this:

```
await navigator.mediaDevices.requestUserMediaPermission();
const devices = await navigator.mediaDevices.enumerateDevices();
```



-- 
GitHub Notification of comment by bradisbell
Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/874#issuecomment-1160741102 using your GitHub account


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

Received on Monday, 20 June 2022 18:35:53 UTC