使用FlowPlayer API,有没有办法捕捉视频进度?我期待捕捉视频的进度,以便我可以在视频中的某些点将事件触发到页面。在Flash中,有Progress事件触发每一帧,我希望自FlowPlayer是Flash以来,Progress事件也将暴露。我似乎无法在FlowPlayer文档中找到任何简单的内容。Flowplayer视频进度跟踪?
如果进度事件不存在。有没有关于如何使用JS setInterval和现有的FlowPlayer API方法来构建这样的东西的建议?
使用FlowPlayer API,有没有办法捕捉视频进度?我期待捕捉视频的进度,以便我可以在视频中的某些点将事件触发到页面。在Flash中,有Progress事件触发每一帧,我希望自FlowPlayer是Flash以来,Progress事件也将暴露。我似乎无法在FlowPlayer文档中找到任何简单的内容。Flowplayer视频进度跟踪?
如果进度事件不存在。有没有关于如何使用JS setInterval和现有的FlowPlayer API方法来构建这样的东西的建议?
我破解了一个JavaScript的快速片段,与Flowplayer Player
和Clip
对象进行交互以确定视频进度。
var videoProgressInterval;
flowplayer("player", "http://releases.flowplayer.org/swf/flowplayer-3.2.15.swf");
flowplayer("player").onStart(startVideoProgressChecking);
flowplayer("player").onResume(startVideoProgressChecking);
flowplayer("player").onStop(stopVideoProgressChecking);
flowplayer("player").onPause(stopVideoProgressChecking);
flowplayer("player").onFinish(stopVideoProgressChecking);
function startVideoProgressChecking() {
videoProgressInterval = setInterval(checkVideoProgress, 1000);
videoProgressInterval();
}
function stopVideoProgressChecking() {
clearInterval(videoProgressInterval);
}
function checkVideoProgress() {
var time_completed = flowplayer("player").getTime();
var total_time = flowplayer("player").getClip().fullDuration;
var percent_done = Math.floor((time_completed/total_time) * 100);
console.log(percent_done + "% of video done");
}
您可以在JSFiddle上看到演示。
它注册玩家的start
和resume
事件的事件句柄。一旦视频播放开始后,它会记录每秒运行的时间间隔(随意修改,以便更频繁地运行)。间隔在每次执行时调用checkVideoProgress()
,然后从Clip
对象获取当前播放时间和总持续时间以计算进度。
此外,事件处理程序还会为stop
,pause
和finish
事件注册,以便在视频暂停/停止后清除间隔。
也许你可以使用Flowplayers Cuepoints
(从最终要么秒或秒负)添加中cuePoints的数据属性
<div class="flowplayer" data-cuepoints="[1.5, 2, 3, -1]"><!-- video here --></div>
然后绑定一个事件:
flowplayer(function (api, root) {
api.bind("cuepoint", function (e, api, cuepoint) {
console.log(cuepoint);
});
});
我能够设计一个使用提示点的方法。我特别的问题是我需要动态地确定视频播放时间的25%和50%。我发现玩家最早发现视频持续时间在onMetaData事件中。这工作对我来说: – Lounge9
这对我工作*: https://gist.github.com/1161365 *它不适用于iOS时使用FP iPad插件。但是这似乎是一个更大的FlowPlayer问题。 – Lounge9