title: How to play Youtube video in background in android webview?
body: <p>I am new to android and developing an app for my blog, which has embedded youtube video.I am developing android web view app. I want them to play in the background but can't play.When home button is pressed, the video stops. Please also tell how the video should autoplay.
  Please help me. Here is my code. Thanks</p>
  
  <pre><code>@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      wv1 = (WebView) findViewById(R.id.webview);
      wv1.getSettings().setJavaScriptEnabled(true);
      wv1.getSettings().setMediaPlaybackRequiresUserGesture(false);
      wv1.getSettings().setSupportZoom(true);
      wv1.getSettings().setBuiltInZoomControls(true);
      wv1.getSettings().setDisplayZoomControls(false);
      wv1.getSettings().setLoadWithOverviewMode(true);
      wv1.setWebViewClient(new WebViewClient() {
          public void onPageFinished(WebView view, String url) {wv1.loadUrl("javascript:(function() { document.getElementsByTagName('video')[0].play(); })()"); }
      });
  </code></pre>