如何在流播放器中获得时间
How to get time in flowplayer?
我想知道如何在flowplayer中获得当前播放时间?
即使在播放过程中,这行代码也会返回一个异常:playertime=$f().getTime();
我包含了调用getTime()的Javascript
Javascript:enjo.js
setInterval(function() {
var playertime = 0;
var duration = 0;
try {
duration = $f().getClip().duration;
// alert(duration); /* This works fine*/
playertime = $f().getTime(); /* This throws an exception outside try-catch. Uncaught exception: Error in Actionscript. Use a try/catch block to find error.*/
if (isNaN(playertime)) {
// no clip running
playertime = 0;
}
} catch (err) {
playertime = 0;
}
$.ajax({
url : "/enjoy_ajax/",
type : "POST",
data : {
code : $('#code').val(),
playback : playertime
}
}).done(function() {
$(this).addClass("done");
});
}, 1000 * 60 * 0.05); // where X is your every X minutes
这是包含enjoy.js的HTML
HTML
{% extends "movies/template.html" %}
{% load aws-tags %}
{% block title %}{{ movie.title }}{% endblock %}
{% block js %}
<script src="https://s3.amazonaws.com/MY_AMAZON_S3_BUCKET/flowplayer/flowplayer-3.2.10.min.js"></script>
<script src="https://s3.amazonaws.com/MY_AMAZON_S3_BUCKET/flowplayer/flowplayer.ipad-3.2.9.min.js"></script>
{% endblock %}
{% block content %}
<div id="title">
Enjoy The Show!
</div>
<div id="movie_player">
<a id="player" href="{{signed_url}}"> </a>
<script type="text/javascript">
$(document).ready(function() {
if(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i)) {
$f("player", {
src : "https://s3.amazonaws.com/MY_AMAZON_S3_BUCKET/flowplayer/flowplayer.commercial-3.2.11.swf",
wmode : 'opaque'
}, {
key : '{{player_key}}',
clip : {
// preserve aspect ratios
scaling : 'fit'
}
}).ipad({
simulateiDevice : true,
controls : true
});
} else {
$f("player", {
src : "https://s3.amazonaws.com/MY_AMAZON_S3_BUCKET/flowplayer/flowplayer.commercial-3.2.11.swf",
wmode : 'opaque'
}, {
key : '{{player_key}}',
clip : {
provider : 'rtmp',
autoPlay : true,
urlResolvers : 'brselect',
// preserve aspect ratios
scaling : 'fit',
bitrates : [
// use the 800 kbps item by default, the SD item, marked with sd: true
{
url : "mp4:{{movie.mp4_file_lo|aws_sign_cf_stream}}",
bitrate : 320,
sd : true,
isDefault : false
},
// this is the HD item, marked with hd: true
{
url : "mp4:{{movie.mp4_file_hi|aws_sign_cf_stream}}",
bitrate : 1066,
hd : true,
isDefault : true
}]
},
plugins : {
brselect : {
url : "https://s3.amazonaws.com/MY_AMAZON_S3_BUCKET/flowplayer/flowplayer.bitrateselect-3.2.10.swf",
// comment this out in production
onStreamSwitch : function(newItem) {
$f().getPlugin('content').setHtml("Switched to: " + newItem.streamName);
},
hdButton : {
// custom labels for the HD splash
splash : false,
place : 'controls'
}
},
rtmp : {
url : 'https://s3.amazonaws.com/MY_AMAZON_S3_BUCKET/flowplayer/flowplayer.rtmp-3.2.10.swf',
netConnectionUrl : 'rtmpe://{{cloudfront_domain}}/cfx/st'
}
}
}).ipad();
}
});
</script>
</div>
<hr id="green_hr" />
<div id="movie_poster">
<img src="{{ movie.poster_url }}" alt ="" />
</div>
<div id="movie_title">
{{ movie.title }}
</div>
<div id="movie_description">
{{ movie.description }}
</div>
<input type="hidden" id="code" name="code" value="{{code}}" />
<script type="text/javascript" src="{{STATIC_URL}}javascript/enjoy.js"></script>
{% endblock %}
var playerapi = flowplayer($(".flowplayer"));
alert(playerapi.ready ? playerapi.video.time : 0);
使用此
此处,提醒(playerapi.ready?playerapi.video.time:0)此节目为当前时间。
相关文章:
- 如何检查用户在html5视频播放器中观看了完整的视频
- 音乐播放器使用相同的id播放所有内容
- 在FF和IE中使用vimeo播放器的问题-加载flash播放器而不是使用HTML5播放器
- 使用HTML5播放器时使用Javascript更改Youtube视频
- 如何在模式弹出窗口中使用引导程序日期和时间选择器
- 可以't根据设备自动调整youtube播放器的大小
- html5视频播放器和视频js之间的关系
- 两个日期时间选择器
- 有没有办法在dailymotion播放器的新测试版中播放youtube视频
- 如何在流播放器中获得时间
- 在WordPress中的Youtube播放器中包含跳转到特定时间的链接
- 在视频播放器中达到特定时间时滚动
- 检测用户播放视频JW播放器7的时间
- 如何为html5音频播放器创建自定义时间轴
- SMF播放器时间轴属性
- 是否有一个用于媒体播放器时间控制的HTML组件?
- 获得当前嵌入iframe youtube播放器的时间
- 添加HTML音频播放器时间轴功能
- 音频持续时间返回NaN需要一些修改来运行播放器
- JW播放器根据经过的时间执行操作