Javascript 如何在flowplayer中获得时间?
我想知道如何在flowplayer中获取当前播放时间 即使在播放过程中,这行代码也会返回一个异常:playertime=$f().getTime() 我包括了调用getTime()的Javascript Javascript:previous.jsJavascript 如何在flowplayer中获得时间?,javascript,jquery,flowplayer,Javascript,Jquery,Flowplayer,我想知道如何在flowplayer中获取当前播放时间 即使在播放过程中,这行代码也会返回一个异常:playertime=$f().getTime() 我包括了调用getTime()的Javascript Javascript:previous.js setInterval(function() { var playertime = 0; var duration = 0; try { duration = $f().getClip().duration;
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
这是包含previous.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
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 %}
{%extends“movies/template.html”%}
{%加载aws标记%}
{%block title%}{{movie.title}{%endblock%}
{%block js%}
{%endblock%}
{%block content%}
享受这场演出!
$(文档).ready(函数(){
if(navigator.userAgent.match(/iPhone/i)| navigator.userAgent.match(/iPad/i)| navigator.userAgent.match(/iPod/i)){
$f(“玩家”{
src:“https://s3.amazonaws.com/MY_AMAZON_S3_BUCKET/flowplayer/flowplayer.commercial-3.2.11.swf",
wmode:“不透明”
}, {
键:{{player_key}}},
剪辑:{
//保持纵横比
缩放:“适合”
}
}).ipad({
模拟设备:是的,
控件:true
});
}否则{
$f(“玩家”{
src:“https://s3.amazonaws.com/MY_AMAZON_S3_BUCKET/flowplayer/flowplayer.commercial-3.2.11.swf",
wmode:“不透明”
}, {
键:{{player_key}}},
剪辑:{
提供程序:“rtmp”,
自动播放:对,
urlResolvers:'brselect',
//保持纵横比
缩放:“适合”,
比特率:[
//默认情况下使用800 kbps项,即标有SD:true的SD项
{
url:{movie.mp4_file_lo|aws_sign_cf_stream}},
比特率:320,
sd:没错,
isDefault:错误
},
//这是HD项,标记为HD:true
{
url:{movie.mp4_file_hi|aws_sign_cf_stream}},
比特率:1066,
高清:是的,
isDefault:正确
}]
},
插件:{
br选择:{
url:“https://s3.amazonaws.com/MY_AMAZON_S3_BUCKET/flowplayer/flowplayer.bitrateselect-3.2.10.swf",
//在生产中对此进行评论
onStreamSwitch:函数(newItem){
$f().getPlugin('content').setHtml(“切换到:“+newItem.streamName”);
},
HDB按钮:{
//HD splash的自定义标签
飞溅:错,
地点:“控制”
}
},
rtmp:{
网址:'https://s3.amazonaws.com/MY_AMAZON_S3_BUCKET/flowplayer/flowplayer.rtmp-3.2.10.swf',
netConnectionUrl:'rtmpe://{{cloudfront_domain}}}/cfx/st'
}
}
}).ipad();
}
});
{{movie.title}
{{movie.description}}
{%endblock%}
用这个
这里,警报(playerapi.ready?playerapi.video.time:0)此节目为当前时间
用这个
这里,警报(playerapi.ready?playerapi.video.time:0)此节目为当前时间