- I want to play video fullscreen in Android
WebView
, so I use HTML5 tag<video>
and put these web files into src/main/asset/... folder. - But when I clcik 'Fullscreen' button, the video just moving to center in the vertical direction(portrait).
- So, my question is how to set fullscreen in landscape? Thank you.
Asked
Active
Viewed 6,906 times
6

kevin4z
- 349
- 4
- 12
-
Possible duplicate of [Playing HTML5 video on fullscreen in android webview](http://stackoverflow.com/questions/15768837/playing-html5-video-on-fullscreen-in-android-webview) – petey Oct 31 '16 at 14:09
-
I have tried that way, but it did not work. @petey – kevin4z Oct 31 '16 at 14:12
1 Answers
2
I used cprcrack/VideoEnabledWebView and RotatedVerticalFrameLayout. I just changed part of onShowCustomView(View view, CustomViewCallback callback) in VideoEnabledWebChromeClient.
// Hide the non-video view, add the video view, and show it
activityNonVideoView.setVisibility(View.INVISIBLE);
Point screenSize = Utils.getDisplaySize(activityNonVideoView.getContext());
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(screenSize.y, screenSize.x);
params.gravity = Gravity.BOTTOM;
videoViewContainer.setLayoutParams(params);
activityVideoView.addView(videoViewContainer);
activityVideoView.setVisibility(View.VISIBLE);
In Activity I changed line in OnToggledFullscreenCallback
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE)
to
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
so that it hides navigation bar.
For getting display size I used
public static Point getDisplaySize(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getRealSize(size);
return size;
}

gustavoknz
- 482
- 1
- 6
- 12

Andrijan Stanković
- 71
- 5