Getting Current YouTube Video Time

后端 未结 7 833
[愿得一人]
[愿得一人] 2020-11-28 08:27

I am writing a Browser Plugin and need to find a way to get the current time a YouTube Video playing on YouTube using JavaScript. I have been playing around in the Chrome Ja

7条回答
  •  一个人的身影
    2020-11-28 08:59

    Depends on what you want

    player.getCurrentTime():Number
    

    Returns the elapsed time in seconds since the video started playing.

    player.getDuration():Number
    

    Returns the duration in seconds of the currently playing video. Note that getDuration() will return 0 until the video's metadata is loaded, which normally happens just after the video starts playing.

    http://code.google.com/apis/youtube/js_api_reference.html

提交回复
热议问题