getCurrentTime() for YouTube Video

前端 未结 4 1000
故里飘歌
故里飘歌 2021-02-14 17:02

I\'m writing a Chrome Extension in Javascript and I want to get the current time for the playing video on youtube.com. I tried using the answer from question Getting Current You

4条回答
  •  暖寄归人
    2021-02-14 17:20

    you can only use getElementById when you´r referencing to the correct page. You´r using the right id. if you´r trying to access the play form another page you can use the jquery .load() function

    ---------EDIT----------

    in the sample they do it like so: function getCurrentTime() { var currentTime = player.getCurrentTime(); return roundNumber(currentTime, 3); }

提交回复
热议问题