Parcourir la source

切换外面回来播放优化

谢杰标 il y a 3 ans
Parent
commit
129a04a61e
1 fichiers modifiés avec 14 ajouts et 13 suppressions
  1. 14 13
      src/pages/course-detail/index.vue

+ 14 - 13
src/pages/course-detail/index.vue

@@ -3246,9 +3246,6 @@ export default {
     this.gradeId = this.$route.query.gradeId;
     this.sectionItem = this.$route.query;
     let isOther = this.$route.query.isOther || "";
-    // setTimeout(() => {
-    //   this.playNextVideo();
-    // }, 2000);
 
     if (isOther) {
       const confirmText = [
@@ -3383,10 +3380,15 @@ export default {
     ...mapMutations(["getCartCount"]),
     ...mapActions(["getUserInfo"]),
     pauseVideo() {
+      let _p = this.player
       if (document.visibilityState === "hidden") {
-        this.player && this.player.j2s_pauseVideo();
-      }else{
-        this.player && this.player.j2s_resumeVideo();
+        _p  && _p .j2s_pauseVideo();
+      } else {
+        if (_p) {
+          if(parseInt(_p .j2s_getCurrentTime())<_p .j2s_getDuration()){
+             this.player.j2s_resumeVideo();
+          }
+        }
       }
     },
     openChangeCourseBoxs() {
@@ -5188,8 +5190,8 @@ export default {
             isRebuild ? (item.isRebuild = 1) : (item.menuType = 2);
           }
           menuItem.list = res.data;
-          if(isAuto){
-            return Promise.resolve(res.data)
+          if (isAuto) {
+            return Promise.resolve(res.data);
           }
           if (isRebuild) return;
           if (status) {
@@ -6025,7 +6027,7 @@ export default {
         this.getResource(playChapter[playVideoIndex + 1], 1);
       } else if (playChapterIndex < chapterList.length - 1) {
         // 不是最后一杰
-        let nextChapter = chapterList[playChapterIndex + 1].list
+        let nextChapter = chapterList[playChapterIndex + 1].list;
         if (nextChapter.length) {
           this.getResource(nextChapter.list[0], 1);
         } else {
@@ -6035,7 +6037,7 @@ export default {
         }
       } else {
         // 章最后一个视频  跳去下一章
-        let nextChapterList = this.menuList[moduleIndex + 1].list
+        let nextChapterList = this.menuList[moduleIndex + 1].list;
         if (!nextChapterList.length) {
           this.needOpen = true;
           nextChapterList = await this.openModule(
@@ -6044,9 +6046,9 @@ export default {
             true
           );
         }
-        if(nextChapterList[0].list.length){
+        if (nextChapterList[0].list.length) {
           this.getResource(nextChapterList[0].list[0], 1);
-        }else{
+        } else {
           let data = await this.openChapter(nextChapterList[0]);
           this.getResource(data[0], 1);
         }
@@ -6066,7 +6068,6 @@ export default {
             this.photoHistoryList.length == 0
           ) {
             //开启直播拍照
-
             polyvPlayerContext.j2s_pauseVideo();
             this.openPhoto();
           } else {