I'm currently working on my little project to Web Scan QR Code. When I use it on my Desktop, the webcam works fine and it can scan the QR Code but I have a problem when I use it on my smartphones. Both Rear & Front camera won't work on smartphones.
My code:
<script>
let scanner = new Instascan.Scanner(
{
video: document.getElementById('preview')
}
);
scanner.addListener('scan', function(content) {
alert('The Content is : ' + content);
window.open(content, "_blank");
});
Instascan.Camera.getCameras().then(cameras => {
if (cameras.length > 0) {
scanner.start(cameras[0]);
} else {
console.error("There is no camera available");
}
});
</script>
So, I even tried to change the index
to 1
but it still doesn't work:
if (cameras.length > 0) {
scanner.start(cameras[1]);
How do I enable the camera on the smartphones? Your help is very appreciated.