title: Random youtube video and API
body: <p>I have been messing around with JavaScript and HTML on my website. I am trying to get it to play a random video from a list I made and when the video ends to refresh the page and play another video. I have been looking at the YouTube embed API but could not get it to work. Bits have this code have been found on other posts. The random video works but not the auto refresh so I left that part out.</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Test&lt;/title&gt;
          &lt;script type='text/javascript' src='http://www.youtube.com/player_api'&gt;&lt;/script&gt;
          &lt;script type="text/javascript"&gt;
              var player = [
              '&lt;iframe width="100%" height="100%" src="https://www.youtube.com/embed/dxnl-TGq6Sk?autoplay=1&amp;modestbranding=1&amp;autohide=1&amp;showinfo=0&amp;controls=0&amp;iv_load_policy=3&amp;enablejsapi=1" scrolling-="no" frameborder="0" id="player"&gt;&lt;/iframe&gt;',
              '&lt;iframe width="100%" height="100%" src="https://www.youtube.com/embed/2dbR2JZmlWo?autoplay=1&amp;modestbranding=1&amp;autohide=1&amp;showinfo=0&amp;controls=0&amp;iv_load_policy=3&amp;enablejsapi=1" scrolling-="no" frameborder="0" id="player"&gt;&lt;/iframe&gt;'
              ];
              function Random() {
                  var rannum= Math.floor(Math.random()*player.length);
                  document.getElementById('player').innerHTML=player[rannum];
              }
              onload = function() { Random(); }
          &lt;/script&gt;
          &lt;!--Mouse--&gt;
          &lt;script language="javascript"&gt;
              document.onmousedown=disableclick;
              function disableclick(event)
              {
                  if(event.button==2)
                  {
                      return false;    
                  }
              }
          &lt;/script&gt;
          &lt;!--Style--&gt;
          &lt;style type="text/css"&gt;
              #overlay {
                  position: absolute;
                  top: 0;
                  right: 0;
                  bottom: 0;
                  left: 0;
                  margin: auto;
                  margin-top: 0px;
                  cursor: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjbQg61aAAAADUlEQVQYV2P4//8/IwAI/QL/+TZZdwAAAABJRU5ErkJggg=='),
                  url(images/blank.cur),
                  none !important;
              }
          &lt;/style&gt;
      &lt;/head&gt;
      &lt;body style="background-color:black;" oncontextmenu="return false"&gt;
          &lt;?php include_once("analyticstracking.php") ?&gt;
          &lt;div id="player"&gt;&lt;/div&gt;
          &lt;div id="overlay"&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>