Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Torch is not working #20

Open
stamahto opened this issue Aug 15, 2023 · 3 comments
Open

Torch is not working #20

stamahto opened this issue Aug 15, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@stamahto
Copy link

I am encountering an issue with the torch.on() and torch.off() functions. When I call torch.on(), no noticeable changes occur, even console don't log any message.

I´m using the latest version 1.1.4

@adamalfredsson adamalfredsson self-assigned this Aug 15, 2023
@adamalfredsson
Copy link
Owner

What OS are you using?

@stamahto
Copy link
Author

Android 13
I made my own custom torch function, which get user media by deviceId from my state and works fine.

    const handleToggleTorch = useCallback(() => {
        navigator.mediaDevices.getUserMedia({ video: { deviceId: deviceId } }).then(stream => {
            const track = stream.getVideoTracks()[0];
            track.applyConstraints({
                advanced: [{ torch: !isTorchOn } as any]
            });
            setIsTorchOn(!isTorchOn);
        });
    }, [deviceId, isTorchOn]);

As I look into your hook, did you consider put videoTrackRef into useCallback dependencies?

Btw. if you would update the code, please also update @zxing/library version

@adamalfredsson
Copy link
Owner

That's strange! Unfortunately I'm in no possession of a torch-compatible device, so any help I could get with this would be highly appreciated!

@zxing/library has been updated now, in 2.0.0!

@adamalfredsson adamalfredsson added the help wanted Extra attention is needed label Aug 17, 2023
@adamalfredsson adamalfredsson removed their assignment Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants