2017-02-28 13 views
0

よろしくね!iframe apiとの混乱

私はjavascriptとnoobの新機能である です。そのため、できるだけ少ないjsを使用しようとしていますが、この部分では本当に必要でした。

私はフルスクリーンのビデオを持っており、最初は正しく再生されますが、リロード時に埋め込みURLを再度使用したいと考えています。だから私はこれを作った。

 function onYouTubeIframeAPIReady() { 
      var player; 
      player = new YT.Player('video', { 
      videoId: 'A3rvUNcueFg', // YouTube Video ID 
      playerVars: { 
       autoplay: 1,  // Auto-play the video on load 
       controls: 0,  // Show pause/play buttons in player 
       showinfo: 0,  // Hide the video title 
       loop: 1,   // Run the video in a loop 
       fs: 1,    // Hide the full screen button 
       cc_load_policty: 0, // Hide closed captions 
       iv_load_policy: 3, // Hide the Video Annotations 
       autohide: 1,   // Hide video controls when playing 
       start: 13, 
       end: 295, 
       rel: 0, 
       playlist: 'A3rvUNcueFg' 
      }, 
      events: { 
       onReady: function(e) { 
       e.target.mute(); 
       var Embed = e.target.getVideoEmbedCode(); 
       } 
      } 
      }); 
      YT.PlayerState.ENDED: function(e) { 
      var player; 
      player = new YT.Player(Embed) 
     } 

私がしたいことは、私はそれをミュートしたい(その部分は機能します)。 その後、埋め込みURLを取得して、終了後に同じ開始点でビデオをリロードすることができます。これは現在、最初に再読み込みして開始するためです。事前に

おかげで、 イェルーン

答えて

0

どのようにあなたのビデオオブジェクトでseekToオプションを含めて約。スキップしてビデオを開始する秒数を渡すことができます。

function onYouTubeIframeAPIReady() { 
     var player; 
     var time = //whatever time you want it to start from each loop; NEW CODE 
     player = new YT.Player('video', { 
     videoId: 'A3rvUNcueFg', // YouTube Video ID 
     playerVars: { 
      autoplay: 1,  // Auto-play the video on load 
      controls: 0,  // Show pause/play buttons in player 
      showinfo: 0,  // Hide the video title 
      loop: 1,   // Run the video in a loop 
      fs: 1, // Hide the full screen button 
      cc_load_policty: 0, // Hide closed captions 
      iv_load_policy: 3, // Hide the Video Annotations 
      autohide: 1,   // Hide video controls when playing 
      start: 13, 
      end: 295, 
      rel: 0, 
      playlist: 'A3rvUNcueFg' 
     }, 
     events: { 
      onReady: function(e) { 
      e.target.mute(); 
      var Embed = e.target.getVideoEmbedCode(); 
      } 
     } 
     }); 
     YT.PlayerState.ENDED: function(e) { 
     var player; 
     player = new YT.Player(Embed); 
     player.seekTo(time); //NEW CODE 
    } 

参考:https://developers.google.com/youtube/iframe_api_reference#Playback_controls

player.seekTo(秒:番号、allowSeekAhead:ブール):ボイド