I am using the html5-qrcode barcode scanner library v2.0.12 based on zxing-js. I am using php, javascript and html to make a PWA that scans barcodes. I am testing on an iphone 8 using iOS 14.7.1.
Here is the documentation link for the library: QR and barcode scanner using HTML and Javascript
My issue is that I cannot find any documentation online that allows any config settings to enable the torch/flashlight option once the scanner window has started. I am wanting to do this for low light settings where it might help to get a better scan.
UPDATE I have found this link to a fork that mentions the flashlight support, but I cannot figure out how to add the appropriate code or where. It does mention the camera must first be activated. Add support for detecting and turning on/off flash light
In the config settings I have tried 'torch: true' but it does not do anything. I have also looked into using getUserMedia. The references I find on this site all seem to not work on iphones.
Is it possible to control the camera light on a phone via a website?
Turn on phone flashlight on web app using JavaScript and HTML
NodeJS - Turn On and Off Tourch/Flashlight in mobile Android/IPhone
Is it possible to use a jquery or javascript code and/or library to add a toggle switch to manually turn it on? At this point the user has already granted permission for the browser to access the phone if that makes a difference.
<script src="https://unpkg.com/html5-qrcode@2.0.9/dist/html5-qrcode.min.js"></script>
<div id="reader" width="350px"></div>
<script>
const html5QrCode = new Html5Qrcode("reader");
/** successful scan actions **/
const qrCodeSuccessCallback = (decodedText, decodedResult) => {
html5QrCode.stop();
alert (decodedText);
};
/** define scanner default settings **/
const config = { fps: 60,
qrbox: 275,
torch: true,
aspectRatio: 1.0
};
html5QrCode.start({ facingMode: { exact: "environment"} }, config, qrCodeSuccessCallback);
</script>