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

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

Issue 164273002: Cast icon should show in sync with media controls Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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..7802554908fd39b7c6719128cee3d4f3a9862bc7 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,41 @@ 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;
+ MediaControlsVisibilityListener mListener;
- public FullScreenMediaController(Context context, View video) {
+ 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,8 +65,19 @@ public class ContentVideoViewLegacy extends ContentVideoView {
if (mVideoView != null) {
mVideoView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
}
+ if (mListener != null) mListener.onMediaControlsVisibilityChanged(false);
super.hide();
}
+
+ /**
+ * 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;
+ }
}
ContentVideoViewLegacy(Context context, long nativeContentVideoView,
@@ -112,7 +140,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 +212,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 +293,14 @@ 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;
+ if (mMediaController != null) mMediaController.setListener(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