ngx-scanner icon indicating copy to clipboard operation
ngx-scanner copied to clipboard

Behaviour when camera is already opened

Open MrLegaropex opened this issue 4 years ago • 1 comments

Let's assume this: I am developing a website which uses one specific camera for the zxing-scanner. Now if i open the same website in another tab/browser and try to access the same camera, which is already getting used, i get the following error: grafik

Now this would be less of a problem if I could simply catch this error or handle it in another way. Unless I am missing something, in the last non-deprecated version (3.0.1) does not allow this, since none of the - events return a value that can be used for this.

Google Chrome version: 87.0.4280.88 Mozilla Firefox version: 84.0.1 Angular version: 11.0.4 @zxing/library version: 0.18.3 @zxing/ngx-scanner version: 3.0.1

MrLegaropex avatar Jan 04 '21 17:01 MrLegaropex

I'm not sure if this is a bug. This will vary from browser to browser and is bit tricky to handle, that's why I never spent time on it. However, you have a few options to handle this issue:

https://github.com/zxing-js/ngx-scanner/blob/42e6ad4f58fd235bd15d688d36050a4ea25fdc01/projects/zxing-scanner/src/lib/zxing-scanner.component.ts#L676-L739

Notice that this code snippet emits some values into some properties you can listen to. That console error message at least served it's purpose of letting you know this problem exists. 😌

odahcam avatar Feb 02 '21 15:02 odahcam