I converted a website into an app with WebView in Android Studio. Everything is fine but the youtube videos that was in my website does not go in full Screen. I am a beginner, s
To achieve this follows these steps :
1) Set WebChromeClient to your webview.
Exmaple : WebView.setWebChromeClient(new MyChromeBrowser());
2) Implement method onShowCustomView() and onHideCustomView() inside your WebChromeClient.
Example : `
private class MyChromeBrowser extends WebChromeClient {
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
super.onShowCustomView(view, callback);
}
@Override
public void onHideCustomView() {
super.onHideCustomView();
}
}`
3) Give android:hardwareAccelerated="true"
in manifest file for your activity.
Example : <activity android:name=".MainActivity"
android:hardwareAccelerated="true"
/>
Update :
To fix this try these :
change these lines : webView.setWebChromeClient(new MyWebChromeClient());
to
mWebChromeClient = new myWebChromeClient();
webView.setWebChromeClient(mWebChromeClient);
inside initWebView() method.
To let the system decide the best orientation in full-screen mode add this line to onShowCustomView(View view, CustomViewCallback callback) method:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
UPDATE : 09-07-2017
Or you can use a VideoEnabledWebView library for full screen viedo player in webview and much more .
Link : GitHub