I am adding video recording and preview feature to my react native app.For taking video i used the following code and once recorded i am able to get the output file.Now using the file uri i tried to preview this file to the users using react-native-video component.But it always shows blank screen, but the video is not loaded.
import { RNCamera, FaceDetector } from 'react-native-camera';
<RNCamera
ref={ref => {
this.camera = ref;
}}
style={{width:width(100),height:height(100)}}
type={RNCamera.Constants.Type.back}
flashMode={RNCamera.Constants.FlashMode.on}
permissionDialogTitle={"Permission to use camera"}
permissionDialogMessage={
"We need your permission to use your camera phone"
}
>
async startRecording() {
this.setState({ recording: true });
var self = this;
this.camera.recordAsync().
then((data) => {
self.setState({video:data.uri})
})
}
Once video variable is avaialbe i tried to load this using below code snippet :-
import Video from 'react-native-video';
{this.state.video !== ''
?
<Video source={{uri: this.state.video}} // Can be a URL or a local file.
ref={(ref) => {
this.player = ref
}}
onBuffer={this.onBuffer}
onError={this.videoError}
style={styles.backgroundVideo} />
:
<View/>
}
The version details are:-
- "react-native": "0.61.5".
- "react-native-video": "^5.0.2"
- "react-native-camera": "^3.15.0"
This is video file im getting after camera recording finished "file:///data/user/0/com.dezzexvideo/cache/Camera/94d367ef-c6b8-43c3-844f-7d0d2c6d0ddf.mp4"