2016-08-07 5 views
0

私はいつもビデオで自分のiframejQueryでYoutubeビデオを取得するには?

<iframe id="Frustrated" width="560" height="315"src="https://www.youtube.com/embed/mjQwedC1WzI" frameborder="0" allowfullscreen sandbox="allow-scripts allow-same-origin"></iframe>

にこのビデオを持っている、あなたがビデオを取得し、それを関数を呼び出すこと

$('#Frustrated').get(0) 

のようなものになるだろう。

しかし、これをYouTubeのビデオでやろうとすると、これは機能しません。 Googleの開発ページで、APIを設定してからそれに従ってください。しかし、APIを使ったことは一度もありません。私はこのすべてを非常に混乱させています。

これは私が現時点で持っているjQueryで、iframeで作業しようとしています。

jQuery(document).ready(function($) { 
    var video = $('section iframe').get(0); 

    video.onended = function(e) { 
     $('section iframe').animate({ width: "50%"}, 'slow', function(){ 
      $('#information').fadeIn('slow'); 
     }); 
    } 

    video.onplay = function(e) { 
     $('#information').fadeOut('slow', function(){ 
    $('section iframe').animate({ width: "100%" }, 'slow'); 
    }); 
    } 

    $('section iframe').click(function() { 

     if(this.paused || this.ended){ 
      $('#information').fadeOut('slow', function(){ 
      $('section iframe').animate({ width: "100%" }, 'slow', function(){ 
      video.play(); 
      }); 
      }); 
     } 

     else if (this.play) { 
      video.pause(); 
      $('section iframe').animate({ width: "50%" }, 'slow'); 
       $('#information').fadeIn('slow'); 
    } 
    }); 
}); 

どのように進行するのか説明できますか?

+1

、そうではjQueryと一緒にHTMLを投稿してください https://developers.google.com/youtube/iframe_api_reference

ためとのiframeなしで見てみましょう[MCVE(** M ** inimal、* * C ** omplete、** V ** erifiable ** E ** xample)](http://stackoverflow.com/help/mcve)を参照してください。 – zer00ne

答えて

関連する問題