Pause youtube video, youtube api

前端 未结 3 749

I\'m trying to pause and play YouTube videos with the following code which is pretty much a copy from the Youtube API page:

         


        
3条回答
  •  长情又很酷
    2020-12-03 04:13

    In your HTML, have some buttons to control the video:

    
    
    

    Using jQuery, bind an event listener (the click) to trigger a function on your player object:

    $(function() {
      $('#play').click(function() {
        player.playVideo();
      });
      $('#pause').click(function() {
        player.pauseVideo();
      });
    });
    

    I built an app using YouTube's Player and Data api. Take what you need: https://github.com/HunterMeyer/YouTV

提交回复
热议问题