In latest Samsung s10 and s20 phones, I facing back-camera blocked issue on browser while accessing using navigator.mediaDevices.getUserMedia javascript. But able to access front-camera successfully. These s10 and s20 mobile have 3plus back-cameras.
Note: it worked well on Samsung s9 for both front and back camera, I believe it has single back camera, so no camera access issue in s9.
Below is the simple JS code used to access back and front camera.
navigator.mediaDevices.getUserMedia({
video: {
width: screen.width > ipad_size ? 1280 : { ideal: 640 },
height: screen.width > ipad_size ? 720 : { ideal: 480 },
facingMode: method == 2 ? "user" : { exact: "environment" },
},
})
.then(function (stream){
console.log("Access camera: ");
})
.catch(function (err) {
console.log("Unable to access camera: " + err);
});
is what I recommend.