zxing-js / browser

ZXing for JS's browser layer with decoding implementations for browser.
MIT License
213 stars 43 forks source link

Add Play, Pause, Stop, Destroy methods #137

Open gregg-cbs opened 2 months ago

gregg-cbs commented 2 months ago

As another issue mentions this reader once initialized does not stop, it causes a memory leak and high battery consumption on mobile.

controls.stop() seems to do nothing and there is no controls.play() to resume.

There is also no codeReader.stop() or .destroy() or .pause() or .play()

codeReader = new BrowserQRCodeReader(undefined, {
  delayBetweenScanAttempts: scanDelay
});

// this would be amazing
codeReader.stop()
codeReader.play()
codeReader.destroy()

as noted by others this does not work but even if it did there is no way to resume:

codeReader.decodeFromConstraints({ video: constraint }, videoRef, (result)=> {
  console.log(result?.getText())
})
.then((controls: IScannerControls) => {
  // does nothing
  controls.stop()
})