- From: youennf via GitHub <sysbot+gh@w3.org>
- Date: Thu, 03 Sep 2020 09:53:00 +0000
- To: public-webrtc-logs@w3.org
I am unclear with some details in your scenario, like whether only one webcam is connected (720p) and web page wants user to connect the 1080p camera. Here is a potential flow: ``` const previousDeviceId = await getDeviceIdFromIDB(); let stream = await navigator.mediaDevices.getUserMedia({ video : { deviceId : previousDeviceId, width : 1920 } }); // Browser will try using the previous device, if not possible, it will try selecting any 1080p camera. if (stream.getVideoTracks()[0].getSettings().width < 1920) { // Chances are high there is no 1080p camera otherwise it would have been selected in the first place. Let's still check just in case. const devices = await navigator.mediaDevices.enumerateDevices(); const newDeviceId = select1080pCamera(devices); if (!deviceId) { // Ask user to connect a 1080p camera through some UI. .... navigator.mediaDevices.ondevicechange = trySelecting1080pCamera; return; } // Optional step: switch immediately to the 1080p camera. It might be bad if the user selected the other camera explicitly through a device picker (say Firefox picker). stream = await navigator.mediaDevices.getUserMedia({ video : { deviceId : newDeviceId, width : 1920 } }); } // Proceed with using the stream ... ``` Another approach: ``` try { const stream = await navigator.mediaDevices.getUserMedia({ video : { deviceId : { exact : await getDeviceIdFromIDB() } } }); stream.getVideoTracks()[0].applyConstraints({ width : 1920 }); return stream; } catch (e) { return navigator.mediaDevices.getUserMedia({ video : { width : 1920 } }) } ``` -- GitHub Notification of comment by youennf Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/709#issuecomment-686381982 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 3 September 2020 09:53:02 UTC