You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To accomplish this feature, we should simulate the 'exit full screen' click from webView. What I mean, when user press back button , it should exit the fullscreen like clicked the video's fullscreen button.
to do this follow these steps;
First Step
Embed this javascript code inside your webView element.
<script>
function exitFullScreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
</script>
** this code should be inside the html body tag.
Second Step
Use boolean value to know if the video is in fullscreen mode.
My activity like this;
public class PostDetailActivity extends AppCompatActivity
implements VideoEnabledWebChromeClient.ToggledFullscreenCallback{
private boolean fullscreen = false;
// some code
in here we save the fullscreen situation
@Override
public void toggledFullscreen(boolean fullscreen) {
this.fullscreen = fullscreen;
// Your code to handle the full-screen change, for example showing and hiding the title bar. Example:
if (fullscreen)
{
Third Step
Call this javascript exit function from activity when back button is pressed;
@Override
public void onBackPressed() {
if (fullscreen){
postWebView.loadUrl("javascript:toggleFullScreen()");
fullscreen=false;
//webChromeClient.onHideCustomView();
}
else
{
postWebView.onPause();
super.onBackPressed();
}
}
When the back is pressed from fullscreen while a video is playing, video gets struck.
The text was updated successfully, but these errors were encountered: