HOWL_CODER
HOWL_CODER

Reputation: 35

cant use webcam in phone but in pc it works fine

I'm trying to put a QR barcode scanner in my website using Quagga after lots of trying I finally succeeded to put the live reader, its ask for permission to use in the pc but when I'm trying to access it through my phone it doesn't work, and by doesn't work I mean doesn't even ask for permission to open the camera

I am rendering the script tag on the ejs file and it looks something like this:

<script src="js/quagga.min.js"></script>
<script>
Quagga.init({
    inputStream : {
      name : "Live",
      type : "LiveStream",
      target: document.querySelector('#camera')
    },
    decoder : {
      readers : ["code_128_reader"]
    }
  }, function(err) {
      if (err) {
          console.log(err);
          return
      }
      console.log("Initialization finished. Ready to start");
      Quagga.start();
  });
  
  Quagga.onDetected(function(data){
      document.body.appendChild("<h1>"+data.codeResult.code +"</h1>")
  });
</script>

Thanks in advance!

Upvotes: 1

Views: 689

Answers (1)

HOWL_CODER
HOWL_CODER

Reputation: 35

SOLVED!

for the chrome version that is 47+, it seems like you don't have permission to use the camera on unsecure website, and mine was on the localhost. so I got into the chrome flags and inside of that I searched "Insecure origin treated as secure" and then I added my laptop IP and the opened port and it worked!

the "Yahha Udin" question answered by "Kartik Sharma" (link below) helped me solve it.

link: "unsafely-treat-insecure-origin-as-secure" flag is not working on Chrome

Upvotes: 1

Related Questions