Browse Source

切换窗口暂停播放

xiejiebiao 2 năm trước cách đây
mục cha
commit
4a7fc288a2

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 305 - 625
src/pages/course-detail/index.vue


+ 7 - 0
src/pages/goods-detail/course-detail.vue

@@ -632,6 +632,7 @@ export default {
     if (this.player) {
       this.player.destroy();
     }
+    document.removeEventListener('visibilitychange', this.pauseVideo)
   },
   watch: {
     "$route.params.goodsId": {
@@ -645,6 +646,7 @@ export default {
   },
   mounted() {
     this.getInit();
+    document.addEventListener('visibilitychange', this.pauseVideo)
   },
   computed: {
     compyRecommend: function () {
@@ -665,6 +667,11 @@ export default {
   },
   methods: {
     ...mapMutations(["setCurrentRouter", "getCartCount"]),
+    pauseVideo() {
+      if (document.visibilityState === 'hidden') {
+        this.player && this.player.j2s_pauseVideo();
+      }
+    },
     getInit() {
       this.goodsId = this.$route.params.goodsId;
       this.getGoodsDetail();

+ 9 - 0
src/pages/goods-detail/live-detail.vue

@@ -652,6 +652,7 @@ export default {
     if (this.$tools.isLogin()) {
       this.getProvinceList();
     }
+    document.addEventListener('visibilitychange', this.pauseVideo)
   },
   computed: {
     compyRecommend: function () {
@@ -672,6 +673,11 @@ export default {
   },
   methods: {
     ...mapMutations(["setCurrentRouter", "getCartCount"]),
+    pauseVideo() {
+      if (document.visibilityState === 'hidden') {
+        this.player && this.player.j2s_pauseVideo();
+      }
+    },
     appCommonGoodsCourseModuleFreeExamList() {
       this.$request
         .appCommonGoodsCourseModuleFreeExamList(this.goodsId)
@@ -1703,6 +1709,9 @@ export default {
         });
     },
   },
+  beforeDestroy(){
+    document.removeEventListener('visibilitychange', this.pauseVideo)
+  }
 };
 </script>
 

+ 11 - 0
src/pages/goodsTopic/components/catalogue.vue

@@ -381,6 +381,11 @@ export default {
     ...mapGetters(["header"]),
   },
   methods: {
+    pauseVideo() {
+      if (document.visibilityState === 'hidden') {
+        this.player && this.player.j2s_pauseVideo();
+      }
+    },
     getTel(tel) {
       return tel ? tel.split(";") : [];
     },
@@ -798,6 +803,12 @@ export default {
       }
     },
   },
+  mounted(){
+    document.addEventListener('visibilitychange', this.pauseVideo)
+  },
+  beforeDestroy(){
+    document.removeEventListener('visibilitychange', this.pauseVideo)
+  }
 };
 </script>
 

+ 7 - 3
src/pages/live-detail/index.vue

@@ -2807,9 +2807,6 @@ export default {
       };
     },
   },
-  // beforeDestroy() {
-  //   this.player.destroy();
-  // },
   async mounted() {
     this.courseId = +this.$route.query.courseId || "";
     this.nowTime = Number(new Date().getTime() / 1000).toFixed(0);
@@ -2864,6 +2861,7 @@ export default {
       console.log("------");
       this.studyRecordQueryLiveLast();
     }
+    document.addEventListener('visibilitychange', this.pauseVideo)
     // let noteSecond = this.$route.query.noteSecond;
     // if (noteSecond > 0) {
     //   let item = {
@@ -2888,6 +2886,7 @@ export default {
     clearInterval(this.answerTimer);
     clearInterval(this.postTimer);
     clearInterval(this.livingTimer);
+    document.removeEventListener('visibilitychange', this.pauseVideo)
     try {
       this.$msgbox.close();
     } catch (err) {}
@@ -2910,6 +2909,11 @@ export default {
   },
   methods: {
     ...mapMutations(["getCartCount"]),
+    pauseVideo() {
+      if (document.visibilityState === 'hidden') {
+        this.player && this.player.j2s_pauseVideo();
+      }
+    },
     isLast(item) {
       if (this.liveLast) {
         let sectionASame =

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 247 - 586
src/pages/person-center/my-course/index.vue


Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác