0

I want to play a video on android 4.2 webview but I can not play video. Video is in url. Here is my code:

public WebView webView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    webView = (WebView) findViewById(R.id.webView1);


   webView.setWebChromeClient(new WebChromeClient());
   webView.getSettings().setJavaScriptEnabled(true);
   webView.getSettings().setMediaPlaybackRequiresUserGesture(false);

  webView.post(new Runnable() {
      @Override
      public void run() {
          String pageURL = "http://custom-url";
          webView.loadUrl(pageURL);

          //String customHtml = "<html><body><iframe src='http://custom-url' /></body></html>";
          //webView.loadData(customHtml, "text/html", "UTF-8");
      }
  });
}

android:hardwareAccelerated="true" is enabled in AndroidManifest.xml.

When video is trying to play, application is terminated. I am getting "Application is stopped".

I tried everything but there is no solution.

Can problem be hardware. Is hardware responsible for that problem?

0 Answers0