|
|
@@ -171,7 +171,7 @@ export default {
|
|
|
timer: null, // 计时器
|
|
|
recordFile: 1, // 录音文件名
|
|
|
selectIndex: null, // 选中的录音索引
|
|
|
- oldIndex: null, // 存储播放录音索引
|
|
|
+ oldIndex: '', // 存储播放录音地址
|
|
|
playtime: 0, // 播放时间
|
|
|
isPlaying: false,
|
|
|
scoreLoading: false,
|
|
|
@@ -221,6 +221,8 @@ export default {
|
|
|
this.audio.addEventListener('ended', () => {
|
|
|
this.changeStatus('normal');
|
|
|
this.isPlaying = false;
|
|
|
+ this.recordtime = this.wholeRecordSelectList[this.selectWholeIndex].toltime;
|
|
|
+ this.playtime = 0;
|
|
|
});
|
|
|
// 登记录音器,供提交前统一停止(停止会触发录音上传)
|
|
|
this.unregisterRecorder = registerRecorder({ stopIfRecording: () => this.stopIfRecording() });
|
|
|
@@ -572,14 +574,13 @@ export default {
|
|
|
async playmicrophone(totalTimes) {
|
|
|
if (this.isPlaying) {
|
|
|
this.isPlaying = false;
|
|
|
+ this.hasMicro = 'normal';
|
|
|
this.audio.pause();
|
|
|
clearInterval(this.timer);
|
|
|
- this.recordtime = this.wholeRecordSelectList[this.selectWholeIndex].toltime;
|
|
|
+ // this.recordtime = this.wholeRecordSelectList[this.selectWholeIndex].toltime;
|
|
|
} else {
|
|
|
- this.isPlaying = true;
|
|
|
if (this.selectWholeIndex || this.selectWholeIndex === 0) {
|
|
|
let totalTime = totalTimes;
|
|
|
-
|
|
|
this.audio.pause();
|
|
|
// 历史答案存 dataURL(同步播放,行为与改动前一致),新答案存 file_id(先换 URL)
|
|
|
const src = this.wholeRecordSelectList[this.selectWholeIndex].src;
|
|
|
@@ -588,21 +589,36 @@ export default {
|
|
|
this.$message.warning('录音加载失败,请稍后重试');
|
|
|
return;
|
|
|
}
|
|
|
- this.audio.load();
|
|
|
- this.audio.src = src;
|
|
|
- this.oldIndex = this.selectWholeIndex;
|
|
|
- playAudioElement(this.audio);
|
|
|
- this.playtime = 0;
|
|
|
- this.recordtime = totalTime;
|
|
|
- clearInterval(this.timer);
|
|
|
- this.timer = setInterval(() => {
|
|
|
- if (this.playtime < totalTime) {
|
|
|
- this.playtime += 1;
|
|
|
- this.recordtime = totalTime - this.playtime;
|
|
|
- } else {
|
|
|
- clearInterval(this.timer);
|
|
|
- }
|
|
|
- }, 1000);
|
|
|
+ this.hasMicro = 'active';
|
|
|
+ this.isPlaying = true;
|
|
|
+ if (this.oldIndex === src) {
|
|
|
+ playAudioElement(this.audio);
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.timer = setInterval(() => {
|
|
|
+ if (this.playtime < totalTime) {
|
|
|
+ this.playtime += 1;
|
|
|
+ this.recordtime = totalTime - this.playtime;
|
|
|
+ } else {
|
|
|
+ clearInterval(this.timer);
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ } else {
|
|
|
+ this.audio.load();
|
|
|
+ this.audio.src = src;
|
|
|
+ this.oldIndex = src;
|
|
|
+ playAudioElement(this.audio);
|
|
|
+ this.playtime = 0;
|
|
|
+ this.recordtime = totalTime;
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.timer = setInterval(() => {
|
|
|
+ if (this.playtime < totalTime) {
|
|
|
+ this.playtime += 1;
|
|
|
+ this.recordtime = totalTime - this.playtime;
|
|
|
+ } else {
|
|
|
+ clearInterval(this.timer);
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
@@ -635,7 +651,7 @@ export default {
|
|
|
this.hasMicro = 'normal';
|
|
|
clearInterval(this.timer);
|
|
|
this.audio.pause();
|
|
|
- this.oldIndex = null;
|
|
|
+ this.oldIndex = '';
|
|
|
this.$emit('getWholeRecordIndex', index);
|
|
|
},
|
|
|
handleDelete() {
|
|
|
@@ -651,7 +667,7 @@ export default {
|
|
|
this.wholeRecordSelectList.length > 0 ? this.wholeRecordSelectList[this.selectWholeIndex].toltime : 0;
|
|
|
releaseAudioElement(this.audio);
|
|
|
this.audio = new window.Audio();
|
|
|
- this.oldIndex = null;
|
|
|
+ this.oldIndex = '';
|
|
|
this.isPlaying = false;
|
|
|
clearInterval(this.timer);
|
|
|
this.audio.addEventListener('ended', () => {
|