[mediacapture-main] When device is in use, enumerateDevices() does not show alternatives (#911)

ma1hman has just created a new issue for https://github.com/w3c/mediacapture-main:

== When device is in use, enumerateDevices() does not show alternatives ==
I am using GetUserMedia to show available webcams and mics for a video capture tool. This works fine when no devices are in use. For the first time, user is prompted to gain access to camera / mic and then all devices are shown for video and audio. But if that user has forgotten to close Teams or Zoom and goes to view devices, none are shown. I would think that the unused devices would be available. This is the current code I'm using:

navigator.mediaDevices.getUserMedia({audio: true, video: true})
         .then((stream) => {
            navigator.mediaDevices.enumerateDevices().then((devices) => {
                 devices.forEach((device) => {
                    if (device.kind === "videoinput") {
                        addItemToList("video-devices", device.label, device.deviceId);
                    } else if (device.kind === "audioinput") {
                        addItemToList("audio-devices", device.label, device.deviceId);
                    }
                 });
               stream.getTracks().forEach(x => x.stop());
            });
        });

The addItemToList() is just a function to add these to drop down menu to choose before beginning capture. 

Any insight in how to adjust this so that if a device is in use, alternatives are pulled. 

Thanks in advance,
Jason


Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/911 using your GitHub account


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

Received on Wednesday, 19 October 2022 17:42:53 UTC