播放器函数接口示例一

演示

当前观看时间(包含视频缓冲时间)是 0 秒
当前观看时间(不包含视频缓冲时间)是 0 秒
当前播放进度是 0 秒
当前流量: 0 字节 | 0 KB
当前视频的时长是 0 秒
示例代码

点击查看播放器函数接口说明

<object id="polyvplayer02bfeb00e2ba940698c54cdf517aa9b6_0" width="708" height="490" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="http://player.polyv.net/videos/player.swf"><param name="allowscriptaccess" value="always"><param name="wmode" value="Transparent"><param name="flashvars" value="vid=02bfeb00e2ba940698c54cdf517aa9b6_0"><param name="allowFullScreen" value="true"><embed allowfullscreen="true" allowscriptaccess="always" flashvars="vid=02bfeb00e2ba940698c54cdf517aa9b6_0" height="490" name="polyvplayer02bfeb00e2ba940698c54cdf517aa9b6_0" src="http://player.polyv.net/videos/player.swf" type="application/x-shockwave-flash" width="708" wmode="Transparent"></object><br />
 
<span id="stayInVideoTime">当前观看时间(包含视频缓冲时间)是 0 秒</span><br>
<span id="realPlayVideoTime">当前观看时间(不包含视频缓冲时间)是 0 秒</span><br>
<span id="getCurrentTime">当前播放进度是 0 秒</span><br />
<span id="flow">当前流量: 0 字节 | 0 KB</span><br />
<span id="duration">当前视频的时长是 0 秒</span><br />
 
<input type="button" onclick="resume()" value="播放"></input>
<input type="button" onclick="pause()" value="暂停"></input>
<input type="button" onclick="seek(30)" value="seek到第30秒"></input>
<input type="button" onclick="stop()" value="停止"></input>
<input type="button" onclick="nextVideo()" value="切换到下一个视频"></input><br />
 
<script type="text/javascript">
function getPlayer(movieName) {
 if (navigator.appName.indexOf("Microsoft") != -1) {
  var reObj=window[movieName];
  try
  {
   if(reObj.length>0)
   {
    return reObj[0];
   }
            else
            {
              return reObj;
            }
  }catch(e)
  {
    
  }
  return ;
 }
 else {
  return document[movieName];
 }
}
var player=getPlayer("polyvplayer02bfeb00e2ba940698c54cdf517aa9b6_0");
 
function resume()
{
  player.j2s_resumeVideo();
}
 
function pause()
{
  player.j2s_pauseVideo();
} 
 
function seek(_sec)
{
  player.j2s_seekVideo(_sec);
}
 
function stop()
{
  player.j2s_stopVideo();
}
 
function nextVideo()
{
  player.changeVid("02bfeb00e27ff92a76364b16af2f115e_0");
}
 
function render()
{
if(player != undefined && player.j2s_stayInVideoTime != undefined && player.j2s_realPlayVideoTime != undefined && player.j2s_getCurrentTime != undefined && player.j2s_getDuration != undefined && player.j2s_getFlowCount != undefined){
  var sec1=player.j2s_stayInVideoTime();
  var sec2=player.j2s_getCurrentTime();
  var sec3=player.j2s_getDuration();
  var sec4=player.j2s_realPlayVideoTime();
  var byte=player.j2s_getFlowCount();
  document.getElementById("stayInVideoTime").innerHTML="当前观看时间(包含视频缓冲时间)是 <span style='color:#ff0000;'>"+sec1+"</span> 秒";
  document.getElementById("realPlayVideoTime").innerHTML="当前观看时间(不包含视频缓冲时间)是 <span style='color:#ff0000;'>"+sec4+"</span> 秒";
  document.getElementById("getCurrentTime").innerHTML="当前播放进度是 <span style='color:#ff0000;'>"+sec2+"</span> 秒";
  document.getElementById("duration").innerHTML="当前视频的时长是 <span style='color:#ff0000;'>"+sec3+"</span> 秒";
  document.getElementById("flow").innerHTML="当前流量: <span style='color:#ff0000;'>"+byte+"</span> 字节 | <span style='color:#ff0000;'>"+byte/1024+"</span> KB";
}
}
var interval=setInterval("render()",500);
</script>
以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...