代码如下,当recordManger.onStart的时候recordClicked = true 记录开始录音。
当用户点击停止的时候触发recordManger.stop()停止录音,我们在onStop的时候,把标志recordClicked = false,记录完成录音,提示发送按钮。
但是目前有部分用户反馈,开始录音后无法停止,查看日志,发现日志反馈onError:{"errMsg":"operateRecorder:fail recorder not start"}。
我们是在onstart之后才开放停止按钮的,而且用户录音都是10秒以上的不存在1秒以内时间太多的情况。这个应该不存在异步还没开始的问题呢。
设备型号 iPhone 12 Pro<iPhone13,3>
const recordManger = wx.getRecorderManager();
this.remainingTime = RECORD_DURATION;
recordManger.onStop((res) => {
this.recordClicked = false;
this.recordPaused = false;
this.tempRecordFilePath = res.tempFilePath;
this.audioDuration = Math.round(res.duration);
this.recordFileSize = res.fileSize;
InnerAudioContext2.src = res.tempFilePath;
this.recordDuration = parseInt(RECORD_DURATION - this.remainingTime);
this.remindPlayTime = this.recordDuration;
this.remainingTime = RECORD_DURATION;
clearInterval(this.interver);
});
recordManger.onStart(() => {
this.recordFileSize = 0;
this.recordClicked = true;
clearInterval(this.interver);
this.interver = setInterval(() => {
!this.recordPaused && this.remainingTime--;
if (this.remainingTime === 0) {
clearInterval(this.interver);
recordManger.stop();
this.recordClicked = false;
this.recordPaused = false;
}
}, 1000);
});
recordManger.onError((res) => {
onlineConsultationHook.emit(
'recorderErrMsg',
this.consultItem,
JSON.stringify(res)
);
});
startRecordVoice() {
checkRecordPermission(
() => {
this.initPlugin();
recordManger &&
recordManger.start({
format: 'mp3',
duration: RECORD_DURATION * 1000
});
},
() => {}
);
},
pauseRecordVoice() {
this.recordPaused = true;
recordManger && recordManger.pause();
},
resumeRecordVoice() {
this.recordPaused = false;
recordManger && recordManger.resume();
},
stopRecordVoice() {
recordManger && recordManger.stop();
},
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
您好,请问解决了吗