DetectRTC icon indicating copy to clipboard operation
DetectRTC copied to clipboard

Works on the demo site, but not on my app until I found a chrome bug :)

Open Bappy1988 opened this issue 5 years ago • 0 comments

So I've found what appears to be a bug in Chrome. In order to enumerate the list of audio devices, you need to allow access to both your Microphones and your Cameras.

I've just lost an hour trying to figure out why the DetectRTC sample page listed all 10 of my audio input devices but my own app only listed 'Microphone 1'

If you're only interested in capturing audio, you need to request permission for cameras as well as microphones or the list doesn't evaluate properly.

I appreciate that the 'how to fix labels' section does state that you need to make a getUserMedia call, but it doesn't highlight that you need to request video in order to get accurate audio device data.

if (DetectRTC.MediaDevices[0] && DetectRTC.MediaDevices[0].isCustomLabel) {
    // it seems that we did not make getUserMedia request yet
    navigator.mediaDevices.getUserMedia({
        audio: true,
        video: true
    })

could easily be tweaked to make that clear;

if (DetectRTC.MediaDevices[0] && DetectRTC.MediaDevices[0].isCustomLabel) {
    // it seems that we did not make getUserMedia request yet
    navigator.mediaDevices.getUserMedia({
        audio: true,
        video: true //must request video even if you only want audio as chrome will not evaluate audio devices correctly otherwise.
    })

I get this isn't a bug in your project but it's info that would help use it so thought I'd share :)

Bappy1988 avatar Jun 06 '20 14:06 Bappy1988