Avoiding Camera Permission and Keep Scanning #246
Replies: 6 comments 8 replies
-
|
Beta Was this translation helpful? Give feedback.
-
To stop using camera and thus stop scanning, call Html5Qrcode#stop() which returns a Promise for stopping the video feed and scanning. html5QrCode.stop().then((ignore) => { Note that the class is stateful and stop() should be called to properly tear down the video and camera objects safely after calling start() when the scan is over or the user intend to move on. stop() will stop the video feed on the viewfinder. |
Beta Was this translation helpful? Give feedback.
-
why not to try the html5QrCodeScanner class first? |
Beta Was this translation helpful? Give feedback.
-
@ROBERT-MCDOWELL , first of all I'd like to thank you for your help, I was able to keep scanning and everything looks good. I just have one small problem with the scanning. When I point the camera to the barcode at the time it's being initialized, it's throwing an exception "Stop the camera before rescanning"(or something like this) in mobile browsers and then website stops responding. Is there a way for to put a hold on the scanner and start scanning 100 miliseconds after it's initialized? |
Beta Was this translation helpful? Give feedback.
-
Can someone share the working code ? |
Beta Was this translation helpful? Give feedback.
-
UpdateThis feature has been implemented in Use the config called rememberLastUsedCamera to enable this feautre function onScanSuccess(decodedText, decodedResult) {
// handle success.
}
let html5QrcodeScanner = new Html5QrcodeScanner(
"reader",
{
fps: 10,
qrbox: {width: 250, height: 250},
rememberLastUsedCamera: true
// ^ set this to false to disable this.
});
html5QrcodeScanner.render(onScanSuccess); Once the user grant permission for camera (which is required in all browsers once) - the library will remember this and automatically open last used camera next time user opens your web page - see the demo page: qrcode.minhazav.dev for instance. |
Beta Was this translation helpful? Give feedback.
-
Hey guys,
I am still pretty new in this library and trying to figure out a way to avoid asking permissions for camera every time.
I also would like to scan a barcode -> stop the scanning if an successful -> use the result -> go back to scanning without initial screen and stay in this loop until users chooses to stop using my custom action buttons.
I cannot really see what functions or attributes I can use to complete these operations. Can you provide more documentation or help?
Every help is appreciated!
Beta Was this translation helpful? Give feedback.
All reactions