0

People, tell me, I try to play the video on the URL in the WebView, but it does not play on all devices, on what is working, at some not. I use this simple code:

webViewShow = (WebView)findViewById(R.id.webView);
String linkShow = getIntent().getExtras().getString(PARAM_LINK_SHOW);
webViewShow.getSettings().setJavaScriptEnabled(true);
webViewShow.getSettings().setMediaPlaybackRequiresUserGesture(false);
webViewShow.loadUrl(linkShow);

We also note that where not working, it can not be played, and through regular browser.

I added android:hardwareAccelerated="true" in androidManifest

user1854307
  • 580
  • 4
  • 8
  • 21

1 Answers1

0

Make sure you add android:hardwareAccelerated="true" to your app in your Manifest.

How to play video URL inside android webview

In this answer they show:

WebView webview = (WebView) findViewById(R.id.webView1);
webview.setWebViewClient(new WebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webview.getSettings().setPluginState(WebSettings.PluginState.ON);
webview.setWebChromeClient(new WebChromeClient());
webview.loadUrl("https://www.youtube.com");

And in Manifest:

 <application
    android:allowBackup="true"
    android:hardwareAccelerated="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
Community
  • 1
  • 1