Full screen option not available when loading YouTube video in WebView
iFrame
is an option but you can try this
Android's WebView and WebChromeClient class extensions that enable fully working HTML5 video support
VideoEnabledWebView
I have not try this yet but hope will help to you.
Do following changes in your java file:
view.setWebViewClient(new Browser());
view.setWebChromeClient(new MyWebClient());
and add this 2 class that is class Browser and class MyWebClient in java file
class Browser
extends WebViewClient
{
Browser() {}
public boolean shouldOverrideUrlLoading(WebView paramWebView, String paramString)
{
paramWebView.loadUrl(paramString);
return true;
}
}
public class MyWebClient
extends WebChromeClient
{
private View mCustomView;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
protected FrameLayout mFullscreenContainer;
private int mOriginalOrientation;
private int mOriginalSystemUiVisibility;
public MyWebClient() {}
public Bitmap getDefaultVideoPoster()
{
if (MainActivity.this == null) {
return null;
}
return BitmapFactory.decodeResource(MainActivity.this.getApplicationContext().getResources(), 2130837573);
}
public void onHideCustomView()
{
((FrameLayout)MainActivity.this.getWindow().getDecorView()).removeView(this.mCustomView);
this.mCustomView = null;
MainActivity.this.getWindow().getDecorView().setSystemUiVisibility(this.mOriginalSystemUiVisibility);
MainActivity.this.setRequestedOrientation(this.mOriginalOrientation);
this.mCustomViewCallback.onCustomViewHidden();
this.mCustomViewCallback = null;
}
public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback paramCustomViewCallback)
{
if (this.mCustomView != null)
{
onHideCustomView();
return;
}
this.mCustomView = paramView;
this.mOriginalSystemUiVisibility = MainActivity.this.getWindow().getDecorView().getSystemUiVisibility();
this.mOriginalOrientation = MainActivity.this.getRequestedOrientation();
this.mCustomViewCallback = paramCustomViewCallback;
((FrameLayout)MainActivity.this.getWindow().getDecorView()).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1));
MainActivity.this.getWindow().getDecorView().setSystemUiVisibility(3846);
}
}