【问题标题】:How to seek youtube video on youtube.com?如何在 youtube.com 上查找 youtube 视频?
【发布时间】:2017-12-29 18:04:03
【问题描述】:

如何与 youtube.com 上的 YouTube 播放器交互——而不是 iFrame API?例如。寻找或播放/暂停视频。我想用我的扩展程序以编程方式设置播放视频的当前时间。

【问题讨论】:

    标签: javascript youtube youtube-api


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-15
      • 2013-06-18
      • 2019-06-27
      • 2017-06-12
      • 2016-12-19
      • 1970-01-01
      • 2015-12-27
      • 2018-10-19
      相关资源
      最近更新 更多