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

Cannot start video source

Open cloakapps opened this issue 3 years ago • 1 comments

OS: Ubuntu 22.04 Browser: Version 104.0.5112.79 (Official Build) (64-bit) Angular 12.0.0 Ngx-scanner: 3.4.2

The component was working fine, until a OS / Chrome update.

It is now unable to start the video source

6928.js:1 zxing scanner component: NotReadableError DOMException: Could not start video source

Checked and video camera is not used by other chrome tabs. Also it works fine in Firefox or Chrome on Android and Mac OS X etc.

cloakapps avatar Aug 05 '22 00:08 cloakapps

The error comes from trying to instantiate a new MediaStreamTrack/MediaStream whenever the <video> element's MediaStream has an active MediaStreamTrack with the same deviceId.

You might have luck by calling scanner.scanStop() or you can write your own method like so:

this.scanner.previewElementRef.nativeElement.srcObject.getTracks().forEach((track: MediaStreamTrack) => { track.stop() });

Call this method before updating the scanners device and it might fix the problem

eqprog avatar Sep 02 '22 23:09 eqprog