Browse Source

修改逻辑

lex 1 year ago
parent
commit
8ada3c1e6a
1 changed files with 26 additions and 55 deletions
  1. 26 55
      src/views/student-register/index.tsx

+ 26 - 55
src/views/student-register/index.tsx

@@ -280,50 +280,6 @@ export default defineComponent({
       return res;
     };
 
-    const formatEffectiveTimeToAfter = (res: any[]) => {
-      // 格式化有效时间
-      const effective: any = [];
-      const startNode = videoForms.pointVideo.startNode;
-      const endNode = videoForms.pointVideo.endNode;
-      // console.log(startNode, endNode, 'startNode')
-      res.forEach((item: any) => {
-        // 开始时间大于 设置时间
-        if (item[1] >= item[0]) {
-          /**
-           * 1、开始时间
-           */
-          if (
-            item[0] >= startNode &&
-            item[0] <= endNode &&
-            item[1] <= endNode
-          ) {
-            // console.log(1)
-            effective.push(item);
-          }
-          if (item[0] >= startNode && item[0] <= endNode && item[1] > endNode) {
-            // console.log(3)
-            effective.push([item[0], endNode]);
-          }
-          if (
-            item[0] < startNode &&
-            item[1] > startNode &&
-            item[1] <= endNode
-          ) {
-            // console.log(4)
-            effective.push([startNode, item[1]]);
-          }
-
-          if (item[0] < startNode && item[1] > startNode && item[1] > endNode) {
-            // console.log(4)
-            effective.push([startNode, endNode]);
-          }
-        }
-      });
-
-      // console.log(effective, 'effective')
-      return effective;
-    };
-
     /**
      * 获取数据有效期
      * @param intervals [[], []]
@@ -1236,10 +1192,14 @@ export default defineComponent({
         const rate = Math.floor(
           (time / Math.floor(videoForms.player.duration())) * 100
         );
-        console.log(
-          videoIntervalRef?.counter.value,
-          'videoIntervalRef?.counter.value'
-        );
+        console.log({
+          useTime: pageBrowseTime, // 固定5秒
+          videoBrowseData: JSON.stringify(videoBrowseData), // 视屏播放数据
+          videoBrowseDataTime: time || 0, // 有效的视频观看时长
+          videoBrowsePercentage: rate || 0, // 有效的视频观看时长百分比
+          videoBrowseTime: videoIntervalRef?.counter.value, // 视频观看时长
+          videoBrowsePoint: Math.floor(videoForms.player.currentTime() || 0) // 视频最后观看点 - 向下取整
+        });
         const { data } = await requestStudent.post(
           '/edu-app/open/studentRegisterPointRecord/update',
           {
@@ -1347,8 +1307,7 @@ export default defineComponent({
         // videoForms.player.poster(videoForms.coverImg || '');
 
         videoForms.player.on('ready', (item: any) => {
-          console.log('ready', item);
-
+          // console.log('ready', item);
           // videoForms.player.pause()
         });
         videoForms.player.on('loadedmetadata', () => {
@@ -1360,8 +1319,8 @@ export default defineComponent({
         // 速度变化时
         videoForms.player.on('ratechange', () => {
           videoForms.playerSpeed =
-            videoForms.playerSpeed < videoForms.player.speed
-              ? videoForms.player.speed
+            videoForms.playerSpeed < videoForms.player.playbackRate()
+              ? videoForms.player.playbackRate()
               : videoForms.playerSpeed;
         });
 
@@ -1387,10 +1346,16 @@ export default defineComponent({
           console.log('timeupdate', videoForms.player.currentTime());
           // 判断视频计时器是否暂停,如果暂停则恢复
           // 添加 「videoForms.player.playing」 是由会跳转到上次播放时间,会触发些方法
+          console.log(
+            videoIntervalRef.isActive.value,
+            videoForms.player.currentTime(),
+            videoForms.player.paused(),
+            'timeupdate'
+          );
           if (
             !videoIntervalRef.isActive.value &&
             videoForms.player.currentTime() > 0 &&
-            videoForms.player.playing
+            !videoForms.player.paused()
           ) {
             // console.log('timeupdate play')
             videoIntervalRef.resume();
@@ -1474,8 +1439,14 @@ export default defineComponent({
         }
       }
 
-      // console.log(newVal, repeat, tempTime, tempTime.length, 'videoIntervalRef.isActive.value in')
-      // console.log(videoForms.player.speed, 'speed')
+      console.log(
+        newVal,
+        repeat,
+        tempTime,
+        tempTime.length,
+        'videoIntervalRef.isActive.value in'
+      );
+      console.log(videoForms.player.playbackRate(), 'speed');
 
       if (tempTime.length >= 2) {
         // console.log(tempTime, 'tempTime', moreTime.value)