我在我的应用程序中使用 JW Player。我想知道在 JW Player 中单击播放按钮时会触发哪个功能。
问问题
3554 次
1 回答
3
What are you trying to do? What version of JWPlayer?
You can simulate a "Play" click in JWPlayer 4 by doing this: http://developer.longtailvideo.com/trac/wiki/Player4Api#Sendingevents
player.sendEvent("PLAY","true");
Otherwise if you want to do something when the video is played you need to listen for the event.
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/";
}
}
于 2010-10-07T20:56:34.393 回答