Sfoglia il codice sorgente

Merge branch 'gcj'

guanchunjie 3 anni fa
parent
commit
a099edbcb4

+ 13 - 2
src/components/Adult/preview/DialogueArticleViewChs/NormalModelChs.vue

@@ -16,7 +16,10 @@
             :getCurTime="getCurTime"
             :mp3Source="curQue.mp3_list[0].source"
             :width="625"
+            :ed="ed"
+            type="audioLine"
             ref="audioLine"
+            @emptyEd="emptyEd"
           />
         </template>
       </div>
@@ -87,7 +90,10 @@
                       item.timeList &&
                         item.timeList.length > 0 &&
                         item.timeList[pItem.sentIndex].bg,
-                      item
+                      item,
+                      item.timeList &&
+                        item.timeList.length > 0 &&
+                        item.timeList[pItem.sentIndex].ed
                     )
                   "
                 >
@@ -372,6 +378,7 @@ export default {
       curNoteCon: null,
       screenHeight: 0,
       contentWidth: 732,
+      ed: undefined,
     };
   },
   computed: {
@@ -573,11 +580,15 @@ export default {
       return listRes;
     },
     //点击播放某个句子
-    handleChangeTime(time, item) {
+    handleChangeTime(time, item, ed) {
       if (item.timeList && item.timeList.length > 0) {
         this.curTime = time;
         this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
       }
+      this.ed = ed;
+    },
+    emptyEd() {
+      this.ed = undefined;
     },
     viewNotes(e, noteNum) {
       let _this = this;

+ 49 - 40
src/components/Adult/preview/WordPhrase.vue

@@ -40,7 +40,7 @@
             <div
               :class="[
                 'NPC-word-row',
-                mp3_index == sItem.sIndex ? 'active' : '',
+                playClass && mp3_index == sItem.sIndex ? 'active' : '',
               ]"
               v-for="(sItem, sIndex) in item"
               :key="'curQue.option.child' + sIndex"
@@ -59,7 +59,7 @@
                       : themeColor == 'red'
                       ? 'NPC-play-btn-red'
                       : 'NPC-play-btn-brown',
-                    mp3_index == sItem.sIndex ? 'active' : '',
+                    playClass && mp3_index == sItem.sIndex ? 'active' : '',
                   ]"
                   @click="palyAudio(sItem.sIndex)"
                 ></span>
@@ -215,7 +215,7 @@ export default {
       detailIndex: 0,
       audio: new Audio(),
       playClass: "",
-      mp3_index: -1,
+      mp3_index: 0,
       playWord: null,
       optionRes: [],
       mp3List: [],
@@ -265,12 +265,16 @@ export default {
       let _this = this;
       if (_this.playWord) {
         let _this = this;
-        _this.playWord.addEventListener("play", function () {});
+        _this.playWord.addEventListener("play", function () {
+          _this.playClass = "nn";
+        });
         _this.playWord.addEventListener("pause", function () {
-          _this.mp3_index = -1;
+          _this.mp3_index = 0;
+          _this.playClass = "";
         });
         _this.playWord.addEventListener("ended", function () {
-          _this.mp3_index = -1;
+          _this.mp3_index = 0;
+          _this.playClass = "";
         });
       }
     },
@@ -303,25 +307,38 @@ export default {
       if (_this.playWord) {
         _this.playWord.pause();
       }
-      let mp3_index = 0;
-      let leg = _this.mp3List.length;
-      let mp3 = _this.mp3List[mp3_index].mp3_list[0].id;
-      _this.mp3_index = _this.mp3List[mp3_index].sIndex;
-      _this.handlePlayVoice(mp3);
-      _this.$refs.newwordAudio.addEventListener("ended", function () {
-        if (mp3_index < leg - 1) {
-          mp3_index = mp3_index + 1;
-          _this.mp3_index = _this.mp3List[mp3_index].sIndex;
-          mp3 =
-            _this.mp3List[mp3_index].mp3_list.length > 0 &&
-            _this.mp3List[mp3_index].mp3_list[0].id;
-          if (mp3) {
-            _this.handlePlayVoice(mp3);
-          }
-        } else {
-          _this.mp3_index = -1;
-        }
-      });
+      if (_this.playClass) {
+        _this.$refs.newwordAudio.pause();
+        // _this.mp3_index = -1;
+        _this.playClass = "";
+      } else {
+        let mp3_index = _this.mp3_index;
+        let leg = _this.mp3List.length;
+        let mp3 = _this.mp3List[mp3_index].mp3_list[0].id;
+        _this.mp3_index = _this.mp3List[mp3_index].sIndex;
+        _this.handlePlayVoice(mp3);
+        _this.$refs.newwordAudio.addEventListener("ended", function () {
+          setTimeout(() => {
+            if (_this.playClass != "nn") {
+              if (mp3_index < leg - 1) {
+                if (_this.playClass) {
+                  mp3_index = mp3_index + 1;
+                  _this.mp3_index = _this.mp3List[mp3_index].sIndex;
+                  mp3 =
+                    _this.mp3List[mp3_index].mp3_list.length > 0 &&
+                    _this.mp3List[mp3_index].mp3_list[0].id;
+                  if (mp3) {
+                    _this.handlePlayVoice(mp3);
+                  }
+                }
+              } else {
+                _this.mp3_index = 0;
+                _this.playClass = "";
+              }
+            }
+          }, 1000);
+        });
+      }
     },
     handlePlayVoice3(mp3) {
       let _this = this;
@@ -356,17 +373,12 @@ export default {
       if (!mp3) {
         return;
       }
-      if (!_this.$refs.newwordAudio.paused) {
-        _this.$refs.newwordAudio.pause();
-        _this.mp3_index = -1;
-      } else {
-        setTimeout(() => {
-          _this.$refs.newwordAudio.pause();
-          _this.$refs.newwordAudio.src = mp3;
-          _this.$refs.newwordAudio.load();
-          _this.$refs.newwordAudio.play();
-        }, 10);
-      }
+      // setTimeout(() => {
+      //_this.$refs.newwordAudio.pause();
+      _this.$refs.newwordAudio.src = mp3;
+      //_this.$refs.newwordAudio.load();
+      _this.$refs.newwordAudio.play();
+      // }, 1000);
     },
     stopAudio() {
       this.$refs.newwordAudio.pause();
@@ -410,10 +422,7 @@ export default {
       _this.playClass = "active";
     });
     _this.$refs.newwordAudio.addEventListener("pause", function () {
-      _this.playClass = "";
-    });
-    _this.$refs.newwordAudio.addEventListener("ended", function () {
-      _this.playClass = "";
+      //_this.playClass = "";
     });
   },
   //生命周期-创建之前