I'm using react-native-image-picker
library for video recording and react-native-video
to play video in which duration of video in onLoad
callback function is given but how can I use it in my code can anyone please guide me? I have written durationLimit
in function but it is not working. How can I record video of duration 30 seconds? I tried this
too but failed.
My Code
import ImagePicker from 'react-native-image-picker';
import Video from 'react-native-video';
constructor(props){
super(props);
this.state = {
video: '',
isVideo: true
};
};
_handleVideoUpload = () => {
const options = {
mediaType: 'video',
videoQuality: 'medium',
durationLimit: 30000,
thumbnail: true,
allowsEditing: true,
};
ImagePicker.launchCamera(options, (response) => {
if (response.didCancel) {
// console.warn('User cancelled video picker');
return true;
} else if (response.error) {
// console.warn('ImagePicker Error: ', response.error);
} else if (response.customButton) {
console.warn('User tapped custom button: ', response.customButton);
} else {
this.setState({video: response.uri});
}
});
}
render() {
return(
<View>
{
this.state.video != '' ?
<View>
<Video
ref={ref => this._video = ref}
source={{ uri: this.state.video }}
resizeMode={'cover'}
repeat={true}
paused = {true}
onLoad={() => { this._video.seek(2);}}
/>
</View>
:
<TouchableOpacity
onPress={() => this._handleVideoUpload()}
>
<Text>Upload Video</Text>
</TouchableOpacity>
}
</View>
);}
Thank you in advance.