问题描述
我正在尝试使用RN Camera
录制视频,并且当用户单击“录制”按钮时,我也在使用react-native-sound
lib来播放音乐。我面临的问题是,当我单击“录制”按钮时,视频会在几秒钟后开始录制,但不是立即开始。
这是我的代码。
async startRecording() {
this.sound = new Sound(
'https://www.bensound.com/bensound-music/bensound-dubstep.mp3','',(error) => {
if (error) {
console.log('failed to load the sound',error);
Alert.alert('Notice','audio file error. (Error code : 1)');
// this.setState({playState: 'paused'});
} else {
if (this.sound.isLoaded) {
// this.setState({loading: false});
}
// this.setState({
// playState: 'playing',// duration: this.sound.getDuration(),// });
this.sound.play();
this.setState({recording: true},() => {
this.videoRec();
});
}
},);
}
这里是vid录制代码。
async videoRec() {
const {uri,codec = 'mp4',size} = await this.camera.recordAsync();
this.setState({recording: false,processing: true});
const type = `video/${codec}`;
this.setState({processing: false,uri: uri,type: type},() => {
this.sound.pause();
this.props.navigation.navigate('Preview',{video: uri});
});
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)