id1945 / ngx-scanner-qrcode

This library is built to provide a solution scanner QR code. This library takes in raw images and will locate, extract and parse any QR code found within.
https://id1945.github.io/ngx-scanner-qrcode
GNU Lesser General Public License v2.1
54 stars 28 forks source link

ERROR TypeError: Cannot read properties of undefined (reading 'getUserMedia') #39

Closed victor-hpm closed 1 year ago

victor-hpm commented 1 year ago

I am using the library in angular 16.1.0 but when developing locally there is no problem with the permissions to use the camera, the problem is when it is deployed and it needs to access the device's camera and it does not request permissions, it stays in black screen and send this error.

escaner.component.html:40 ERROR TypeError: Cannot read properties of undefined (reading 'getUserMedia') at NgxScannerQrcodeComponent.safariWebRTC (ngx-scanner-qrcode.mjs:980:32) at NgxScannerQrcodeComponent.start (ngx-scanner-qrcode.mjs:707:18) at EscanerComponent.handle (escaner.component.ts:68:17) at EscanerComponent_Template_button_click_26_listener (escaner.component.html:40:140) at executeListenerWithErrorHandling (core.mjs:15786:16) at wrapListenerIn_markDirtyAndPreventDefault (core.mjs:15819:22) at HTMLButtonElement. (platform-browser.mjs:665:17) at _ZoneDelegate.invokeTask (zone.js:402:31) at core.mjs:25998:55 at AsyncStackTaggingZoneSpec.onInvokeTask (core.mjs:25998:36)

id1945 commented 1 year ago

@victor-hpm This error is because the getUserMedia() method does not actually exist in navigator.mediaDevices. You need to check the condition exists then allow the camera to start.

victor-hpm commented 1 year ago

ok found out, in the end the problem was the security protocol since I was using http and https is required to be able to access the resources, thanks for the prompt response and the library is great...