How to access torch (flashlight) using javascript or jquery?

72
September 24, 2021, at 12:10 PM

I am using the html5-qrcode barcode scanner library based on zxing and everything is working fine.

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.

In the config settings I have tried 'torch: true' but it does not do anything.

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>
READ ALSO
LinkedLIst and Switch Case Java to add middle string [closed]

LinkedLIst and Switch Case Java to add middle string [closed]

Want to improve this question? Add details and clarify the problem by editing this post

61
SVG `fill` overlaps `stroke`

SVG `fill` overlaps `stroke`

Having a circle it has fill and strokeBut I see that fill color overlaps little bit stroke

82
Get MIN, MAX values from a linking table

Get MIN, MAX values from a linking table

I have 3 tables in a MYSQL DB

75