Skip to content

progress的hook报错 #1692

Open
Open
@future-xhy

Description

您使用的西瓜播放器版本是多少? What version of xgplayer are you using?
3.0.20

您使用的操作系统和浏览器分别是? What OS and browser are you using?
Windows,谷歌浏览器

如何复现问题? How to reproduce the problem?
通过npm包,或者html页面直接引入都能复现

import { Events } from 'xgplayer'
let currentTime = 0

// 监听用户的播放进度
player.on(Events.TIME_UPDATE, () => {
if (player.currentTime > currentTime) {
currentTime = player.currentTime
}
})

player.usePluginHooks('progress', 'dragstart', (plugin, event, data) => {
// 当点击开始的位置计算出来的时间data.currentTime大于当前播放过的时间,则阻止默认行为
if (data.currentTime > currentTime) {
return false
}
return true
})

player.usePluginHooks('progress', 'drag', (plugin, event, data) =>{
// 当拖拽的位置计算出来的时间data.currentTime大于当前播放过的时间,则阻止默认行为
if (data.currentTime > currentTime) {
return false
}
return true
})

您期望的播放器正常行为是? What did you expect to happen?
progress的hook能正常使用

实际播放器的表现是? What actually happened?
报错:Uncaught TypeError: [pluginName: progress:dragstart] >> Cannot read properties of undefined (reading 'currentTime')

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions