|
@@ -29,6 +29,45 @@ function getSourceType(src: string) {
|
|
|
return `video/${ext}`
|
|
|
}
|
|
|
|
|
|
+/* view_type = [
|
|
|
+ "txwx_jtjy_zj",
|
|
|
+ "txwx_mszy_zj",
|
|
|
+ "txwx_tskc_zj",
|
|
|
+ "txwx_zyfd"
|
|
|
+] */
|
|
|
+// function updateViewLog(d?: object) {
|
|
|
+// request({
|
|
|
+// url: '/openapi/user_view_log.php',
|
|
|
+// data: {
|
|
|
+// ...d,
|
|
|
+// },
|
|
|
+// })
|
|
|
+// }
|
|
|
+
|
|
|
+let timer: null | NodeJS.Timer = null
|
|
|
+let count = 0
|
|
|
+
|
|
|
+const INTERVAL = 2 * 3
|
|
|
+function startTimer(payload?: object) {
|
|
|
+ if (timer === null) {
|
|
|
+ timer = setInterval(() => {
|
|
|
+ count++
|
|
|
+ console.log('count : ', count)
|
|
|
+ if (count % INTERVAL === 0) {
|
|
|
+ console.log('3min')
|
|
|
+ emits('scoreAtTarget', payload)
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function pauseTimer() {
|
|
|
+ if (timer !== null) {
|
|
|
+ clearInterval(timer)
|
|
|
+ timer = null
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
if (!videoPlayerRef.value)
|
|
|
return
|
|
@@ -44,7 +83,7 @@ onMounted(() => {
|
|
|
'PlayToggle', // 播放
|
|
|
'NextBtn', // 下一个
|
|
|
'CurrentTimeDisplay', // 当前时间
|
|
|
- // 'ProgressControl', // 进度条
|
|
|
+ 'ProgressControl', // 进度条
|
|
|
'DurationDisplay', // 时长
|
|
|
'VolumePanel', // 音量
|
|
|
'PlaybackRateMenuButton', // 倍速
|
|
@@ -61,19 +100,33 @@ onMounted(() => {
|
|
|
},
|
|
|
() => {
|
|
|
console.log('player is ready')
|
|
|
+ timer = null
|
|
|
+ count = 0
|
|
|
const p = player.value
|
|
|
- let callbackExecuted = false
|
|
|
- p.on('timeupdate', () => {
|
|
|
- // 计算视频已经播放的百分比
|
|
|
- const percentagePlayed = p.currentTime() / p.duration()
|
|
|
+ // p.on('timeupdate', () => {
|
|
|
+ // // 计算视频已经播放的百分比
|
|
|
+ // const percentagePlayed = p.currentTime() / p.duration()
|
|
|
|
|
|
- if (percentagePlayed >= 0.9 && !callbackExecuted) {
|
|
|
- // 执行回调函数
|
|
|
- console.log('达到目标时间')
|
|
|
- emits('scoreAtTarget')
|
|
|
- p.off('timeupdate')
|
|
|
- callbackExecuted = true
|
|
|
- }
|
|
|
+ // if (percentagePlayed >= 0.9 && !callbackExecuted) {
|
|
|
+ // // 执行回调函数
|
|
|
+ // console.log('达到目标时间')
|
|
|
+ // emits('scoreAtTarget')
|
|
|
+ // p.off('timeupdate')
|
|
|
+ // callbackExecuted = true
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ p.on('play', () => {
|
|
|
+ console.log('视频播放开始')
|
|
|
+ startTimer()
|
|
|
+ })
|
|
|
+ p.on('pause', () => {
|
|
|
+ console.log('视频暂停')
|
|
|
+ pauseTimer()
|
|
|
+ })
|
|
|
+ p.on('ended', () => {
|
|
|
+ console.log('视频播放结束')
|
|
|
+ pauseTimer()
|
|
|
+ emits('scoreAtTarget', { isover: 1 })
|
|
|
})
|
|
|
},
|
|
|
)
|