title: youtube api end of video load a function
body: <p>I am trying to use the YouTube API to detect when a video ends and then to call a JS function I have to then load another one. The call function is in another JS document which is in the head of my HTML document.
  This is the code I have so far from the API site but I am really confused with it.</p>
  
  <pre><code>&lt;pre&gt;&lt;code&gt; &lt;script&gt;
  
  
  
  
  var ytfullplayer;
      function onYouTubePlayerAPIReady() {
          console.log('onYouTubePlayerAPIReady');
          ytfullplayer = new YT.Player('myVid', {
              events: {
  
                if ''onStateChange': getVideo
  
              }
          });
  
      }
      function getVideo(); }
  
  
  &lt;/script&gt; &lt;/code&gt; &lt;/pre&gt;
  </code></pre>
  
  <p>I have called the youtube api in the head of my page. But I am not 100% sure if it goes there.
  Any assistance would be nice.
  I am using an  for my youtube video.</p>
  
  <p>Cheers
  Matt</p>