title: Youtube video autoplay inside UIWebview
body: <p>I found many questions in this forum regarding embedding youtube video and autoplay, but none of them cleared all my doubts.</p>
  
  <p>I found two methods to embed youtube video in UIWebView</p>
  
  <p>1) </p>
  
  <pre><code>NSString *youTubeHTMLTemplate = @"&lt;html&gt;&lt;head&gt;&lt;style type=\"text/css\"&gt;body { background-color: transparent;color: white;}&lt;/style&gt;&lt;/head&gt;&lt;body style=\"margin:0\"&gt;&lt;embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" width=\"%0.0f\" height=\"%0.0f\"&gt;&lt;/embed&gt;&lt;/body&gt;&lt;/html&gt;"; 
  finalHtml = [NSString stringWithFormat:youTubeHTMLTemplate, fullYopuTubeUrl, htmlFrameWidth, htmlFrameHeight];
  </code></pre>
  
  <p>2) </p>
  
  <pre><code>NSString *youTubeHTMLTemplate = @"&lt;html&gt;&lt;body style=\"margin:0;padding:0;\"&gt;&lt;iframe class=\"youtube-player\" type=\"text/html\" width=\"%f\" height=\"%f\" src=\"http://www.youtube.com/embed/%@\" frameborder=\"0\" allowfullscreen&gt;&lt;/iframe&gt;&lt;/body&gt;&lt;/html&gt;";
  finalHtml = [NSString stringWithFormat:youTubeHTMLTemplate, htmlFrameWidth, htmlFrameHeight, videoID];
  </code></pre>
  
  <p>If I use (1) method and follow the approach given <a href="https://stackoverflow.com/questions/3010708/youtube-video-autoplay-on-iphones-safari-or-uiwebview">here</a> my video autoplays. Idea is to find button in UIWebView and send touch up event to it.</p>
  
  <p>If I use (2) and follow the same approach video does not autoplay.</p>
  
  <p>I think that the (2) approach is recommended as the (1) is for Flash Videos only (Right?). </p>
  
  <p>Is by any means (2) is possible ? This <a href="https://stackoverflow.com/questions/8141652/youtube-embeded-video-autoplay-feature-not-working-in-iphone">link</a> says NO.</p>
  
  <p>Can anyone confirm </p>
  
  <ul>
  <li>If I am correct that (2) is recommended </li>
  <li>Autoplay with (2) is not possible.</li>
  </ul>