|
@@ -203,8 +203,6 @@ export default {
|
|
|
innerAudio: null, //该页面的音频
|
|
|
audioCount: 0, //录音计时,毫秒
|
|
|
audioSrc:'',//tempSrc
|
|
|
- recordStartTime: null, //录音开始时间
|
|
|
- recordStopTime: null, //录音停止的时间
|
|
|
audioTime: "00:00", //录音时间(格式化后):string
|
|
|
timer: null,
|
|
|
audioItem: null,
|
|
@@ -272,6 +270,16 @@ export default {
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
+ //麦克风被占用,初始化录音相关变量 其他状态->未录音状态
|
|
|
+ setRecorder(){
|
|
|
+ this.questionItem.recordStatus = 1;
|
|
|
+ this.innerAudio.stop();
|
|
|
+ this.isplay = false;
|
|
|
+ this.audioItem = null;
|
|
|
+ this.audioCount = 0;
|
|
|
+ this.scrollTop = 0;
|
|
|
+ this.audioTime = this.moment(this.audioCount * 1000).format("mm:ss");
|
|
|
+ },
|
|
|
//onHide触发
|
|
|
resetAudio(){
|
|
|
this.innerAudio.stop();
|
|
@@ -355,15 +363,25 @@ export default {
|
|
|
this.pageLoading = false;
|
|
|
});
|
|
|
this.globalRecorder.onError((res) => {
|
|
|
- console.log('err',res.errMsg)
|
|
|
- uni.showToast({
|
|
|
+ console.log('err',res)
|
|
|
+ console.log('errMsg',res.errMsg)
|
|
|
+ /* uni.showToast({
|
|
|
title:res.errMsg,
|
|
|
icon:'none'
|
|
|
- })
|
|
|
+ }) */
|
|
|
//开始录音失败
|
|
|
if(res.errMsg.includes('start')){
|
|
|
this.questionItem.recordStatus = 1;
|
|
|
}
|
|
|
+ //麦克风被占用的情况
|
|
|
+ if(res.errCode===1){
|
|
|
+ uni.showToast({
|
|
|
+ title:'麦克风被占用,已停止录音',
|
|
|
+ icon:'none'
|
|
|
+ })
|
|
|
+ this.globalRecorder.stop();
|
|
|
+ this.setRecorder()
|
|
|
+ }
|
|
|
});
|
|
|
/* this.globalRecorder.onFrameRecorded((res) => {
|
|
|
console.log("?", res);
|
|
@@ -477,9 +495,7 @@ export default {
|
|
|
this.audioItem = res.data;
|
|
|
} else {
|
|
|
//重新录
|
|
|
- this.questionItem.recordStatus = 1;
|
|
|
- this.audioCount = 0;
|
|
|
- this.audioTime = this.moment(this.audioCount).format("mm:ss");
|
|
|
+ this.setRecorder()
|
|
|
}
|
|
|
},
|
|
|
//录音操作:完成/删除/发布
|
|
@@ -494,14 +510,7 @@ export default {
|
|
|
} else if (type === "delete") {
|
|
|
//重新录
|
|
|
if(this.questionItem.recordStatus===3)this.globalRecorder.stop();
|
|
|
- this.questionItem.recordStatus = 1;
|
|
|
- this.innerAudio.stop();
|
|
|
- this.isplay = false;
|
|
|
- this.audioItem = null;
|
|
|
- this.audioCount = 0;
|
|
|
- this.scrollTop = 0;
|
|
|
- this.recordStartTime = null;
|
|
|
- this.audioTime = this.moment(this.audioCount * 1000).format("mm:ss");
|
|
|
+ this.setRecorder()
|
|
|
} else {
|
|
|
//发布
|
|
|
if (!this.audioItem) {
|
|
@@ -593,15 +602,10 @@ export default {
|
|
|
//录音计时
|
|
|
clockTime() {
|
|
|
console.log("开始录音计时");
|
|
|
- if (!this.recordStartTime) {
|
|
|
- this.recordStartTime = Date.now();
|
|
|
- }
|
|
|
- //console.log(this.recordStartTime);
|
|
|
this.timer = setInterval(() => {
|
|
|
if (this.timer) {
|
|
|
this.audioCount += 30;
|
|
|
this.audioTime = this.moment(this.audioCount).format("mm:ss.SS");
|
|
|
- //this.audioTime = this.moment(Date.now() - this.recordStartTime).format("mm:ss.SS");
|
|
|
this.scrollTop+=1;
|
|
|
}
|
|
|
}, 30);
|
|
@@ -609,7 +613,6 @@ export default {
|
|
|
//清除录音计时
|
|
|
cleanTime() {
|
|
|
console.log("结束录音计时");
|
|
|
- //console.log('aa',this.recordStopTime)
|
|
|
clearTimeout(this.timer);
|
|
|
this.playIconKey++; //更新录音暂停播放图标
|
|
|
//this.audioTime = this.moment(this.audioCount).format("mm:ss.SS");
|