Which Function is triggered when play button is clicked in JW Player?
-
03-10-2019 - |
Pergunta
I am using JW Player in my application. I want to know which function is triggered when the play button is clicked in the JW Player.
Solução
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/";
}
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow