Skip to content

Commit c07b678

Browse files
author
Michael Kolb
committed
set System UI visibility based on MediaController state
Bug: 5494143 still doesn't remove the buttons in dimmed state, but at least dims them correctly Change-Id: Idcfc10616d31f6ccf8cd84b706a17d048bf505a1
1 parent 613ed4c commit c07b678

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

core/java/android/webkit/HTML5VideoFullScreen.java

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44
import android.content.Context;
55
import android.media.MediaPlayer;
66
import android.media.Metadata;
7-
import android.util.Log;
87
import android.view.Gravity;
98
import android.view.MotionEvent;
109
import android.view.SurfaceHolder;
1110
import android.view.SurfaceView;
1211
import android.view.View;
1312
import android.view.ViewGroup;
14-
import android.webkit.HTML5VideoView;
15-
import android.webkit.HTML5VideoViewProxy;
1613
import android.widget.FrameLayout;
1714
import android.widget.MediaController;
1815
import android.widget.MediaController.MediaPlayerControl;
@@ -150,7 +147,7 @@ public void decideDisplayMode() {
150147
private void prepareForFullScreen() {
151148
// So in full screen, we reset the MediaPlayer
152149
mPlayer.reset();
153-
MediaController mc = new MediaController(mProxy.getContext());
150+
MediaController mc = new FullScreenMediaController(mProxy.getContext(), mLayout);
154151
mc.setSystemUiVisibility(mLayout.getSystemUiVisibility());
155152
setMediaController(mc);
156153
mPlayer.setScreenOnWhilePlaying(true);
@@ -261,9 +258,6 @@ public void enterFullScreenVideoState(int layerId,
261258
mLayout.addView(getSurfaceView(), layoutParams);
262259

263260
mLayout.setVisibility(View.VISIBLE);
264-
mLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
265-
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
266-
267261
WebChromeClient client = webView.getWebChromeClient();
268262
if (client != null) {
269263
client.onShowCustomView(mLayout, mCallback);
@@ -340,4 +334,33 @@ protected void switchProgressView(boolean playerBuffering) {
340334
}
341335
return;
342336
}
337+
338+
static class FullScreenMediaController extends MediaController {
339+
340+
View mVideoView;
341+
342+
public FullScreenMediaController(Context context, View video) {
343+
super(context);
344+
mVideoView = video;
345+
}
346+
347+
@Override
348+
public void show() {
349+
super.show();
350+
if (mVideoView != null) {
351+
mVideoView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
352+
}
353+
}
354+
355+
@Override
356+
public void hide() {
357+
if (mVideoView != null) {
358+
mVideoView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
359+
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
360+
}
361+
super.hide();
362+
}
363+
364+
}
365+
343366
}

0 commit comments

Comments
 (0)