title: How to auto play iframe youtube on webview android
body: <p>I use android webview in my app for display video from youtube it's work well.</p>
  
  <p>But i want it's auto play.</p>
  
  <p>This is my activity i append <strong>"?autoplay=1"</strong> to videoUrl but nothing change it's still not auto play.</p>
  
  <pre><code>public class LandVideoAct extends Activity {
      WebView mWebView;
      String videoURL = "";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          requestWindowFeature(Window.FEATURE_NO_TITLE);
          setContentView(R.layout.landfull);
          videoURL = "http://www.youtube.com/embed/VYIi49czywo?autoplay=1";
          mWebView = (WebView) findViewById(R.id.fullwebview);
  
          String vid = "&lt;html&gt;&lt;body style=\"margin: 0; padding: 0\"&gt;&lt;iframe  width=\"100%\" height=\"100%\" src=\""+videoURL+"\" type=\"text/html\" frameborder=\"0\"&gt;&lt;/iframe&gt;&lt;body&gt;&lt;html&gt;";
  
          WebChromeClient mWebChromeClient = new WebChromeClient(){
              public void onProgressChanged(WebView view, int newProgress) {
              }
          };
  
          mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
          mWebView.setWebChromeClient(mWebChromeClient);
          mWebView.setWebViewClient(new WebViewClient() {
              public void onPageFinished(WebView view, String url) {
                  mWebView.loadUrl("javascript:(function() { document.getElementsByTagName('video')[0].play(); })()"); 
              }
          });
          mWebView.getSettings().setJavaScriptEnabled(true);
          mWebView.getSettings().setAppCacheEnabled(true);
          mWebView.setInitialScale(1);
          mWebView.getSettings().setLoadWithOverviewMode(true);
          mWebView.getSettings().setUseWideViewPort(true);
          if (Build.VERSION.SDK_INT &lt; 17) {
              Log.i("GPSNETWORK", "&lt;17");
          } else {
              Log.i("GPSNETWORK", Build.VERSION.SDK_INT+"&gt;=17");
              mWebView.getSettings().setMediaPlaybackRequiresUserGesture(false);
          }
          mWebView.loadData(vid, "text/html", "UTF-8");
      }
  }
  </code></pre>