title: Add autoplay to ytplayer
body: <p>How do I add autoplay to the code below?</p>
  
  <p>The HTML and JavaScript code below shows a simple example that inserts a YouTube player into the page element that has an id value of ytplayer. The onYouTubePlayerAPIReady() function specified here is called automatically when the IFrame Player API code has loaded. This code does not define any player parameters and also does not define other event handlers.</p>
  
  <pre><code>&lt;div id="ytplayer"&gt;&lt;/div&gt;
  
  &lt;script&gt;
  // Load the IFrame Player API code asynchronously.
  var tag = document.createElement('script');
  .src = "https://www.youtube.com/player_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  
  // Replace the 'ytplayer' element with an &lt;iframe&gt; and
  // YouTube player after the API code downloads.
  var player;
  function onYouTubePlayerAPIReady() {
  player = new YT.Player('ytplayer', {
    height: '360',
    width: '640',
    videoId: 'M7lc1UVf-VE'
  });
  }
  &lt;/script&gt;
  </code></pre>