Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentVideoViewLegacy.java

Issue 171233002: Cast icon should show in sync with media controls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/ContentVideoViewLegacy.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentVideoViewLegacy.java b/content/public/android/java/src/org/chromium/content/browser/ContentVideoViewLegacy.java
index 30035c9fa08e2b415f5f0566242d2d1ba15d5b58..d628fcf24b83e97f85a720a34549d29769d14d2d 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentVideoViewLegacy.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentVideoViewLegacy.java
@@ -20,24 +20,48 @@ import android.widget.MediaController;
* https://code.google.com/p/chromium/issues/detail?id=331966
*/
public class ContentVideoViewLegacy extends ContentVideoView {
- private MediaController mMediaController;
+ private FullScreenMediaController mMediaController;
private boolean mCanPause;
private boolean mCanSeekBackward;
private boolean mCanSeekForward;
private int mCurrentBufferPercentage;
+ private MediaControlsVisibilityListener mListener;
+
+ /**
+ * A listener for changes in the MediaController visibility.
+ */
+ public interface MediaControlsVisibilityListener {
+ /**
+ * Callback for when the visibility of the media controls changes.
+ *
+ * @param shown true if the media controls are shown to the user, false otherwise
+ */
+ public void onMediaControlsVisibilityChanged(boolean shown);
+ }
private static class FullScreenMediaController extends MediaController {
- View mVideoView;
+ final View mVideoView;
+ final MediaControlsVisibilityListener mListener;
- public FullScreenMediaController(Context context, View video) {
+ /**
+ * @param context The context.
+ * @param video The full screen video container view.
+ * @param listener A listener that listens to the visibility of media controllers.
+ */
+ public FullScreenMediaController(
+ Context context,
+ View video,
+ MediaControlsVisibilityListener listener) {
super(context);
mVideoView = video;
+ mListener = listener;
}
@Override
public void show() {
super.show();
+ if (mListener != null) mListener.onMediaControlsVisibilityChanged(true);
if (mVideoView != null) {
mVideoView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}
@@ -48,6 +72,7 @@ public class ContentVideoViewLegacy extends ContentVideoView {
if (mVideoView != null) {
mVideoView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
}
+ if (mListener != null) mListener.onMediaControlsVisibilityChanged(false);
super.hide();
}
}
@@ -112,7 +137,7 @@ public class ContentVideoViewLegacy extends ContentVideoView {
return false;
}
});
- surfaceView.setOnTouchListener(new OnTouchListener() {
+ setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (isInPlaybackState() && mMediaController != null &&
@@ -184,7 +209,7 @@ public class ContentVideoViewLegacy extends ContentVideoView {
mCurrentBufferPercentage = 0;
if (mMediaController != null) return;
- mMediaController = new FullScreenMediaController(getContext(), this);
+ mMediaController = new FullScreenMediaController(getContext(), this, mListener);
mMediaController.setMediaPlayer(new MediaController.MediaPlayerControl() {
@Override public boolean canPause() { return mCanPause; }
@Override public boolean canSeekBackward() { return mCanSeekBackward; }
@@ -265,4 +290,13 @@ public class ContentVideoViewLegacy extends ContentVideoView {
return true;
}
+ /**
+ * Sets the MediaControlsVisibilityListener that wants to listen to visibility change events.
+ *
+ * @param listener the listener to send the events to.
+ */
+ public void setListener(MediaControlsVisibilityListener listener) {
+ mListener = listener;
+ }
+
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698