在JW Player中单击播放按钮时会触发哪个功能?

时间:2010-09-18 05:43:27

标签: jwplayer

我在我的应用程序中使用JW Player。我想知道在JW Player中单击播放按钮时触发了哪个功能。

1 个答案:

答案 0 :(得分:3)

你想做什么?什么版本的JWPlayer?

您可以通过以下方式模拟JWPlayer 4中的“播放”点击: http://developer.longtailvideo.com/trac/wiki/Player4Api#Sendingevents

player.sendEvent("PLAY","true");

否则,如果您想在播放视频时执行某些操作,则需要收听该事件。

var player = null;
function playerReady(thePlayer) {
 player = document.getElementById(thePlayer.id);
 addListeners();
}


function addListeners() {
 if (player) { 
  player.addModelListener("STATE", "stateListener");
 } else {
  setTimeout("addListeners()",100);
 }
}
function stateListener(obj) { //IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
 currentState = obj.newstate; 
 previousState = obj.oldstate; 

 var tmp = document.getElementById("stat");
 if (tmp) { 
  tmp.innerHTML = "current state: " + currentState + 
  "<br>previous state: " + previousState; 
 }

 if ((currentState == "COMPLETED")&&(previousState == "PLAYING")) {
  document.location.href="http://www.longtailvideo.com/players/jw-flv-player/"; 
 }
}