browser icon indicating copy to clipboard operation
browser copied to clipboard

NextJS - stop() not stopping decodeFromConstraints

Open Snolandia opened this issue 1 year ago • 6 comments

Stop doesnt seem to do anything. Calling it or not calling it has no effect and the callback continuously gets called.

Code Below

const controlsRef: MutableRefObject<IScannerControls | null | undefined> = useRef(undefined);

useEffect(()=>{
const codeReader = new BrowserQRCodeReader(undefined, { delayBetweenScanAttempts:props.qrReaderProps.scanDelay, }); codeReader.decodeFromConstraints({ video:props.qrReaderProps.constraints }, props.qrReaderProps.videoId, (result, error,controls) => {onResult(result,error,controls,codeReader)}) .then((controls: IScannerControls) => { controlsRef.current = controls; }) .catch((error: Error) => { if(props.qrReaderProps.onResult){ onResult(null, error, controlsRef.current, codeReader); } }); return () => { BrowserCodeReader.releaseAllStreams() controlsRef.current?.stop(); }; },[])

Snolandia avatar Dec 06 '23 18:12 Snolandia