Closed Samyak81 closed 3 years ago
Same here.. I will be very grateful if you can provide us with a solution to this.
Did you find a solution @Samyak81 ?
Same with me, Is there any solution?
跟我一样,有什么办法吗?
Hi, I am facing same issue while using Advance webview, Screen hangs whenever i click full screen button while playing youtube video
please provide us full control over the full screen, we will be rally grateful for this.
In my case, there was a problem displaying full screen ads.
So, the library is included in the project, and "pauseTimers ();" and "resumeTimers ();" in "AdvancedWebView.java" are disabled and used.
did anyone got the solution for this fullscreen problem
does any one got this solution or solved in library ?
//copy this code after protected void onCreate(Bundle savedInstanceState){....} private class myChrome extends WebChromeClient { private View mCustomeview; private WebChromeClient.CustomViewCallback mcustomViewCallback;
private int mOrginalSystemVisiblity;
myChrome() {
}
public Bitmap getDefaultVideoPoster() {
if (mCustomeview == null) {
return null;
}
return BitmapFactory.decodeResource(getApplicationContext().getResources(),2130837573);
}
public void onHideCustomView()
{
((FrameLayout)getWindow().getDecorView()).removeView(this.mCustomeview);
this.mCustomeview=null;
getWindow().getDecorView().setSystemUiVisibility(this.mOrginalSystemVisiblity);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
this.mcustomViewCallback.onCustomViewHidden();
this.mcustomViewCallback=null;
}
public void onShowCustomView(View paramView,WebChromeClient.CustomViewCallback paraCustomeViewcallback)
{
if(this.mCustomeview !=null)
{
onHideCustomView();
return;
}
this.mCustomeview=paramView;
this.mOrginalSystemVisiblity=getWindow().getDecorView().getSystemUiVisibility();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
this.mcustomViewCallback=paraCustomeViewcallback;
((FrameLayout)getWindow().getDecorView()).addView(this.mCustomeview,new FrameLayout.LayoutParams(-1,-1));
getWindow().getDecorView().setSystemUiVisibility(3846);
}
}
and just before loading url call this function
mWebView.setWebViewClient(new WebViewClient());
mWebView.setWebChromeClient(new myChrome());
Hi @AadarshaSadan I get nullpoint in the code getWindow().getDecorView(). Can you please help me fix that?
this.mOrginalSystemVisiblity=getWindow().getDecorView().getSystemUiVisibility();
When fullscreen button clicked, chrome client gives us fullscreen view and then we should add it to our activity view :
Define this variable global to hold fullscreen view reference in our activity:
public class MyAmazingActivity extends AppCompatActivity {
private View fullscreenView;
//...
}
Then web chrome client will notify us about showing and hiding fullscreen view in onShowCustomView
and onHideCustomView
methods:
WebChromeClient webChromeClient = new WebChromeClient() {
private ViewGroup rootView;
private WebChromeClient.CustomViewCallback customViewCallback;
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
//Destroy full screen view if already exists
if (fullscreenView != null) {
callback.onCustomViewHidden();
return;
}
//Layout params to fit fullscreen view in our activity
ViewGroup.LayoutParams layoutParams =
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
//Catch root of current activity to add fullscreen view
rootView = (ViewGroup) WebViewBaseActivity.this.webView.getRootView();
//Store full screen view, we need it to destroy it out of scope
fullscreenView = view;
customViewCallback = callback;
rootView.addView(fullscreenView, layoutParams);
}
@Override
public void onHideCustomView() {
//Make sure fullscreen view exists
if (fullscreenView != null) {
//Remove fullscreen view from activity root view
rootView.removeView(fullscreenView);
fullscreenView = null;
//Tell browser we did remove fullscreen view
customViewCallback.onCustomViewHidden();
}
}
};
And finally removing fullscreen view when back pressed(User expects this behaviour):
@Override
public void onBackPressed() {
if (fullscreenView != null) {
webChromeClient.onHideCustomView();
}
}
Youtue video or html video. If you click full screen icon. It will hang the screen and nothing works.