When I run navigator.mediaDevices.enumerateDevices()
in chrome and I have no input devices connected, it returns only the output audio deviceInfo. When I do it in Firefox it always returns a few audio input devices that are system audio. How can I know if that input device is an external one?
Thanks.
The way to identify external devices with enumerateDevices()
is to filter out internal ones by label
. And what is left is external. Device list will contain device in format like this:
InputDeviceInfo
deviceId: "9d6e3ef425928764340c9927aca8ed229c0133f52b13e503c6d1726750fbdb02"
groupId: "2e16224d6094a619c3dcc965a83d5c64d7d9020ebe8fda00182bb482bb9cb84b"
kind: "audioinput"
label: "MacBook Pro Microphone (Built-in)"
Built-in means this is an internal device. For more information look in here.