|
@@ -9,7 +9,6 @@ import { useRoute, useRouter } from 'vue-router'
|
|
|
import request from '@/helpers/request'
|
|
|
import qs from 'query-string'
|
|
|
import { usePageVisibility } from '@vant/use'
|
|
|
-import deepClone from '@/helpers/deep-clone'
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'pre-register',
|
|
@@ -220,7 +219,7 @@ export default defineComponent({
|
|
|
// 如何视频在缓存不会触发
|
|
|
forms.player.on('timeupdate', () => {
|
|
|
// console.log('timeupdate', forms.player.currentTime)
|
|
|
- // console.log(videoIntervalRef.isActive.value, 'timeupdate')
|
|
|
+ console.log(videoIntervalRef.isActive.value, 'timeupdate')
|
|
|
// 时间变化时更新每一段的状态
|
|
|
checkVideoDetails(forms.player.currentTime)
|
|
|
// 判断视频计时器是否暂停,如果暂停则恢复
|
|
@@ -289,28 +288,18 @@ export default defineComponent({
|
|
|
}
|
|
|
)
|
|
|
|
|
|
- /**
|
|
|
- * 初始化视频时长
|
|
|
- * @param newVal 播放状态
|
|
|
- * @param repeat 是否为定时发送的
|
|
|
- */
|
|
|
- const initVideoCount = (newVal: any, repeat = false) => {
|
|
|
+ const initVideoCount = (newVal: any) => {
|
|
|
+ console.log(newVal, 'videoIntervalRef.isActive.value in')
|
|
|
// console.log('watch', forms.player.currentTime)
|
|
|
- const initTime = deepClone(tempTime)
|
|
|
- if (repeat) {
|
|
|
- if (tempTime.length > 0) {
|
|
|
- // console.log('join video', tempTime, 'initTime', initTime)
|
|
|
- tempTime[1] = Math.floor(forms.player.currentTime)
|
|
|
- }
|
|
|
+ // console.log('保留两个小数:', forms.player.currentTime.toFixed(2))
|
|
|
+ // console.log('向下取整:', Math.floor(forms.player.currentTime))
|
|
|
+ // console.log('向上取整:', Math.ceil(forms.player.currentTime))
|
|
|
+ // console.log('四舍五入:', Math.round(forms.player.currentTime))
|
|
|
+ if (newVal) {
|
|
|
+ tempTime[0] = Math.floor(forms.player.currentTime)
|
|
|
} else {
|
|
|
- if (newVal) {
|
|
|
- tempTime[0] = Math.floor(forms.player.currentTime)
|
|
|
- } else {
|
|
|
- tempTime[1] = Math.floor(forms.player.currentTime)
|
|
|
- }
|
|
|
+ tempTime[1] = Math.floor(forms.player.currentTime)
|
|
|
}
|
|
|
-
|
|
|
- // console.log(newVal, repeat, tempTime, tempTime.length, 'videoIntervalRef.isActive.value in')
|
|
|
// console.log(forms.player.speed, 'speed')
|
|
|
|
|
|
if (tempTime.length >= 2) {
|
|
@@ -318,15 +307,11 @@ export default defineComponent({
|
|
|
// 处理在短时间内的时间差 【视屏拖动,点击可能会导致时间差太大】
|
|
|
const diffTime =
|
|
|
tempTime[1] - tempTime[0] - currentTimer.counter.value * forms.playerSpeed > 2
|
|
|
- // console.log(diffTime, 'diffTime', currentTimer.counter.value, forms.playerSpeed, 'value')
|
|
|
+ // console.log(diffTime, 'diffTime', currentTimer.counter.value, 'value')
|
|
|
// 结束时间,如果 大于开始时间则清除
|
|
|
if (tempTime[1] >= tempTime[0] && !diffTime) moreTime.value.push(tempTime)
|
|
|
- if (repeat) {
|
|
|
- tempTime = deepClone(initTime)
|
|
|
- } else {
|
|
|
- tempTime = []
|
|
|
- currentTimer.counter.value = 0
|
|
|
- }
|
|
|
+ tempTime = []
|
|
|
+ currentTimer.counter.value = 0
|
|
|
}
|
|
|
|
|
|
// console.log('观看的时间', moreTime)
|
|
@@ -447,9 +432,6 @@ export default defineComponent({
|
|
|
// 页面时间恢复
|
|
|
pageTimer.counter.value = 0
|
|
|
pageTimer.resume()
|
|
|
- // 同步数据时先进行有效时间进行保存
|
|
|
- initVideoCount(false, true)
|
|
|
-
|
|
|
await updateStat()
|
|
|
videoIntervalRef.counter.value = 0
|
|
|
}, 10000)
|