quagga2
quagga2 copied to clipboard
Torch not working in iOS Safari / Android Firefox
With the setup that I have, I set the torch to automatically turn on / off when opening and closing the barcode scanner, and this works properly on Android / Google Chrome.
However, this does not work properly in the other 2 setups I have tested:
Firefox on my Android device, Safari on my iOS device.
I would like to get it working on Firefox of possible, but It's possible that's just a limitation with the browser.
I am more concerned with getting it working on iOS, as I have received reports from iOS users that specifically need to use the barcode scanner in low light conditions.
I have not tried chrome on iOS yet, but I will update this post once I am able.
hmm. I'm not very confident on iOS supporting enabling torch/flash in Safari. Apple has been absolutely terrible with media support in iOS Safari, taking years to support features, and then breaking some of them for no obvious reason.
This looks to be about the simplest test example I see out there https://jsfiddle.net/39puneug/4/
Give it a try, and see if it works?
A fully browser based solution might not be the answer for iOS in that case. Perhaps Cordova has something that can help, though.
Also, MDN/Mozilla offers a playground where you can test out various constraints so you might try that
https://developer.mozilla.org/en-US/docs/Web/API/Media_Streams_API/Constraints#result
According to the constraint playground, the torch constraint is not available in iOS safari.
so let me ask a new question. I would think that a workaround would be to turn on the flashlight first, and then start scanning barcodes. However, this does not work because starting the barcode scanner always seems to turn the light off, if it's already on. Any idea what causes this behavior, and if it can be disabled?
It seems weird that all browsers are able to turn the light off, but not turn it on.
i don't know anything about iOS internals, but i'd guess that they probably reset the camera, including the flash, to a specific state when turning it on. :| I'm guessing that you can't turn it on after starting the camera, from a system menu, like you probably can in Android?
As an aside, we just in the most recent version of iOS got the ability to even use the camera in WebView, previously it was restricted to Safari only :(
The light rest happens in both iOS and Android,
in the Android Chrome, it turns the light off and then back on again.
TODO: Update documentation to include some information about how to use the Torch and Zoom methods, and what platforms they are known to be available on.