开发者

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");
    }
  1. 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?

  1. Even When video is detected it doesn't fire play and pause events when I click play/pause. How to do it properly?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜