Bug 1443294 Comment 7 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

### Workaround

For those arriving here looking for a workaround, the spec recommends:

 1. using ideal `deviceId: id` when users come to the site, and
 2. using exact `deviceId: {exact: id}` from your site's camera/mic picker (e.g. typically under a site's ⚙️ settings)

See [Example 6](https://w3c.github.io/mediacapture-main/getusermedia.html#example-6) (use ideal on revisit) and [Example 7](https://w3c.github.io/mediacapture-main/getusermedia.html#example-7) (use exact in device picker) respectively. This gives the best user experience in all browsers. 

Benefits in all browsers:
* (Option 1) On revisits to your site, it's common to try to use the camera the user used last time, but using `ideal` (or plain values) here is better, because they may have removed their device since then, added another, or prefer a different device since they may be in a different circumstance.
 * (Option 2) assumes `getUserMedia` is called in direct response to a user selecting a specific camera or microphone in your interface. It makes sense to use `deviceId: {exact: id}` to control that you only get that particular device successfully, or an error. This avoids accidentally showing the wrong combination of preview and label. — If the request fails you may want to give an error to the user (NotAllowedError = no permission, other errors = this camera is not working), and depending on the specifics of your device switching UI, leave the preview blank or go back to an earlier device or not.


Benefits specific to Firefox which grants per-device permission by default:
 * Option 1 gives users who haven't opted out of prompting a chance to use a different camera this visit, and won't wonder why they're not seeing all their devices listed in the prompt.
 * Option 2 gives sites our simplified permission prompt appearance in Firefox 88+, meant to not compete with in-content device selection.
### Workaround

For those arriving here looking for a workaround, the spec recommends:

 1. using ideal `deviceId: id` when users come to the site, and
 2. using exact `deviceId: {exact: id}` from your site's camera/mic picker (e.g. typically under a site's ⚙️ settings)

See [Example 6](https://w3c.github.io/mediacapture-main/getusermedia.html#example-6) (use ideal on revisit) and [Example 7](https://w3c.github.io/mediacapture-main/getusermedia.html#example-7) (use exact in device picker) respectively. This gives the best user experience in all browsers. 

Benefits in all browsers:
* (Option 1) On revisits to your site, it's common to try to use the camera the user used last time, but using `ideal` (or plain values) here is better, because they may have removed their device since then, added another, or prefer a different device since they may be in a different circumstance.
 * (Option 2) assumes `getUserMedia` is called in direct response to a user selecting a specific camera or microphone in your interface. It makes sense to use `deviceId: {exact: id}` to control that you only get that particular device successfully, or an error. This avoids accidentally showing the wrong combination of preview and label. — If the request fails you may want to give an error to the user (NotAllowedError = no permission, other errors = this camera is not working), and depending on the specifics of your device switching UI, leave the preview blank or go back to an earlier device or not.


Benefits specific to Firefox which grants per-device permission by default:
 * Option 1 gives users who haven't opted out of prompting a chance to use a different camera or microphone this visit, and won't wonder why they're not seeing all their devices listed in the prompt.
 * Option 2 gives sites our simplified permission prompt appearance in Firefox 88+, meant to not compete with in-content device selection.
### Workaround

For those arriving here looking for a workaround, the spec recommends:

 1. using ideal `deviceId: id` when users come to the site, and
 2. using exact `deviceId: {exact: id}` from your site's camera/mic picker (e.g. typically under a site's ⚙️ settings)

See [Example 6](https://w3c.github.io/mediacapture-main/getusermedia.html#example-6) (use ideal on revisit) and [Example 7](https://w3c.github.io/mediacapture-main/getusermedia.html#example-7) (use exact in device picker) respectively. This gives the best user experience in all browsers. 

Benefits in all browsers:
* (Option 1) On revisits to your site, it's common to try to use the camera the user used last time, but using ideal constrains (e.g. `deviceId: id`) here is better, because this allows it to fall back to a different device if the user has removed their device since then, or (in cases where constraints other than `deviceId` are used) added another more fit device.
 * (Option 2) assumes `getUserMedia` is called in direct response to a user selecting a specific camera or microphone in your interface. It makes sense to use `deviceId: {exact: id}` to control that you only get that particular device successfully, or an error. This avoids accidentally showing the wrong combination of preview and label. — If the request fails you may want to give an error to the user (NotAllowedError = no permission, other errors = this camera is not working), and depending on the specifics of your device switching UI, leave the preview blank or go back to an earlier device or not.


Benefits specific to Firefox which grants per-device permission by default:
 * Option 1 gives users who haven't opted out of prompting a chance to use a different camera or microphone this visit, and won't wonder why they're not seeing all their devices listed in the prompt.
 * Option 2 gives sites our simplified permission prompt appearance in Firefox 88+, meant to not compete with in-content device selection.

Back to Bug 1443294 Comment 7