1

I just added a webview to my app to load a simple article with a video on it and some text. The text shows up as it should but it's as if the video is not even an invisible element.

    WebView browser = (WebView) findViewById(R.id.webArticle);
    browser.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    WebSettings settings = browser.getSettings();
    settings.setBlockNetworkLoads(false);
    settings.setBlockNetworkImage(false);
    settings.setAllowContentAccess(true);
    settings.setLoadsImagesAutomatically(true);
    settings.setAllowFileAccess(true);
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);

    browser.loadUrl(url);
Ledii
  • 261
  • 1
  • 3
  • 13

1 Answers1

1

At first ,You need to add this

getSettings().setPluginsEnabled(true);
getSettings().setUserAgent(USER_MOBILE);

Then Add to the Application Manifest File (Below Permission):

android:hardwareAccelerated="true"

For demo code Play YouTube video in WebView

play youtube video in WebView

Community
  • 1
  • 1
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198