Browse Source

解决音频播放问题

natasha 2 years ago
parent
commit
2238e8ef2b

+ 10 - 6
src/components/Adult/Preview.vue

@@ -1232,13 +1232,17 @@ export default {
     },
     },
     puaseAudio() {
     puaseAudio() {
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        item.pause();
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            item.pause();
+        });
+      }
       let video = document.getElementsByTagName("video");
       let video = document.getElementsByTagName("video");
-      video.forEach((item) => {
-        item.pause();
-      });
+      if(video&&video.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        video.forEach((item) => {
+            item.pause();
+        });
+      }
     },
     },
     // 下一页
     // 下一页
     handleNNPEnext() {
     handleNNPEnext() {

+ 10 - 6
src/components/Adult/preview/ArticleViewChs/Practicechs.vue

@@ -525,15 +525,19 @@ export default {
     },
     },
     pauseAudio() {
     pauseAudio() {
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        item.pause();
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            item.pause();
+        });
+      }
     },
     },
     pauseVideo() {
     pauseVideo() {
       let video = document.getElementsByTagName("video");
       let video = document.getElementsByTagName("video");
-      video.forEach((item) => {
-        item.pause();
-      });
+      if(video&&video.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        video.forEach((item) => {
+            item.pause();
+        });
+      }
     },
     },
     //语音全屏
     //语音全屏
     fullScreen() {
     fullScreen() {

+ 22 - 17
src/components/Adult/preview/AudioLine.vue

@@ -171,20 +171,23 @@ export default {
     PlayAudio() {
     PlayAudio() {
       let audioId = this.audioId;
       let audioId = this.audioId;
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        if (item.src == this.mp3) {
-          if (item.id !== audioId) {
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            if (item.src == this.mp3) {
+            if (item.id !== audioId) {
+                item.pause();
+            }
+            } else {
             item.pause();
             item.pause();
-          }
-        } else {
-          item.pause();
-        }
-      });
+            }
+        });
+      }
       let video = document.getElementsByTagName("video");
       let video = document.getElementsByTagName("video");
-      video.forEach((vItem) => {
-        vItem.pause();
-      });
-
+      if(video&&video.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        video.forEach((vItem) => {
+            vItem.pause();
+        });
+      }
       if (this.audio.playing) {
       if (this.audio.playing) {
         this.$refs[audioId].pause();
         this.$refs[audioId].pause();
         this.audio.playing = false;
         this.audio.playing = false;
@@ -262,11 +265,13 @@ export default {
       this.playValue = (res / this.audio.maxTime) * 100;
       this.playValue = (res / this.audio.maxTime) * 100;
       if (playFlag) {
       if (playFlag) {
         let audio = document.getElementsByTagName("audio");
         let audio = document.getElementsByTagName("audio");
-        audio.forEach((item) => {
-          if (item.id !== audioId) {
-            item.pause();
-          }
-        });
+        if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+            audio.forEach((item) => {
+            if (item.id !== audioId) {
+                item.pause();
+            }
+            });
+        }
         this.$refs[audioId].play();
         this.$refs[audioId].play();
       }
       }
     },
     },

+ 22 - 16
src/components/Adult/preview/AudioLineSentence.vue

@@ -195,19 +195,23 @@ export default {
     PlayAudio() {
     PlayAudio() {
       let audioId = this.audioId;
       let audioId = this.audioId;
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        if (item.src == this.mp3) {
-          if (item.id !== audioId) {
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            if (item.src == this.mp3) {
+            if (item.id !== audioId) {
+                item.pause();
+            }
+            } else {
             item.pause();
             item.pause();
-          }
-        } else {
-          item.pause();
-        }
-      });
+            }
+        });
+      }
       let video = document.getElementsByTagName("video");
       let video = document.getElementsByTagName("video");
-      video.forEach((vItem) => {
-        vItem.pause();
-      });
+      if(video&&video.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        video.forEach((vItem) => {
+            vItem.pause();
+        });
+      }
       this.$set(this.audio, "isPlaying", true);
       this.$set(this.audio, "isPlaying", true);
 
 
       if (this.audio.playing) {
       if (this.audio.playing) {
@@ -289,11 +293,13 @@ export default {
       this.playValue = (time / this.audio.maxTime) * 100;
       this.playValue = (time / this.audio.maxTime) * 100;
       if (playFlag) {
       if (playFlag) {
         let audio = document.getElementsByTagName("audio");
         let audio = document.getElementsByTagName("audio");
-        audio.forEach((item) => {
-          if (item.id !== audioId) {
-            item.pause();
-          }
-        });
+        if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+            audio.forEach((item) => {
+            if (item.id !== audioId) {
+                item.pause();
+            }
+            });
+        }
         this.$refs[audioId].play();
         this.$refs[audioId].play();
       }
       }
     },
     },

+ 10 - 6
src/components/Adult/preview/DialogueArticleViewChs/Practicechs.vue

@@ -632,15 +632,19 @@ export default {
     },
     },
     pauseAudio() {
     pauseAudio() {
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        item.pause();
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            item.pause();
+        });
+      }
     },
     },
     pauseVideo() {
     pauseVideo() {
       let video = document.getElementsByTagName("video");
       let video = document.getElementsByTagName("video");
-      video.forEach((item) => {
-        item.pause();
-      });
+      if(video&&video.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        video.forEach((item) => {
+            item.pause();
+        });
+      }
     },
     },
     //语音全屏
     //语音全屏
     fullScreen(type) {
     fullScreen(type) {

+ 10 - 6
src/components/Adult/preview/PreviewDialogueNPC.vue

@@ -1052,13 +1052,17 @@ export default {
     },
     },
     puaseAudio() {
     puaseAudio() {
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        item.pause();
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            item.pause();
+        });
+      }
       let video = document.getElementsByTagName("video");
       let video = document.getElementsByTagName("video");
-      video.forEach((item) => {
-        item.pause();
-      });
+      if(video&&video.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        video.forEach((item) => {
+            item.pause();
+        });
+      }
     },
     },
     // 下一页
     // 下一页
     handleNNPEnext() {
     handleNNPEnext() {

+ 9 - 7
src/components/Adult/preview/SentenceSortQP copy.vue

@@ -196,13 +196,15 @@ export default {
     audioPlay(e) {
     audioPlay(e) {
       let url = e.target.src;
       let url = e.target.src;
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        if (item.src == url) {
-          item.play();
-        } else {
-          item.pause();
-        }
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            if (item.src == url) {
+            item.play();
+            } else {
+            item.pause();
+            }
+        });
+      }
     },
     },
   },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   //生命周期 - 创建完成(可以访问当前this实例)

+ 9 - 7
src/components/Adult/preview/SentenceSortQP.vue

@@ -188,13 +188,15 @@ export default {
     audioPlay(e) {
     audioPlay(e) {
       let url = e.target.src;
       let url = e.target.src;
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        if (item.src == url) {
-          item.play();
-        } else {
-          item.pause();
-        }
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            if (item.src == url) {
+            item.play();
+            } else {
+            item.pause();
+            }
+        });
+      }
     },
     },
   },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   //生命周期 - 创建完成(可以访问当前this实例)

+ 5 - 3
src/components/Adult/preview/VideoControl.vue

@@ -54,9 +54,11 @@ export default {
   methods: {
   methods: {
     zantingAudio() {
     zantingAudio() {
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        item.pause();
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            item.pause();
+        });
+      }
     },
     },
     // videoOut() {
     // videoOut() {
     //   if (this.VideoStatus == "播放") {
     //   if (this.VideoStatus == "播放") {

+ 5 - 3
src/components/Adult/preview/VoiceMatrix.vue

@@ -773,9 +773,11 @@ export default {
 
 
     pauseAudio() {
     pauseAudio() {
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach(item => {
-        item.pause();
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach(item => {
+            item.pause();
+        });
+      }
     },
     },
     fullScreen() {
     fullScreen() {
       this.pauseAudio();
       this.pauseAudio();

+ 5 - 3
src/components/Adult/preview/VoiceMatrixFullscreen.vue

@@ -972,9 +972,11 @@ export default {
 
 
     pauseAudio() {
     pauseAudio() {
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach(item => {
-        item.pause();
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach(item => {
+            item.pause();
+        });
+      }
     },
     },
     exitFullScreen() {
     exitFullScreen() {
       this.pauseAudio();
       this.pauseAudio();

+ 24 - 17
src/components/Adult/preview/VoiceMatrixFullscreenAudio.vue

@@ -134,19 +134,24 @@ export default {
 
 
     PlayAudio() {
     PlayAudio() {
       let audioId = this.audioId;
       let audioId = this.audioId;
-      document.getElementsByTagName("audio").forEach(item => {
-        if (item.src === this.mp3) {
-          if (item.id !== audioId) {
-            item.pause();
-          }
-        } else {
-          item.pause();
+      let audio = document.getElementsByTagName("audio");
+        if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+            audio.forEach(item => {
+                if (item.src === this.mp3) {
+                if (item.id !== audioId) {
+                    item.pause();
+                }
+                } else {
+                item.pause();
+                }
+            });
+        }
+        let video = document.getElementsByTagName("video")
+        if(video&&video.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+            video.forEach(vItem => {
+                vItem.pause();
+            });
         }
         }
-      });
-      document.getElementsByTagName("video").forEach(vItem => {
-        vItem.pause();
-      });
-
       if (this.audio.playing) {
       if (this.audio.playing) {
         this.$refs[audioId].pause();
         this.$refs[audioId].pause();
         this.audio.playing = false;
         this.audio.playing = false;
@@ -221,11 +226,13 @@ export default {
       this.playValue = (res / this.audio.maxTime) * 100;
       this.playValue = (res / this.audio.maxTime) * 100;
       if (playFlag) {
       if (playFlag) {
         let audio = document.getElementsByTagName("audio");
         let audio = document.getElementsByTagName("audio");
-        audio.forEach(item => {
-          if (item.id !== audioId) {
-            item.pause();
-          }
-        });
+        if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+            audio.forEach(item => {
+            if (item.id !== audioId) {
+                item.pause();
+            }
+            });
+        }
         this.$refs[audioId].play();
         this.$refs[audioId].play();
       }
       }
     },
     },

+ 5 - 3
src/components/Adult/preview/Voicefullscreen-ly.vue

@@ -2405,9 +2405,11 @@ export default {
     },
     },
     pauseAudio() {
     pauseAudio() {
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        item.pause();
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            item.pause();
+        });
+      }
     },
     },
     exitFullScreen() {
     exitFullScreen() {
       // this.patternType = ;
       // this.patternType = ;

+ 5 - 3
src/components/Adult/preview/Voicefullscreen.vue

@@ -1038,9 +1038,11 @@ export default {
     },
     },
     pauseAudio() {
     pauseAudio() {
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        item.pause();
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            item.pause();
+        });
+      }
     },
     },
     exitFullScreen() {
     exitFullScreen() {
       this.pauseAudio();
       this.pauseAudio();

+ 21 - 15
src/components/Adult/preview/WordPhrase.vue

@@ -286,11 +286,13 @@ export default {
       );
       );
       let mp3 = node.src;
       let mp3 = node.src;
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        if (item.src != mp3) {
-          item.pause();
-        }
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            if (item.src != mp3) {
+            item.pause();
+            }
+        });
+      }
       _this.playWord = node;
       _this.playWord = node;
       if (node) {
       if (node) {
         this.mp3_index = sIndex;
         this.mp3_index = sIndex;
@@ -380,11 +382,13 @@ export default {
     handlePlayVoice3(mp3) {
     handlePlayVoice3(mp3) {
       let _this = this;
       let _this = this;
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        if (item.src != mp3) {
-          item.pause();
-        }
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            if (item.src != mp3) {
+            item.pause();
+            }
+        });
+      }
       if (!mp3) {
       if (!mp3) {
         return;
         return;
       }
       }
@@ -402,11 +406,13 @@ export default {
       let _this = this;
       let _this = this;
 
 
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        if (item.src != mp3) {
-          item.pause();
-        }
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            if (item.src != mp3) {
+            item.pause();
+            }
+        });
+      }
       if (!mp3) {
       if (!mp3) {
         return;
         return;
       }
       }

+ 7 - 6
src/components/common/Audio.vue

@@ -32,12 +32,13 @@ export default {
     handlePlayVoice() {
     handlePlayVoice() {
       let _this = this;
       let _this = this;
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        if (item.src != _this.mp3) {
-          item.pause();
-        }
-      });
-
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            if (item.src != _this.mp3) {
+            item.pause();
+            }
+        });
+      }
       if (!_this.mp3) {
       if (!_this.mp3) {
         return;
         return;
       }
       }

+ 7 - 5
src/components/common/AudioRed.vue

@@ -24,11 +24,13 @@ export default {
     handlePlayVoice() {
     handlePlayVoice() {
       let _this = this;
       let _this = this;
       let audio = document.getElementsByTagName("audio");
       let audio = document.getElementsByTagName("audio");
-      audio.forEach((item) => {
-        if (item.src != _this.mp3) {
-          item.pause();
-        }
-      });
+      if(audio&&audio.length>0&&window.location.href.indexOf('GCLS-Learn')==-1){
+        audio.forEach((item) => {
+            if (item.src != _this.mp3) {
+            item.pause();
+            }
+        });
+      }
       if (!_this.audio.paused) {
       if (!_this.audio.paused) {
         _this.audio.pause();
         _this.audio.pause();
       } else {
       } else {