serratus / quaggaJS

An advanced barcode-scanner written in JavaScript
https://serratus.github.io/quaggaJS/
MIT License
5.06k stars 978 forks source link

Torch is not turning off (probable error in official example?) #206

Open alexey-m-ukolov opened 7 years ago

alexey-m-ukolov commented 7 years ago

I've tested this issue on Sony Xperia T3 / Chrome Beta 60 / Android 4.4.4 and Xiaomi MI5 / Chrome Beta 60 / Android 6.0.1. Even in the official example I am able to turn torch on but can't turn it off with a checkbox. The only solution is to change some Quagga settings so it will restart - then torch is off again.

ericblade commented 6 years ago

I have implemented torch in my app with a simple on/off button toggle, and it is able to go on/off. Anyone else still experiencing this with latest?

TomasHubelbauer commented 6 years ago

I don't have a torch-equipped device on me right now to test this, but I will test whether the official example still has this problem. If not, it's likely it's been fixed since and we can probably close this, especially since you got this to work through the API, @ericblade.

alexey-m-ukolov commented 6 years ago

Nope, official example still has this problem for me on Xiaomi MI5 / Chrome 67 / Android 7.0.

ericblade commented 6 years ago

I haven't tried the example -- the examples seem to be a bit finicky. It works in my app with basically the following React code:

    toggleTorch = () => {
        const torch = !this.state.torch;
        this.setState({ torch });
        const track = Quagga.CameraAccess.getActiveTrack();
        if (track && typeof track.getCapabilities === 'function') {
            track.applyConstraints({ advanced: [ { torch } ] });
        }
    }

which I simplified from the example. Seems that there may be a bug in the toggle in the sample app? Certainly worth knowing if it affects just the sample. It's working in the app I'm using it in, on Nexus 5 with stock Android 6, and also worked on Nexus 5 with Android 8, though i don't have that installed anymore.

Thanks @alexey-m-ukolov

synedra-mpe commented 5 years ago

Thats really strange. According to https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints torch seems to only useable to turn the flight on, until the track is active, not off. Testing on a Samsung SM-T800 tablet. Maybe some manufactorers take this feature more precisely?

A Boolean defining whether the fill light is continuously connected, meaning it stays on as long as the track is active.

achu94 commented 3 years ago

I got the same problem, the point of not going off is that, when you have torch on you are closing the stream and trying to off the torch but, you need just first off the torch than close the stream. When you close the stream you dont have any response for aktiveTrack hope that will help you too.