Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Torch / Flashlight doesn't work during camera stream. #264

Open
jonasphp opened this issue Jun 17, 2023 · 1 comment
Open

Torch / Flashlight doesn't work during camera stream. #264

jonasphp opened this issue Jun 17, 2023 · 1 comment

Comments

@jonasphp
Copy link

jonasphp commented Jun 17, 2023

I'm trying this on a complete fresh install. I'm using iOS 16, Newest Android OS xCode 14 and capacitor v5, The qr scanner works only flash doesn't this is the current code:

On iOS the torch turns on and then off as soon as the camera view starts, on android it doesn't turn on at all.

` const startScan = async () => {
document.body.style.opacity="0.2";
document.body.style.background = "transparent";
document.getElementById("pusher").style.display = "none";

            BarcodeScanner.hideBackground(); // make background of WebView transparent
            BarcodeScanner.enableTorch();
            const result = await BarcodeScanner.startScan(); // start scanning and wait for a result
          
            // if the result has content
            if (result.hasContent) {
                 document.getElementById("pusher").style.display = "block";

                document.body.style.background = "";
                document.body.style.opacity="1";
              console.log(result.content); // log the raw scanned content
            }
          }
          startScan();`
@thegnuu
Copy link
Collaborator

thegnuu commented Jun 20, 2023

This will not work, you need to use startScanning and enable your torch after this call.

startScan will reset the camera-view and therefore disable the torch, this is unfortunately not so easy to fix with the current implementation. Maybe it works if you call prepare before your enableTorch call, but unfortunately I cannot test it at the moment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants