Skip to content

Commit

Permalink
Update view-camera.js
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmaris authored Apr 1, 2020
1 parent 7905274 commit 67b7f0f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions view-camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ document.addEventListener('readystatechange', (event) => {
if(location.href.includes('&debug')) {
console.log(`stream: ${stream}`);
}
return navigator.mediaDevices.enumerateDevices();
}

function errorCallback(error) {
Expand All @@ -23,6 +24,16 @@ document.addEventListener('readystatechange', (event) => {

navigator.mediaDevices.getUserMedia({ audio: false, video: true })
.then(successCallback)
.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);

if('mediaDevices' in navigator && 'enumerateDevices' in navigator.mediaDevices) {
Expand Down

0 comments on commit 67b7f0f

Please sign in to comment.