Browse Source

修改时长

lex 1 year ago
parent
commit
f7282c211e
2 changed files with 39 additions and 26 deletions
  1. 37 24
      src/student/pre-register-active/video.tsx
  2. 2 2
      vite.config.ts

+ 37 - 24
src/student/pre-register-active/video.tsx

@@ -79,24 +79,30 @@ export default defineComponent({
       const effective: any = []
       const startNode = forms.pointVideo.startNode
       const endNode = forms.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] <= endNode) {
-          // console.log(1)
-          effective.push(item)
-        }
-        // if (item[0] >= startNode && item[1] < endNode) {
-        //   console.log(2)
-        //   effective.push([item[0], item[1]])
-        // }
-        if (item[0] >= startNode && 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)
+          }
         }
       })
 
@@ -177,8 +183,7 @@ export default defineComponent({
       forms.player = new Plyr('#register-video', params)
 
       forms.player.on('ready', (item: any) => {
-        console.log('ready', item)
-
+        // console.log('ready', item)
         // forms.player.pause()
       })
       forms.player.on('loadedmetadata', () => {
@@ -213,7 +218,8 @@ export default defineComponent({
 
       // 如何视频在缓存不会触发
       forms.player.on('timeupdate', () => {
-        console.log('timeupdate', forms.player.currentTime)
+        // console.log('timeupdate', forms.player.currentTime)
+        console.log(videoIntervalRef.isActive.value, 'timeupdate')
         // 时间变化时更新每一段的状态
         checkVideoDetails(forms.player.currentTime)
         // 判断视频计时器是否暂停,如果暂停则恢复
@@ -231,6 +237,8 @@ export default defineComponent({
       // 视屏播放时暂停
       forms.player.on('ended', () => {
         forms.player.pause()
+
+        console.log(videoIntervalRef.isActive.value, 'ended')
       })
 
       // 开始播放
@@ -255,7 +263,7 @@ export default defineComponent({
         i.addEventListener('click', () => {
           forms.player.fullscreen.exit()
         })
-        console.log(document.getElementsByClassName('plyr'))
+        // console.log(document.getElementsByClassName('plyr'))
         document.getElementsByClassName('plyr')[0].appendChild(i)
       })
 
@@ -281,7 +289,7 @@ export default defineComponent({
     )
 
     const initVideoCount = (newVal: any) => {
-      // console.log(newVal, 'videoIntervalRef.isActive.value in')
+      console.log(newVal, 'videoIntervalRef.isActive.value in')
       // console.log('watch', forms.player.currentTime)
       // console.log('保留两个小数:', forms.player.currentTime.toFixed(2))
       // console.log('向下取整:', Math.floor(forms.player.currentTime))
@@ -333,7 +341,7 @@ export default defineComponent({
             videoBrowseData: JSON.stringify(videoBrowseData), // 视屏播放数据
             videoBrowseDataTime: time || 0, // 有效的视频观看时长
             videoBrowsePercentage: rate || 0, // 有效的视频观看时长百分比
-            videoBrowseTime: videoIntervalRef?.counter.value, // 视频观看时长
+            videoBrowseTime: Math.min(videoIntervalRef?.counter.value, forms.introductionVideoTime), // 视频观看时长 - 最大时长为视频总时长
             videoBrowsePoint: Math.floor(forms.player.currentTime || 0) // 视频最后观看点 - 向下取整
           }
         })
@@ -424,9 +432,14 @@ export default defineComponent({
         }, 10000)
 
         // const arr = [
-        //   [0, 8],
-        //   [9, 12],
-        //   [1, 12]
+        //   [10, 10],
+        //   [53, 53],
+        //   [64, 64],
+        //   [74, 74],
+        //   [155, 155],
+        //   [173, 173],
+        //   [183, 183],
+        //   [191, 201]
         // ]
         // console.log(formatEffectiveTime(arr))
       } catch {

+ 2 - 2
vite.config.ts

@@ -11,9 +11,9 @@ function resolve(dir: string) {
 }
 // https://vitejs.dev/config/
 // https://github.com/vitejs/vite/issues/1930 .env
-// const proxyUrl = 'https://online.lexiaoya.cn/';
+const proxyUrl = 'https://online.lexiaoya.cn/'
 // const proxyUrl = 'https://test.lexiaoya.cn/'
-const proxyUrl = 'https://dev.lexiaoya.cn/'
+// const proxyUrl = 'https://dev.lexiaoya.cn/'
 // const proxyUrl = 'http://47.98.131.38:8989/'
 // const proxyUrl = 'http://192.168.3.20:8989/' // 邹旋
 // const proxyUrl = 'http://192.168.3.143:8989/' // 尚科