cozmo / jsQR

A pure javascript QR code reading library. This library takes in raw images and will locate, extract and parse any QR code found within.
https://cozmo.github.io/jsQR/
Apache License 2.0
3.73k stars 607 forks source link

How can I stop streaming? #196

Closed MichPot closed 3 years ago

MichPot commented 3 years ago

Hello and thank you for jsQR! I'm newbie with programming, with a little help i found the way to insert the jsQR into a web form and it works. I only have a problem, the camera never stop.

After code found, how can i stop camera streaming? after : outputData.innerText = code.data;

if (code) { drawLine(code.location.topLeftCorner, code.location.topRightCorner, "#FF3B58"); drawLine(code.location.topRightCorner, code.location.bottomRightCorner, "#FF3B58"); drawLine(code.location.bottomRightCorner, code.location.bottomLeftCorner, "#FF3B58"); drawLine(code.location.bottomLeftCorner, code.location.topLeftCorner, "#FF3B58"); outputMessage.hidden = true; outputData.parentElement.hidden = false; outputData.innerText = code.data; ? Thank you for your help

MichPot commented 3 years ago

Finally I found my solution! there she is stopStreamedVideo(video); function stopStreamedVideo(videoElem) { const stream = videoElem.srcObject; const tracks = stream.getTracks(); tracks.forEach(function(track) { track.stop(); }); videoElem.srcObject = null; }

cozmo commented 3 years ago

Glad you found a solution!

simplast commented 1 year ago

requestAnimationFrame still running