0

I know there are programmatic ways to request media from another device's camera, but is there any simple way I can access my phone camera from my (localhost) web app?

I connected my phone to my laptop via USB, but it's not showing up on Camera settings

enter image description here

(You can see that my laptop camera is the only option)

I've tried installing an app called Iriun, but it only transfers video to its own desktop app, not to Chrome.

1 Answer 1

0

If you have the Iriun app open on your computer, it will appear as a camera in the browser. You just need to iterate through all of the available cameras.

function getCamAndMics(){
     // List cameras and microphones. in the menu
       
     navigator.mediaDevices.enumerateDevices()
     .then(function(devices) {
         devices.forEach(function(device) {
             console.log(device.kind + ": " + device.label +" id = " + device.deviceId);
             var audioSelect = document.getElementById("audioPicker-select");
             var cameraSelect = document.getElementById("cameraPicker-select");
             if(device.kind=="audioinput"){
                 //add a select to the audio dropdown list
                 var option = document.createElement("option");
                 option.value = device.deviceId;
                 option.text = device.label;
                 audioSelect.appendChild(option);
             }else if(device.kind =="videoinput"){
                 //add a select to the camera dropdown list
                 var option = document.createElement("option");
                 option.value = device.deviceId;
                 option.text = device.label;
                 cameraSelect.appendChild(option);

             }
         });
     })
     .catch(function(err) {
         console.log(err.name + ": " + err.message);
     });


}

You can see this with https://record.a.video - just make sure you have Iriun running on your computer when you use the website. Sample code from https://github.com/dougsillars/recordavideo

You must log in to answer this question.