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的限制向前seek功能不生效 #1668

Open
ydkdev opened this issue Dec 2, 2024 · 5 comments
Open

进度条Progress的限制向前seek功能不生效 #1668

ydkdev opened this issue Dec 2, 2024 · 5 comments

Comments

@ydkdev
Copy link

ydkdev commented Dec 2, 2024

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

您使用的操作系统和浏览器分别是? What OS and browser are you using?
OS: macOS 15.0.1
Browser: Chrome Version 131.0.6778.86

如何复现问题? How to reproduce the problem?
点击视频进度条,尝试前后seek。

复现地址/reproduce demo:
https://jsbin.com/wobaqodube/edit?html,output

您期望的播放器正常行为是? What did you expect to happen?
使用progress hooks后,能正常seek,且按照hooks回调函数要求,限制向前seek功能

实际播放器的表现是? What actually happened?
点击进度条无反应。
控制台报错:Uncaught TypeError: [pluginName: progress:dragstart] >> Cannot read properties of undefined (reading 'currentTime')

@issac2005
Copy link

我也遇到了同样的问题,我的环境是win11 的chrome,官网的示例代码粘过去后拖动进度条就会报错

@ydkdev
Copy link
Author

ydkdev commented Dec 25, 2024

我也遇到了同样的问题,我的环境是win11 的chrome,官网的示例代码粘过去后拖动进度条就会报错

我目前是通过给源码打补丁解决的

@issac2005
Copy link

我也遇到了同样的问题,我的环境是win11 的chrome,官网的示例代码粘过去后拖动进度条就会报错

我目前是通过给源码打补丁解决的

是否方便粘下打过补丁的代码 感谢

@ydkdev
Copy link
Author

ydkdev commented Dec 26, 2024

补丁文件:
xgplayer+3.0.20.patch
使用方法:
1,使用patch-package这个库打补丁;
2,回调函数改成如下方法(以vue3 为例):

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

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

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

@issac2005
Copy link

好的 非常感谢! 我今天尝试下

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

2 participants