Question
I have been trying to figure out why this is not working for some time. I have used a lot of example code, however I still cannot figure it out.
Code
takeVideo() {
console.log('started to take video');
this.camera.capture({
audio: true,
mode: Camera.constants.CaptureMode.video,
target: Camera.constants.CaptureTarget.disk
}).then((data) => {
this.setState({ path: data.path });
console.log(data);
}).catch((err) => console.log(err));
}
stopVideo() {
this.camera.stopCapture();
console.log(this.state.path);
}
renderCamera() {
return (
<View>
<Camera
ref={(cam) => {
this.camera = cam;
}}
style={styles.preview}
aspect={Camera.constants.Aspect.fill}
captureTarget={Camera.constants.CaptureTarget.disk}
captureMode={Camera.constants.CaptureMode.video}
>
<TouchableHighlight
style={styles.capture}
onPressIn={this.takeVideo.bind(this)}
onPressOut={this.stopVideo.bind(this)}
underlayColor="rgba(255, 255, 255, 0.5)"
>
<View />
</TouchableHighlight>
</Camera>
</View>
);
}
Whats not working
When I console.log(this.state.path) it outputs false which means that it does not change and the video did not record.
Info
- This is on IOS
- This works if I change
Camera.constants.CaptureMode.videotoCamera.constants.CaptureMode.still(.video=>.still) - RN version:
react-native-cli: 2.0.1react-native: 0.44.0
Repo
I found this repo that is trying to do almost the exact same thing as me and is having the same issue. Here is the repo: https://github.com/MiLeung/record
captureTarget= {Camera.constants.CaptureTarget.cameraRoll}, where you define the camera in render - edencaptureTargetto cameraRoll: imgur.com/a/SgJSS - zoecarver