You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there.. love this little bit of code, super handy. One thing I noticed is that the code doesn't really wait for the getUserMedia() call to complete before calling enumerateDevices().. so my phone wasn't enabling both cameras because I hadn't accepted the use prior to the looping over the enumeration.
I would have created a patch but was messing around so much that the code looks kinda horrible.. instead here's the relevant parts:
functionsuccessCallback(stream){currentStream=stream;video.srcObject=stream;video.play();if(location.href.includes('&debug')){console.log(`stream: ${stream}`);}// PATCH: return the enumerate here as a promise..returnnavigator.mediaDevices.enumerateDevices();}functionerrorCallback(error){window.alert('Error: ',error);}navigator.mediaDevices.getUserMedia({audio: false,video: true}).then(successCallback)// PATCH: so we can then after the prompt, enumerate the devices.then(media_devices=>{media_devices.forEach(media_device=>{if(location.href.includes('&debug')){console.log(media_device);}if(media_device.kind==='videoinput'){cameras=cameras.concat(media_device.deviceId);}})}).catch(errorCallback);
The text was updated successfully, but these errors were encountered:
Hey there.. love this little bit of code, super handy. One thing I noticed is that the code doesn't really wait for the
getUserMedia()
call to complete before callingenumerateDevices()
.. so my phone wasn't enabling both cameras because I hadn't accepted the use prior to the looping over the enumeration.I would have created a patch but was messing around so much that the code looks kinda horrible.. instead here's the relevant parts:
The text was updated successfully, but these errors were encountered: