Quellcode durchsuchen

语音矩阵 修改问题

dusenyao vor 3 Jahren
Ursprung
Commit
cf1b5141ed
1 geänderte Dateien mit 31 neuen und 10 gelöschten Zeilen
  1. 31 10
      src/components/Adult/preview/VoiceMatrix.vue

+ 31 - 10
src/components/Adult/preview/VoiceMatrix.vue

@@ -118,7 +118,8 @@
                     ? 'selected'
                     : '',
                   column.lrc_data.begin_time / 1000 <= curTime &&
-                    (curTime < column.lrc_data.end_time / 1000 || column.lrc_data.end_time === -1)
+                    (curTime < column.lrc_data.end_time / 1000 ||
+                      column.lrc_data.end_time === -1)
                     ? 'playing'
                     : ''
                 ]"
@@ -150,7 +151,8 @@
                     ? 'selected'
                     : '',
                   column.lrc_data.begin_time / 1000 <= curTime &&
-                    (curTime < column.lrc_data.end_time / 1000 || column.lrc_data.end_time === -1)
+                    (curTime < column.lrc_data.end_time / 1000 ||
+                      column.lrc_data.end_time === -1)
                     ? 'playing'
                     : ''
                 ]"
@@ -297,11 +299,15 @@ export default {
         this.selectCell = { row: -1, column: -1 };
         return;
       }
-      this.$refs.audioLine.onTimeupdateTime(0);
       this.selectCell = { row, column };
       // 设置录音文件名
-      let { type, text, sentence_data } = this.curQue.voiceMatrix.matrix[row][column];
-      this.fileName = `${type === 'text' ? text : ''}${type === 'SentenceSegwordChs' ? sentence_data.sentence : ''}`;
+      let { type, text, sentence_data } = this.curQue.voiceMatrix.matrix[row][
+        column
+      ];
+      this.fileName = `${type === "text" ? text : ""}${
+        type === "SentenceSegwordChs" ? sentence_data.sentence : ""
+      }`;
+      if (!this.hasSelectedCell) this.handleParentPlay();
     },
 
     checkboxMouseenter(isSelected, type) {
@@ -312,6 +318,9 @@ export default {
 
     // 选中行、列
     selectRowOrColumn(index, type) {
+      this.handleParentPlay();
+      this.lrcArray = [];
+      if (this.unWatch) this.unWatch();
       if (
         this.selectedLine.type === type &&
         this.selectedLine.index === index
@@ -324,12 +333,16 @@ export default {
     },
 
     playAudio() {
-      if (!this.hasSelectedCell || this.playing) return;
+      if (!this.hasSelectedCell) return;
+      if (this.playing) return this.handleParentPlay();
       this.lrcArray = [];
       let { type, index } = this.selectedLine;
       if (type.length > 0 && index >= 0 && type === "row") {
         this.curQue.voiceMatrix.matrix[index].forEach(item => {
-          this.lrcArray.push(item.lrc_data);
+          if (
+            item.type !== "connection" ||
+            (item.type === "text" && item.text.length > 0)
+          ) { this.lrcArray.push(item.lrc_data); }
         });
         if (this.lrcArray.length > 0) this.lrcPlay(this.lrcArray[0], 0);
         return;
@@ -337,7 +350,12 @@ export default {
 
       if (type.length > 0 && index >= 0 && type === "column") {
         this.curQue.voiceMatrix.matrix.forEach(item => {
-          this.lrcArray.push(item[index].lrc_data);
+          if (
+            item.type !== "connection" ||
+            (item.type === "text" && item.text.length > 0)
+          ) {
+            this.lrcArray.push(item[index].lrc_data);
+          }
         });
         if (this.lrcArray.length > 0) this.lrcPlay(this.lrcArray[0], 0);
         return;
@@ -358,14 +376,17 @@ export default {
         this.$refs.audioLine.PlayAudio();
         if (end_time === -1) return;
         let end = end_time / 1000 - 0.01;
-        let unWatch = this.$watch("curTime", val => {
+        this.unWatch = this.$watch("curTime", val => {
           if (val >= end) {
+            if (!this.hasSelectedCell) return this.unWatch();
             this.handleParentPlay();
             this.$refs.audioLine.onTimeupdateTime(end);
-            unWatch();
+            this.unWatch();
             let i = index + 1;
             if (i < this.lrcArray.length) {
               this.lrcPlay(this.lrcArray[i], i);
+            } else {
+              this.lrcArray = [];
             }
           }
         });