we want to use the back camera for scanning, and select the correct back camera - the main camera, and not the wide lens camera.
newer mobile devices (for example, Samsung galaxy s10) have several front and back cameras. when calling enumerateDevices() we get a list of cameras for the front and the back. we want to select the main camera from the list of back cameras. we can use constraints to select the back camera (facing: "environment"), but we don't know how to tell for each device if the camera is the main camera or a wide lens camera.
navigator.mediaDevices.enumerateDevices().then(function (devices) {
for(var i = 0; i < devices.length; i ++){
var device = devices[i];
if (device.kind === 'videoinput') {
//any useful device info here?
}
}
});