There's a web page for mobile and from js I can get access to the camera. One case I need to support is when there's no camera. So last week for such case I was getting exception sth like 'Could not start a video source' and added error handler. Today an upload dialog box is opened Now I'm testing it on pc on chrome but soon want to test it on android as well
You can check if any video devices type available or not using enumerateDevices() function available in navigator.
const cameraAvailable = (devices) => {
const videoDevice = devices.filter((d) => d.kind === "videoinput");
if (videoDevice.length > 0) {
console.log("camera available");
return true;
} else {
console.log("No camera available");
return false;
}
};
const getMediaDevices = async () => {
try {
const devices = await navigator.mediaDevices.enumerateDevices();
if(cameraAvailable(devices)){
// handle stuff with camera
}
} catch (error) {
console.log(error);
}
};