我正在使用 react-native-camera RNCamera 组件来录制视频。主要任务是在聊天窗口录制上传和预览,但是我无法获取视频。RNCamerarecordAsync(options)
命令将其作为缓存保存到本地缓存文件夹中,我无法从文件夹中获取它。我尝试使用 fetch-blob 但它返回的文件大小为 0。我做错了什么?
import {RNCamera} from 'react-native-camera';
import RNFetchBlob from 'react-native-fetch-blob';
constructor(props) {
super(props);
this.state = {
path: "",
recorded: false,
isRecording: false,
}
}
takeVideo() {
this.state.isRecording ? this.stopRecord() : this.saveVideo();
this.state.isRecording ? this.setState({isRecording: false}) : this.setState({isRecording: true})
}
async stopRecord(){
this.camera.stopRecording();
const { config, fs, android } = RNFetchBlob;
const str = this.state.path;
const fileName = str.substr(str.indexOf("Camera")+7, str.indexOf(".mp4"));
const path = fs.dirs.CacheDir + '/Camera/'+fileName;
const res = await fetch(str);
const blob = …
Run Code Online (Sandbox Code Playgroud)