How to properly unmount after getting barcode
See original GitHub issueThanks for the awesome library.
I’m using this to scan barcode via video stream
using listVideoInputDevices and decodeOnceFromVideoDevice, till here everything works perfectly fine and I get the barcode.
I move to next page in my web app which uses a another library to record video. I get camera is already in use exception.
After getting the barcode I am doing the following:
const video = document.querySelector('video'); const mediaStream = video.srcObject; const tracks = mediaStream.getTracks(); tracks.forEach((track) => { track.stop(); mediaStream.removeTrack(track); }); codeReader.reset();
am I missing something ?
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How to remove barcode from list items - TechNet - Microsoft
First: The items created before Barcodes disabled can always show values of Barcode and Barcode Value, no matter Barcodes is disabled or not....
Read more >Editing and Deleting Barcodes - One-Key Support
Tap Change next to the barcode's info. · Select Remove barcode. · A confirmation pop-up will appear. · If you don't wish to...
Read more >Place Barcodes on Products - GS1 US
Follow these guidelines to correctly place barcodes on your product labels. The size, color, and placement of a barcode is important to a...
Read more >Do you remove the barcode stickers after each flight?
Usually take the label off after getting bag and stick in inside the bag for later disposal in a secure location. I often...
Read more >Barcode FAQs, Troubleshooting, How-to - Socket Mobile
My D750 barcode reader is adding a zero when scanning a UPC-A barcode. How do I remove it?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Guys just in any case you encounter my issue.
Being that the stop method was not working well every time I went ahead to use native javascript methods to stop stream/video tracks.
So i am getting the video element by id, getting the media tracks from srcObject of element and foreach loop on the tracks and calling stop method on every track.
One thing on my huawei mate 10 pro calling getTracks() and then stop on each, leaves the camera in use. I had to call getVideoTracks() instead and these seems to work fine. I will post code once at home.
Cheers.
I would recommend using the
decodeFromVideoElement
which returns an object with some controls you can take, being one of them the.stop()
, which you can call to stop the scanner. Just playing with the video element may introduce unexpected behaviors and the library may crash.