谢杰标 2 年之前
父节点
当前提交
9d4cb073e3
共有 5 个文件被更改,包括 67 次插入25 次删除
  1. 4 0
      components/course/courseModule.vue
  2. 1 1
      components/course/courseSection.vue
  3. 30 8
      components/myPlayer/polyvPlayer.vue
  4. 2 0
      pages.json
  5. 30 16
      pages3/polyv/detail.vue

+ 4 - 0
components/course/courseModule.vue

@@ -302,6 +302,7 @@ export default {
         "sectionItem",
         "menuAllList",
         "orderNum",
+        "goodsId",
       ]);
     },
     courseId() {
@@ -313,6 +314,9 @@ export default {
     orderGoodsId() {
       return this.params.orderGoodsId;
     },
+    goodsId() {
+      return this.params.goodsId;
+    },
     sectionItem() {
       return this.params.sectionItem;
     },

+ 1 - 1
components/course/courseSection.vue

@@ -345,7 +345,7 @@ export default {
       }
       this.clickLock = true;
       // && !this.menuItem.isRebuild
-      if (this.learningOrder == 2 && !this.isLive) {
+      if (this.params.orderNum == 2 && !this.isLive) {
         //要按从头到尾顺序学习, 且不是重修课程
         if (this.preItem) {
           let rows = this.menuAllList;

+ 30 - 8
components/myPlayer/polyvPlayer.vue

@@ -89,6 +89,8 @@ export default {
       hasStart: false,
       config: null,
       Elevideo: null,
+      isInitSeek: false,
+      playTime: 0,
     };
   },
   created() {
@@ -146,6 +148,7 @@ export default {
       });
     },
     wxStatechange(newstate) {
+      console.log("🚀 ~ file: polyvPlayer.vue:151 ~ wxStatechange ~ newstate:", newstate)
       polyvPlayerContext = this.selectComponent("#playerVideo");
       // ["playing", "pause", "ended","error"]
       let state = newstate.detail.newstate;
@@ -157,12 +160,14 @@ export default {
     },
     playing() {
       // #ifdef MP-WEIXIN
-      polyvPlayerContext.seek(this.videoCurrentTime || 0);
+      this.seekVideo(this.videoCurrentTime);
       // #endif
       // #ifdef H5
-      this.Elevideo = document.querySelector("video.plv-player-video");
-      this.Elevideo &&
-        this.Elevideo.addEventListener("timeupdate", this.timeupdate);
+      if (!this.Elevideo) {
+        this.Elevideo = document.querySelector("video.plv-player-video");
+        this.Elevideo &&
+          this.Elevideo.addEventListener("timeupdate", this.timeupdate);
+      }
       // #endif
     },
     resumeVideo() {
@@ -183,6 +188,14 @@ export default {
       // #endif
       // #ifdef H5
       time = this.playCurrentTime();
+      if (!this.isInitSeek) {
+        if (time >= this.vct) {
+          this.isInitSeek = true;
+        } else {
+          return;
+        }
+      }
+      this.onVideoSeek1(time);
       // #endif
       this.$emit("timeupdate", time);
     },
@@ -206,16 +219,24 @@ export default {
       }
     },
     onVideoSeek(start, end, vid) {
-      polyvPlayerContext.toggleFullscreen();
+      // if (this.allowSeek == "off") {
+      //   return;
+      // }
+      // if (end - this.playTime > 10) {
+      //   this.seekVideo(start);
+      // }
+    },
+    onVideoSeek1(time) {
       if (this.allowSeek == "off") {
         return;
       }
-      if (end - start > 10) {
-        this.seekVideo(start);
+      if (Math.abs(time - this.playTime) > 5) {
+        this.seekVideo(this.playTime);
+      } else {
+        this.playTime = time;
       }
     },
     seekVideo(time) {
-      console.log("🚀 ~ file: polyvPlayer.vue:173 ~ seekVideo ~ time:", time);
       time = time || 0;
       // #ifdef MP-WEIXIN
       polyvPlayerContext.seek(time);
@@ -366,6 +387,7 @@ export default {
   watch: {
     vct: {
       handler(time) {
+        this.playTime = time;
         if (time > 0 && !this.videoToastShow) {
           setTimeout(() => {
             this.videoToastShow = true;

+ 2 - 0
pages.json

@@ -1174,7 +1174,9 @@
     "navigationBarBackgroundColor": "#F8F8F8",
     "backgroundColor": "#F8F8F8",
     "usingComponents": {
+      // #ifdef MP-WEIXIN
       "polyv-player": "plugin://polyv-player/player"
+      // #endif
     }
   },
   "tabBar": {

+ 30 - 16
pages3/polyv/detail.vue

@@ -22,7 +22,7 @@
           :autoplay="autoplay"
           :allowSeek="isAllowSeek"
           :playbackRate="playbackRate"
-          :videoCurrentTime="recordObj.videoCurrentTime || 0"
+          :videoCurrentTime="videoCurrentTime || 0"
           @playing="playing"
           @pause="pause"
           @ended="ended"
@@ -332,7 +332,7 @@ export default {
       gradeId: 0,
       chapterId: 0,
       moduleId: 0,
-      recordObj: {},
+      videoCurrentTime: 0,
       photoIndex: 0,
       isTaking: true, //是否正在拍照
       needSeek: false, //第一次播放是否需要跳转
@@ -430,6 +430,7 @@ export default {
     },
   },
   async onLoad(option) {
+    console.log("🚀 ~ file: detail.vue:433 ~ onLoad ~ option:", option);
     if (option.isOther) {
       this.showMark = true;
       return;
@@ -451,6 +452,7 @@ export default {
     this.init();
   },
   async onShow() {
+    console.log("🚀 ~ file: detail.vue:455 ~ onShow ~ onShow:", this.isCache);
     if (this.isCache) {
       this.isCache = false;
       // #ifdef H5
@@ -461,7 +463,6 @@ export default {
       // #endif
     }
     if (this.beforeHideIsPlaying) {
-      console.log("🚀 ~ file: detail.vue:464 ~ onShow ~ beforeHideIsPlaying:", this.beforeHideIsPlaying)
       // 二建二造提示弹出来
       if (this.playSecIsLearn && this.erJianErZao && this.pauseTimer == null) {
         return;
@@ -497,6 +498,15 @@ export default {
       this.isCanLearn()
         .then((res) => {
           this.courseCourseList();
+          uni.addInterceptor("navigateTo", {
+            invoke({ url }) {
+              console.log(
+                "🚀 ~ file: detail.vue:503 ~ invoke ~ url:",
+                url.includes("/pages2/class/questionBank")
+              );
+              this.isCache = url.includes("/pages2/class/questionBank");
+            },
+          });
         })
         .catch(() => {
           setTimeout(() => {
@@ -679,12 +689,12 @@ export default {
         console.log("开启定时器");
         this.pauseTimer = setInterval(() => {
           console.log("暂停时间", Date.now() - this.pauseTime, this.pauseTime);
-          if (Date.now() - this.pauseTime > 5 * 60 * 1000) {
+          if (Date.now() - this.pauseTime > 20 * 1000) {
             // 5 * 60 * 1000
             let text = "暂停";
             if (this.showCamera) {
               text = "拍照停留";
-              this.refPlv.closeCamera();
+              this.closeCamera();
             }
             uni.showModal({
               title: "提示",
@@ -1123,6 +1133,7 @@ export default {
       return Promise.resolve();
     },
     async isCanLearn() {
+      return Promise.resolve();
       this.option.isQ !== "" && (await this.qCheckIsCanLearn());
       await this.getbaseprofiletplists();
       await this.getGradeInfo();
@@ -1290,9 +1301,12 @@ export default {
     async playVideo(item) {
       this.sectionItem = item;
       let { learning, videoCurrentTime, sectionId, recordingUrl } = item;
-      this.recordObj = videoCurrentTime
-        ? { videoCurrentTime }
-        : await this.getRecordLast(item);
+      this.videoCurrentTime =
+        videoCurrentTime || (await this.getRecordLast(item));
+      // 往前播3秒
+      if (this.videoCurrentTime > 3) {
+        this.videoCurrentTime -= 3;
+      }
       // 查找拍照历史
       if ((this.photoNum > 0 || this.jjShiGongYuan) && learning != 1) {
         await this.getPhotoLastRecord();
@@ -1303,7 +1317,7 @@ export default {
       if (this.refPlv) {
         this.refPlv.changeVid({
           vid: recordingUrl,
-          videoCurrentTime: this.recordObj.videoCurrentTime,
+          videoCurrentTime: this.videoCurrentTime,
         });
       }
     },
@@ -1319,10 +1333,7 @@ export default {
           moduleId: moduleId || 0,
         };
         this.$api.recordLast(data).then((res) => {
-          if (res.data.data.videoCurrentTime > 3) {
-            res.data.data.videoCurrentTime -= 3;
-          }
-          resolve(res.data.data);
+          resolve(res.data.data.videoCurrentTime);
         });
       });
     },
@@ -1485,7 +1496,6 @@ export default {
       }).then((res) => {});
     },
     timeupdate(time) {
-      // console.log("播放中", time);
       if (this.noticeShow) {
         this.refPlv.playPause();
         return;
@@ -1495,10 +1505,10 @@ export default {
       this.timeEvent(time);
     },
     playing() {
-      console.log("playing");
+      console.log("palying");
       this.isPlaying = true;
       this.studyLog();
-      if (!this.recordObj.videoCurrentTime) {
+      if (!this.videoCurrentTime) {
         this.postStudyRecord(0);
       }
       this.studyTimer && clearInterval(this.studyTimer);
@@ -1512,6 +1522,10 @@ export default {
       this.refPlv.playPause();
       this.refPlv.exitFullScreen();
     },
+    closeCamera() {
+      this.showCamera = false;
+      this.$refs["camera"].closeCamera();
+    },
     pause() {
       this.isPlaying = false;
       this.erJianErZaoPauseTip();