title: Play Youtube HTML5 embedded Video in Android WebView
body: <p>I am having a problem running a <strong><em>HTML5 Youtube embedded</em></strong> in a <strong><em>WebView</em></strong>.
  I want to play a Youtube video on my application. I decided to use WebView instead of VideoView, because I want to make my system more flexible to play video from web.</p>
  
  <p>Although There are many ways to get play youtube on the android, but I will use the youtube embedded version. "<a href="http://www.youtube.com/embed/___________________" rel="nofollow noreferrer">http://www.youtube.com/embed/___________________</a>". Because this is one of the solution I found when your android doesn't support flash.</p>
  
  <p><strong><em>The problem:</em></strong></p>
  
  <p>The WebView load as normal including the embedded Youtube. But I get a black screen on the youtube at start. </p>
  
  <p>When I click on it. It load the first Image only but then It is not Playing. I tried to play on the android browser, it works smoothly but not in the webView. </p>
  
  <p>Any idea why?</p>
  
  <p>Below is just a snip of my code:</p>
  
  <pre><code>WebView wv = new WebView(getApplicationContext());
  wv.getSettings().setPluginState(PluginState.ON);
  wv.getSettings().setJavaScriptEnabled(true);
  wv.loadUrl("http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html");
  setContentView(wv);
  </code></pre>
  
  <p>Here are some of the resources that I found very useful:</p>
  
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/5817805/how-can-we-play-youtube-embeded-code-in-android-application-using-webview">How can we play YouTube embeded code in an Android application using webview?</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/2292086/play-youtube-video-in-webview">play youtube video in WebView</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/3458765/how-to-embed-a-youtube-clip-in-a-webview-on-android">How to embed a YouTube clip in a WebView on Android</a></p></li>
  <li><p><a href="http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html" rel="nofollow noreferrer">http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html</a></p></li>
  <li><p><a href="http://www.broken-links.com/2009/10/06/building-html5-video-controls-with-javascript/" rel="nofollow noreferrer">http://www.broken-links.com/2009/10/06/building-html5-video-controls-with-javascript/</a></p></li>
  <li><p><a href="http://www.youtube.com/embed/bHQqvYy5KYo" rel="nofollow noreferrer">http://www.youtube.com/embed/bHQqvYy5KYo</a></p></li>
  </ul>
  
  <p>Thank you in advance for any support and help :)</p>
  
  <hr>
  
  <p><strong>Update (13 June 2011):</strong> </p>
  
  <p>I successfully load the <a href="http://m.youtube.com" rel="nofollow noreferrer">http://m.youtube.com</a> inside the WebView, but unable to play any video. But When I tried to load the URL on my Android Browser, it can play.</p>
  
  <p>From here, I notice that the youtube site from my WebView is not signed in. So How can we allow the WebView to use the same credential as my Youtube account in my phone? Will it actually works?</p>