如何与youtube.com上的YouTube播放器进行互动 - 而不是iFrame API?例如。寻找或播放/暂停视频。我想用我的扩展程序设置当前以编程方式播放视频的时间。
答案 0 :(得分:1)
//First get the video
var myPlayer = document.getElementsByClassName('video-stream html5-main-video')[0];
//Now you can:
//Play video with
myPlayer.play()
//Pause video with
myPlayer.pause()
//Go to particular time with
myPlayer.currentTime = 40
//will take your video to 40 seconds.
//To get current time just use
myPlayer.currentTime