Flowplayer 视频进度跟踪?
使用 FlowPlayer API,有没有办法捕获视频进度?我希望捕获视频的进度,以便我可以在视频中的某些点向页面触发事件。在 Flash 中,每帧都会触发 Progress 事件,我希望由于 FlowPlayer 是 Flash,因此 Progress 事件也能被暴露。我似乎在 FlowPlayer 文档中找不到任何简单的内容。
如果进度事件不存在。对于如何使用 JS setInterval 和现有的 FlowPlayer API 方法构造这样的东西有什么建议吗?
Using the FlowPlayer API, is there a way to capture Video Progress? I'm looking to capture the progress of the video so I can fire events to the page at certain points in the Video. In Flash, there is Progress Event that fires every frame, and I was hoping that since FlowPlayer is Flash, that the Progress Event would also be exposed. I can't seem to find anything as straight-forward in the FlowPlayer docs.
If a Progress Event doesn't exist. Are there any suggestions on how to construct a such a thing using JS setInterval and existing FlowPlayer API methods?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我编写了一段快速的 Javascript 代码片段,它与 Flowplayer
Player
和Clip
对象交互以确定视频进度。您可以在 JSFiddle 上查看演示。
它为播放器的
start
和resume
事件注册事件句柄。视频播放开始后,它会注册一个每秒运行的间隔(请随意修改此间隔以更频繁地运行)。该间隔每次执行时都会调用checkVideoProgress()
,然后从Clip
对象获取当前播放时间和总持续时间来计算进度。此外,还为
stop
、pause
和finish
事件注册了事件处理程序,以便在视频暂停/停止后清除间隔。I hacked up a quick snippet of Javascript that interacts with the Flowplayer
Player
andClip
objects to determine the video progress.You can see a demo on JSFiddle.
It registers event handles for the
start
andresume
events of the player. Once video playback has begun, it registers an interval which runs every second (feel free to modify this to run more often). The interval callscheckVideoProgress()
every time it gets executed which then gets the current playback time and total duration from theClip
object to calculate the progress.Additionally, an event handler is also registered for
stop
,pause
andfinish
events to clear the interval once the video has been paused/stopped.也许您可以使用 Flowplayers Cuepoints
将提示点添加到 data 属性(秒或距离结束的秒数)减号)
然后绑定一个事件:
Maybe you can use Flowplayers Cuepoints
Add cuepoints to the data property (either seconds, or seconds from end with a minus)
Then bind an event: