Video event listener not working properly (Google Chrome extension - Javascript)
I am trying to track when video stops, pauses, etc in Google Chrome extension. This is example page (html5 video): http://www.kaltura.org/apis/html5lib/kplayer-examples/Player_Themable.html
This is the code:
var player = document.getElementById("pid_mwe_v0") || null;
if (player !== null) {
console.log("VIDEO FOUND!!!!!!!");
player.addEventListener("pause", function(event){
console.log("pause");
},false);
player.addEventListener("p开发者_运维百科lay", function(event){
console.log("play");
},false);
player.addEventListener("play", logger, false);
player.addEventListener("pause", logger, false);
}
else{
console.log("NO VIDEO");
}
Why It doesn't detect this video by it's id and it detects it with:
document.getElementsByTagName("video")[0]
and how to detect it by id?
- Even When video is detected it doesn't fire play and pause events when I click play/pause. How to do it properly?
精彩评论