После вызова takePictureAsyn c () из response-native-camera, я получаю эту ошибку:
{
"framesToPop": 1,
"nativeStackAndroid": [],
"userInfo": null,
"message": "Preview is paused - resume it before taking a picture.",
"code": "E_TAKE_PICTURE_FAILED",
"line": 2131,
"column": 45,
"sourceURL": "http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false"
}
Поэтому я попытался использовать метод resumePreview () перед вызовом takePictureAsyn c () и теперь я получаю другое сообщение об ошибке:
{
"framesToPop": 1,
"nativeStackAndroid": [],
"userInfo": null,
"message": "takePicture failed",
"code": "E_TAKE_PICTURE_FAILED",
"line": 2131,
"column": 45,
"sourceURL": "http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false"
}
Мой компонент и использование идентичны https://react-native-community.github.io/react-native-camera/docs/rncamera
<RNCamera
ref={ref => {
this.camera = ref;
}}
style={styles.preview}
type={RNCamera.Constants.Type.back}
flashMode={RNCamera.Constants.FlashMode.on}
androidCameraPermissionOptions={{
title: 'Permission to use camera',
message: 'We need your permission to use your camera',
buttonPositive: 'Ok',
buttonNegative: 'Cancel',
}}
androidRecordAudioPermissionOptions={{
title: 'Permission to use audio recording',
message: 'We need your permission to use your audio',
buttonPositive: 'Ok',
buttonNegative: 'Cancel',
}}
onGoogleVisionBarcodesDetected={({ barcodes }) => {
console.log(barcodes);
}}
/>
takePicture = async () => {
if (this.camera) {
const options = { quality: 0.5, base64: true };
try {
this.camera.resumePreview();
const data = await this.camera.takePictureAsync(options);
console.log(data.uri);
} catch (error) {
console.log(JSON.stringify(error, null, 2));
}
}
};
версий:
"react-native": "0.61.2",
"react-native-camera": "git+https://git@github.com/react-native-community/react-native-camera.git",
Отлично работает на iOS. Это проблема с библиотекой или моей реализацией?