Skip to content

NextJS - stop() not stopping decodeFromConstraints #128

Description

@Snolandia

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();
};
},[])

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions