question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to properly unmount after getting barcode

See original GitHub issue

Thanks 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:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
alanbugejacommented, Nov 29, 2020

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.

0reactions
odahcamcommented, Feb 1, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found