You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The Camera keeps on forever even when a user is directed to different route #8
You have to stop the video tracks and camera manually first.
conststopScanner=useCallback(async()=>{// 1. Stop tracked stream directlyif(streamRef.current){streamRef.current.getTracks().forEach((track)=>track.stop());streamRef.current=null;}// 2. Stop html5-qrcode safely checking its active scanner stateif(scannerRef.current){try{if(scannerRef.current.isScanning){awaitscannerRef.current.stop();}scannerRef.current.clear();}catch(err){console.warn("Soft warning during scanner stop cleanup:",err);}finally{// scannerRef.current = null;}}// 3. Fallback: stop ALL video tracks in the DOMdocument.querySelectorAll("video").forEach((video)=>{if(video.srcObject){(video.srcObjectasMediaStream).getTracks().forEach((track)=>track.stop());video.srcObject=null;}});setIsScanning(false);},[]);
But one thing I have noticed is that the instance is not fully stopping its scanning function by calling the stop method from the instance. @mebjas is it right or not?
This is an awesome package and if a few issues associated with it are fixed, it can turn out the best for this job.
When a scanning is done successfully, the camera keeps on and even after redirecting to another url.