zxing-js / ngx-scanner

Angular QR code, Barcode, DataMatrix, scanner component using ZXing.
https://zxing-js.github.io/ngx-scanner/
MIT License
639 stars 227 forks source link

Camera not opening in Samsung Galaxy s20 Plus Chrome. #329

Closed Sonik20 closed 3 years ago

Sonik20 commented 4 years ago

The camera for the QR Code scanning is not opening up in Samsung Galaxy s20 Plus on google chrome. I am selecting back camera by default. It works fine in Firefox.

s20plus

Same thing works in s20.

I am using ngx-scanner 3.0.0

Error shows: Uncaught (in promise): NotReadableError: Could not start video source

zzlalani commented 4 years ago

Same issue with my Samsung s20 plus, tried with Chrome and Samsung Internet, works ok with Samsung s10

Sonik20 commented 4 years ago

Hey @zzlalani ,

The problem in our code was that, we were by default selecting one back camera, but in the case of S20 Plus it was not working may be it can be a tele lens or micro lens.

So we have added a feature of switching the lens, so user will be able to switch lens if one does not work.

Hope this helps !

abhijeet-pandhe commented 4 years ago

@Sonik20 were you able to resolve this issue? Cause I am facing the same issue on Samsung Galaxy s20 Plus Chrome. And could you also mention what tool are you using to test the ngx-scanner on different mobile devices?

Sonik20 commented 4 years ago

@Naruto248 We were able to find the work around for this, like i mentioned in the previous comment we gave user the option to switch the lens aka camera, so that worked.

We are using BrowserStack for testing on different mobile devices.

zzlalani commented 4 years ago

Sorry but this solution didnt work for me also you can check there demo where they have opt to change the lens its not working either on s20 plus.

perotom commented 4 years ago

The demo also doesn't work for me with s20 plus in chrome. I am using v3.0.1 with Angular 10.

Rusware commented 3 years ago

I was finally able to access the back camera on the S20 plus, with the following Angular code.

let backCams = this.availableDevices.filter((c) => c.label.includes('back')); if (backCams.length > 0) { this.currentDevice = backCams[backCams.length - 1]; } else { this.currentDevice = this.availableDevices[0]); }

jennypabonup commented 3 years ago

In some android devices we are getting the same problems whith canera preview, but we are using AngularJs and ngx-scanner 2.0.1

It happens for example on Samsung Note 10 Plus and Samsung A70.

When open by first time it works fine, but second chance back camera fix at blanks. I debugged on chrome and found that zxScanner.camerasFound only returns 2 cameras frontal and only one back. I suspect is about the lens, such as issue #247

Any idea?

nyl162 commented 3 years ago

Tried to put a delay it seems to work for me.

Tested on Note10 via ngrok with chrome://inspect.

ngOnInit() {
  this.scanner.camerasFound.pipe(
      take(1)
      ,delay(100)
      ,concatMap(devices =>{
        if (devices.length > 1){
          this.scanner.device = devices[devices.length -1]
        }
        return devices
      })
    ).subscribe(result=>{
      this.scanner.enable = true
    })
}
odahcam commented 3 years ago

Hey guys, I hope we can move this discussion to #247. If the workarounds in here didn't satisfy you, please try some in #365 or search some other issues because there's lot of content in here. Thanks!