Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

progress的hook报错 #1692

Open
future-xhy opened this issue Jan 13, 2025 · 0 comments
Open

progress的hook报错 #1692

future-xhy opened this issue Jan 13, 2025 · 0 comments

Comments

@future-xhy
Copy link

您使用的西瓜播放器版本是多少? 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')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant