-
-
Notifications
You must be signed in to change notification settings - Fork 922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Camera does not stop scanning #35
Comments
Would this way help
|
@OneDivZero is this still happening? |
Marking closed, @OneDivZero - Please feel free to reopen if this is still happening. |
Dears, sorry for reopening. I have similar/related problem that I kindly desire some guidance on, pretty please! Using html5QrCode 2.0.3, in my qrCodeSuccessCallback.. I am immediately calling html5QrCode.stop() using await and then reactivating it once done with parsing logic.. this works great (visible in code below). However, I'd like to keep camera off for X seconds (so user can verify parse data before next scan) so I wrapped my call to startScanning() inside setTimeout, but when I do.. I randomly receive this error: Uncaught (in promise) Cannot clear while scan is ongoing, close it first. I'm confident the scanner is stopped before calling startScanning (in both working/non-working scenarios).. I just don't understand how SetTimeout introduces the error. Thank you kindly for the library, and your insight. function startScanning() { html5QrCode.start({facingMode: "environment"}, { fps: 10}, async qrCodeMessage => { await stopScanning(); //parse & display logic here //startScanning(); //this works, camera re-activates really fast setTimeout(function () { //but if I use this instead, it randomly errors on next scan.. regardless of interval startScanning(); }, 100); //errors occur at 100ms, 3000ms, 10000ms }, errorMessage => {}).catch(err => { console.log(err); }); } |
Describe the bug
A call to stopScanning() does not stop scanning im some cases.
Maybe it's a problem, that I'll do this in a timeout-callback.
Reason: I'am doing a pattern-matching on scanned result ... this happens very fast in success-case. For providing a better UX, I add a small timeout for giving interaction-feedback to current user ... before I'll do other stuff in my final implementation.
To Reproduce
Modify Success-Callback this way:
Expected behavior
Should close the stream in any case when invoking stopScanning()
Screenshots
n.a.
Smartphone:
Additional context
n.a.
The text was updated successfully, but these errors were encountered: