From 8ba5b1346308451e2c66f4414aa2c0b242d503d2 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期四, 27 六月 2024 15:31:49 +0800
Subject: [PATCH] 英语音频播放优化

---
 src/books/English/view/components/chapter001.vue |   14 +++++---------
 src/books/artAndDance/view/components/index.vue  |    1 -
 src/App.vue                                      |    2 +-
 src/books/English/view/components/index.vue      |   24 ++++++++++++++++++++----
 4 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/src/App.vue b/src/App.vue
index 16e08b0..ef3b19b 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -65,7 +65,7 @@
         process.env.VUE_APP_RESOURCE_CTX +
           (process.env.VUE_APP_ENV == "product"
             ? process.env.VUE_APP_BOOK_ID
-            : "artAndDance")
+            : "english")
       );
       // 娴嬭瘯璇曡30椤�
       // this.activeBook.tryPageCount = 10;
diff --git a/src/books/English/view/components/chapter001.vue b/src/books/English/view/components/chapter001.vue
index db5f535..6fee5eb 100644
--- a/src/books/English/view/components/chapter001.vue
+++ b/src/books/English/view/components/chapter001.vue
@@ -288,7 +288,7 @@
             <h3 id="c002" class="fl al-cn">
               <span class="bjh3">Listening</span>
               <!--controlslist="noplaybackrate nodownload"鍚庨潰鐨勯煶棰戞鍔犲叆杩欎釜-->
-              <audio :src="resource.listenOne" controls controlslist="noplaybackrate nodownload" class="audio" @play="audioPlay"></audio>
+              <audio :src="resource.listenOne" controls controlslist="noplaybackrate nodownload" class="audio" ></audio>
             </h3>
             <p>
               <b>Four foreigners are talking about their impressions on Chinese
@@ -357,7 +357,7 @@
             </p>
             <p class="center"><b>My Experience in Wonderland</b></p>
             <p class="center">
-            <audio :src="resource.readingOne" controls controlslist="noplaybackrate nodownload" class="audio" @play="audioPlay"></audio>
+            <audio :src="resource.readingOne" controls controlslist="noplaybackrate nodownload" class="audio" ></audio>
 
             </p>
             <p class="block">
@@ -452,7 +452,7 @@
               <span class="line-border-box"></span>
             </p>
             <audio :src="resource.readingTwo" controls controlslist="noplaybackrate nodownload" style="margin-left: 10px" class="audio"
-              @play="audioPlay"></audio>
+              ></audio>
             <p>wonderland /藞w蕦nd蓹l忙nd/ <i>n.</i> 鏈夎澶氬濡欎簨鐗╃殑鍦版柟</p>
             <div class="bkbj">
               <p><i>land or place full of marvels or wonderful things</i></p>
@@ -1613,7 +1613,7 @@
               <span class="line-border-box"></span>
             </p>
             <audio :src="resource.readingTwo" controls controlslist="noplaybackrate nodownload" style="margin-left: 10px" class="audio"
-              @play="audioPlay"></audio>
+              ></audio>
             <p>breeze /bri藧z/ <i>n.</i> 寰锛涘拰椋�</p>
             <div class="bkbj">
               <p><i>a light wind</i></p>
@@ -1994,7 +1994,7 @@
                 to China and fill in the blanks with what you hear.</b>
             </p>
             <audio :src="resource.readingTwo" controls controlslist="noplaybackrate nodownload" style="margin-left: 10px" class="audio"
-              @play="audioPlay"></audio>
+              ></audio>
             <p>
               After studying in China for almost three years by now,I call China
               my second homeland.I love the natural beauty,the 1.________,the
@@ -2635,7 +2635,6 @@
       };
     },
     setBookQuestion() {
-      console.log("淇濆瓨");
       localStorage.setItem(
         "english-book-question-one",
         JSON.stringify(this.questionData)
@@ -2742,9 +2741,6 @@
       this.setTestData()
       console.log(this.testData);
 
-    },
-    audioPlay() {
-      this.$emit("closeMiniAudio");
     },
   },
 };
diff --git a/src/books/English/view/components/index.vue b/src/books/English/view/components/index.vue
index 4b14da9..60252e6 100644
--- a/src/books/English/view/components/index.vue
+++ b/src/books/English/view/components/index.vue
@@ -14,25 +14,21 @@
       ></pageHeader>
       <chapterOne
         @saveCharacters="saveCharacters"
-        @closeMiniAudio="closeMiniAudio"
         v-if="showCatalogList.indexOf(2) > -1"
         :showPageList="loadPageList"
       ></chapterOne>
       <chapterTwo
         @saveCharacters="saveCharacters"
-        @closeMiniAudio="closeMiniAudio"
         v-if="showCatalogList.indexOf(3) > -1"
         :showPageList="loadPageList"
       ></chapterTwo>
       <chapterThree
         @saveCharacters="saveCharacters"
-        @closeMiniAudio="closeMiniAudio"
         v-if="showCatalogList.indexOf(4) > -1"
         :showPageList="loadPageList"
       ></chapterThree>
       <chapterFour
         @saveCharacters="saveCharacters"
-        @closeMiniAudio="closeMiniAudio"
         v-if="showCatalogList.indexOf(5) > -1"
         :showPageList="loadPageList"
       ></chapterFour>
@@ -112,6 +108,7 @@
         setTimeout(() => {
           this.initSwiper();
           this.initViewer();
+          this.closeAudio()
         }, 200);
       },
     },
@@ -901,6 +898,25 @@
     closeMiniAudio() {
       this.audioPath = "";
     },
+    // 鐐瑰嚮闊抽鎾斁锛屽叧闂叾浠栭煶棰�
+    closeAudio() {
+      let allAudio = (
+        this.container ? this.container : document
+      ).querySelectorAll(".audio");
+      for (let index = 0; index < allAudio.length; index++) {
+        const item = allAudio[index];
+        item.addEventListener("play", () => {
+          const audioList = Array.from(allAudio);
+          for (let cindex = 0; cindex < audioList.length; cindex++) {
+            const citem = audioList[cindex];
+            if (citem.currentSrc != item.src) {
+              citem.pause();
+            }
+          }
+          this.closeMiniAudio();
+        });
+      }
+    },
   },
   components: {
     pageHeader,
diff --git a/src/books/artAndDance/view/components/index.vue b/src/books/artAndDance/view/components/index.vue
index e62755e..9c7b0c0 100644
--- a/src/books/artAndDance/view/components/index.vue
+++ b/src/books/artAndDance/view/components/index.vue
@@ -904,7 +904,6 @@
       for (let index = 0; index < allAudio.length; index++) {
         const item = allAudio[index];
         item.addEventListener('play',() => {
-          console.log('鎾斁',item.src);
           const audioList = Array.from(allAudio);
             for (let cindex = 0; cindex < audioList.length; cindex++) {
             const citem = audioList[cindex];

--
Gitblit v1.9.1