Turn flashlight on/off In QRcodeScanner React native

你说的曾经没有我的故事 提交于 2019-12-23 17:12:59

问题


im using react-native-qrcode-scanner and what i want to do is : when user press on a flashlight icon flashLight go on i done this :

<QRCodeScanner
        showMarker
        onRead={this.onSuccess.bind(this)}
        cameraStyle={{ height: SCREEN_HEIGHT }}
        cameraProps={{ flashMode: this.state.flashLight ? RNCamera.Constants.FlashMode.on : RNCamera.Constants.FlashMode.off, captureAudio: false }}

camera prop works but when i change the state.flashLight (true or false) the flashLight not change

any Idea how change camera prop with state ??


回答1:


Try to replace:

RNCamera.Constants.FlashMode.on

with:

RNCamera.Constants.FlashMode.torch

Does the flashlight turn on now?



来源:https://stackoverflow.com/questions/55918898/turn-flashlight-on-off-in-qrcodescanner-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!