从timeupdate的整个视频开始时,如何以10秒的间隔调用功能?
我的目标是每当用户在视频中超过10秒的间隔标记时,要发射事件,例如10、20、20、30、40秒...
我如何使用timeupdate 事件?我觉得自己很亲密,但似乎无法得到正确的答案。到目前为止,我目前的时间为〜10.250,〜10.5和〜10.75。我只需要每10秒间隔一次 。
videoPlayer.on('timeupdate', (e) => {
// Only invoke the function after the 10 second mark
if (videoPlayer.currentTime() > 10 && videoPlayer.currentTime() % 10 < 1) {
myFunc();
}
});
感谢我能获得的任何帮助!谢谢你!
My goal is to fire an event once every time the user gets past a 10 second interval mark within their video e.g. 10, 20, 30, 40 seconds...
How can I achieve this with the timeupdate
event? I feel like I'm close but can't seem to get the right answer. What I have so far is firing several times at ~10.250, ~10.5, and ~10.75 current time. I need it to only fire once per 10 second interval.
videoPlayer.on('timeupdate', (e) => {
// Only invoke the function after the 10 second mark
if (videoPlayer.currentTime() > 10 && videoPlayer.currentTime() % 10 < 1) {
myFunc();
}
});
I appreciate any help I can get! Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在几秒钟内跟踪当前时间,并在更改时才更新。例如:
Try keeping track of the current time in seconds and updating only when it changes. For example: