I write this code in JavaScript in Chrome:
navigator.mediaDevices.enumerateDevices()
.then((list) => {
console.log(list);
});
This outputs a list of media devices like microphones and cameras. Each device is represented as an object with its own deviceId
. But some devices, like one of the microphones in particular, are listed twice. And one time their respective deviceId
is set to 'default'
. What is so special about a one default microphone? And how do I tell which actual deviceId
it has?
I write this code in JavaScript in Chrome:
navigator.mediaDevices.enumerateDevices()
.then((list) => {
console.log(list);
});
This outputs a list of media devices like microphones and cameras. Each device is represented as an object with its own deviceId
. But some devices, like one of the microphones in particular, are listed twice. And one time their respective deviceId
is set to 'default'
. What is so special about a one default microphone? And how do I tell which actual deviceId
it has?
1 Answer
Reset to default 16A deviceId
lets web sites manage which device their user is using. E.g. store it in a cookie to remember the user's preference from last time.
Some browsers (Chrome, Opera) list the same microphone twice, with different ids. In my case:
- Default - Internal Microphone (Built-in)
- Internal Microphone (Built-in)
The former is "the OS default", whatever the end-user has configured in System Preferences/Sound (OSX) or Control Panel/Sound (Windows). The idea is: when recalled from a cookie and used, its id gets you whatever is configured in the OS at the time of use, which may differ from last time.
The latter is always the specific mic. Their groupId
s match; they're the same physical device atm.
The deviceId = "default"
is an oddity of Chrome (and Opera). AFAICT it's a valid id like any other. If you want the other one, pare their groupId
s to find it.
Safari does not do this. Firefox recently stopped doing it (as of version 63).
Cameras are never duplicated in this way.