title: Javascript - Youtube API detect deleted/blocked videos
body: <p>How can i check -> if video is deleted / private or embedd not allowed? </p>
  
  <p><strong>DEMO:</strong> <a href="http://jsbin.com/eyexah/15/edit" rel="nofollow">http://jsbin.com/eyexah/15/edit</a><br />
  <strong>YT API DOC:</strong> <a href="https://developers.google.com/youtube/js_api_reference" rel="nofollow">https://developers.google.com/youtube/js_api_reference</a></p>
  
  <p><strong>JS code</strong><br /></p>
  
  <pre><code>var params = {
      allowScriptAccess: "always"
  },
      atts = {
          id: "youtube_player"
      };
  
  swfobject.embedSWF('http://www.youtube.com/v/SJmrqKOsIpM?enablejsapi=1&amp;playerapiid=ytplayer&amp;version=3&amp;autoplay=1', 'youtube', '425', '356', '8', null, null, params, atts);
  
  function onPlayerStateChange(e) {
      if (e !== 1) {
          return;
      }
  
      var availableQualityLevels = ytp.getAvailableQualityLevels();
      console.log(availableQualityLevels);
  }
  
  function onYouTubePlayerReady() {
      window.ytp = document.getElementById("youtube_player");
      ytp.addEventListener('onStateChange', 'onPlayerStateChange')
  
  };
  </code></pre>