title: Youtube Embed Iframe - Events Not Firing In Local
body: <p>I've just noticed that the Youtube events (onReady, onStateChange) are no longer firing when I am testing in my local, but works when I upload the code to <a href="http://jsfiddle.net/8ZmKx/" rel="nofollow">JsFiddle</a>. I've decided to copy and paste the code from <a href="https://developers.google.com/youtube/iframe_api_reference" rel="nofollow">Youtube Player API</a> where I am able to verify that it indeed is not working. Is anyone else having this issue? This issue occurs on Chrome, Firefox, IE, Safari, and Opera.</p>
  
  <p>EDIT - When I <code>console.log(player);</code> in my local, I see that it is missing a lot of Youtube functions such as <code>seekTo()</code>, <code>setVolume()</code>, <code>showVideoInfo()</code> which are present in JsFiddle. I am unsure why this is happening, but I believe this might be the root of my problem. Any ideas?</p>
  
  <p><a href="http://jsfiddle.net/8ZmKx/" rel="nofollow">http://jsfiddle.net/8ZmKx/</a></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;body&gt;
      &lt;!-- 1. The &lt;iframe&gt; (and video player) will replace this &lt;div&gt; tag. --&gt;
      &lt;div id="player"&gt;&lt;/div&gt;
  
      &lt;script&gt;
        // 2. This code loads the IFrame Player API code asynchronously.
        var tag = document.createElement('script');
  
        tag.src = "https://www.youtube.com/iframe_api";
        var firstScriptTag = document.getElementsByTagName('script')[0];
        firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  
        // 3. This function creates an &lt;iframe&gt; (and YouTube player)
        //    after the API code downloads.
        var player;
        function onYouTubeIframeAPIReady() {
          player = new YT.Player('player', {
            height: '190',
            width: '140',
            videoId: 'M7lc1UVf-VE',
            events: {
              'onReady': onPlayerReady,
              'onStateChange': onPlayerStateChange
            }
          });
        }
  
        // 4. The API will call this function when the video player is ready.
        function onPlayerReady(event) {
          console.log('ready');
          event.target.playVideo();
        }
  
        // 5. The API calls this function when the player's state changes.
        //    The function indicates that when playing a video (state=1),
        //    the player should play for six seconds and then stop.
        var done = false;
        function onPlayerStateChange(event) {
          console.log('change');
          if (event.data == YT.PlayerState.PLAYING &amp;&amp; !done) {
            setTimeout(stopVideo, 6000);
            done = true;
          }
        }
        function stopVideo() {
          player.stopVideo();
        }
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>