-
Notifications
You must be signed in to change notification settings - Fork 580
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
Flash Light not working #518
Comments
Running into the same issue on Android device, with both torchMode="on" and flashMode="on" |
After some investigation, seems like the setFlashMode is called before the imageCapture is even initialized. So flash mode ends up never being set. Screen.Recording.2023-01-25.at.11.41.11.AM.movthe imageCapture is set in the bindCameraUseCases which is called by setupCamera. The flash mode is set before the setupCamera is invoked. So it ends up finding no imageCapture (imageCapture is null), so it just skips setting the flash mode to on. |
@avneeshkumar1 I opened a PR to expose a setTorchMode method to unblock us. #523 |
yousrasd is that pr merged? |
@avneeshkumar1 no not yet, waiting for a maintainer to review the PR and merge it. |
same issue cannot flashlight and camera type is not working |
@ajiehatajie please can you comment on the PR #523 that you need those changes too? Im still waiting for the PR to be reviewed :( |
Be careful, First, your code is right. However it doesn't work because of a timing issue. Timing should be fixed on the library, but a simple workaround is to delay setting the
|
Outdated. Closing since changes have been made since then, and it seems there might have been a misunderstanding of torchMode vs flashMode. |
Not sure why this was closed as this is still an issue (if the user was talking about torchMode). I used the workaround provided by @DavidBertet and it was wonderful. To clarify, the issue is happening when attempting a barcode / QR code scan and attempting to turn on torchMode. torchMode flashes on for a brief moment before turning off again. |
flash and torch is working only when state is toggling manually |
any solution for handling this problem |
Hi team thanks for this awesome library
I am using the below code for scan QR code
render() {
return (
<Camera
ref={this.camera}
style={{flex: 1}}
cameraType={CameraType.Back} // optional
flashMode="on" // on/off/auto(default)
focusMode="on" // off/on(default)
zoomMode="on" // off/on(default)
torchMode="off" // on/off(default)
ratioOverlay="1:1" // optional
ratioOverlayColor="#77" // optional
resetFocusTimeout={0}
resetFocusWhenMotionDetected={false}
saveToCameraRole={false} // iOS only
scanBarcode={true} // optional
showFrame={true} // Barcode only, optional
laserColor="red" // Barcode only, optional
frameColor="yellow" // Barcode only, optional
surfaceColor="blue" // Barcode only, optional
onReadCode={(event) => console.log(event.nativeEvent.codeStringValue)}
/>
);
}
Scanning is working fine
but flash light not working even pass torchMode="on" but still not working. can someone suggest me what is wrong with code.
The text was updated successfully, but these errors were encountered: