title: Embed Youtube video inside an Android app
body: <p>I'm using a WebView for displaying embedded Youtube video and that works on Galaxcy S2 (OS 2.3.5) and doesn't on Nexus S (OS 2.3.4), all I get is white screen without any video display.</p>
  
  <p>Here is the code snippet I'm using and the declarations in Manifest file:</p>
  
  <pre><code>private WebView wv;
  
  private void setWebView()
  {
  wv = (WebView) findViewById(R.id.webView);
  
  wv.setWebChromeClient(new WebChromeClient());
  
  wv.getSettings().setPluginState(WebSettings.PluginState.ON);
  
  wv.setWebViewClient(new WebViewClient()); 
  
  wv.getSettings();
  
  wv.setBackgroundColor(0x00000000);
  
  wv.setKeepScreenOn(true);
  
  wv.setHorizontalScrollBarEnabled(false);
  wv.setVerticalScrollBarEnabled(false);
  
  wv.getSettings().setBuiltInZoomControls(true);
  
  final String mimeType = "text/html";
  final String encoding = "UTF-8";
  String html = getHTML();
  
  wv.loadDataWithBaseURL("", html, mimeType, encoding, "");
  
  }
  
  
  public String getHTML()
  {
  
  String html = "&lt;html&gt;"
  
      + "&lt;head&gt;"
   + "&lt;/head&gt;"
   + "&lt;body style=\"border: 0; padding: 0\"&gt;"
   + "&lt;iframe "
   + "type=\"text/html\" "
   + "class=\"youtube-player\" "
   + "width= 100%\""
   + "\" "
   + "height= 95%\""
   + "\" "
   + "src=\"http://www.youtube.com/v/"
   + selected_video 
      + "?controls=0&amp;showinfo=0&amp;showsearch=0&amp;modestbranding=0" +
   "&amp;autoplay=1&amp;fs=1&amp;vq=hd720\" " + "frameborder=\"0\"&gt;&lt;/iframe&gt;" 
      + "&lt;/body&gt;"
      + "&lt;/html&gt;";
  
   return html;
  }
  </code></pre>
  
  <p>Note: the parameter "selected_video" is the hash of the video (VideoID).</p>
  
  <p>The declarations in Manifest file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android=http://schemas.android.com/apk/res/android
  .
  .
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"  /&gt;
  
  &lt;application
     .
     .
      android:hardwareAccelerated="true"  &gt;
  
      .
      .
  </code></pre>
  
  <p>Please let me know in case you recognizing anything I should change in my code, or help with a complete code which can support all Android devices and OS for displaying embedded (In-App) Youtube video with high quality.</p>
  
  <p>UPDATE:
  Pay attention, the solution I'm looking for should display high resolution video. I got it work on the different devices and OS using VideoView class but the video quality isn't good enough. So any solution including VideoView or WebView or any other way will be accepted only if it makes high quality YouTube video to be displayed. Thanks to all the responders! </p>