Closed abdulwahabalm closed 1 year ago
Could you please provide a minimal working example that demonstrates this behavior?
I am asking this because the polyfill does not behave like that in the unit tests and in the examples.
I attempted to write a minimal working example of you code and it didn't really work
but my attempt was that
function detect(source){ return detector .detect(source) .then(symbols => {
/ rest of code /
detectVideo(false) // my assumption is it would have worked the same way the camera disappears when you trigger detectImg
})
I assume that you are referring to the code in barcode-detector-polyfill/example-bundled/main.js
In order to stop scanning as soon as a symbol has been detected, I would suggest to do something like this:
function detect(source) {
return detector
.detect(source)
.then(symbols => {
// ...
// Add this after the code block:
if (symbols.length > 0) {
detectVideo(false)
}
})
}
To start scanning the video that is playing in the <video>
element, call detectVideo()
without arguments (as in the videoBtn
click listener) . This will clear the previous bounding box.
Thank you! it worked
The scanner is really good and is of high quality but it doesn't stop even after it detects a barcode.
can there be a way for the scanner to stop after scanning a barcode ?