LazarSoft / jsqrcode

Javascript QRCode scanner
http://www.webqr.com
Apache License 2.0
3.99k stars 1.16k forks source link

Camera does not seems to work anymore with Firefox #80

Open heyfellows opened 6 years ago

heyfellows commented 6 years ago

Hi,

It seems the last version Firefox 58.0.2 (64 bits) is unable to display the video stream in the outdiv. I can't see specific errors in console, except few CSP issues. No problem with Chrome.

Regards.

gxurma commented 6 years ago

Same problem for me. It grabs camera, but no video visible. Also no results shown. FF: 58.0.2 (64 bites)

SvilenStoianov commented 6 years ago

And same issue here. Firefox version 59.0.2 (64-bit)

SvilenStoianov commented 6 years ago

I've notice that online demo here https://webqr.com/ work fine with FF. Then i download main js from here https://webqr.com/webqr.js and put it in my project and now everything work. Need to insert my custom callback again - so if you have some customization in this file you need to do it again or maybe compare will be better option.

anferneemnc commented 6 years ago

In fact, in newest version of Firefox (called Quantum), it uses mediaDevices.getUserMedia instead of mozGetUserMedia. The mozGetUserMedia method doesn't exist anymore.

So here, the simplest solution is, changing the line 135 of jsqrcode/src/qrcode.js by using these codes

if (typeof v.mozSrcObject === "undefined") {
    //for firefox Quantum
    n.mediaDevices.getUserMedia({video: options, audio: false}).then(success).catch(error);
} else {
    n.mozGetUserMedia({video: options, audio: false}, success, error);
}