diff options
4 files changed, 65 insertions, 0 deletions
diff --git a/core/java/android/widget/MediaControlView2.java b/core/java/android/widget/MediaControlView2.java index 42ba61b1b933..f0a27286ea5e 100644 --- a/core/java/android/widget/MediaControlView2.java +++ b/core/java/android/widget/MediaControlView2.java @@ -26,6 +26,7 @@ import android.media.update.ViewProvider; import android.util.AttributeSet; import android.view.KeyEvent; import android.view.MotionEvent; +import android.view.View; /** * A View that contains the controls for MediaPlayer2. @@ -47,6 +48,19 @@ import android.view.MotionEvent; * @hide */ public class MediaControlView2 extends FrameLayout { + // TODO: should overflow button be included? + public static final int BUTTON_PLAY_PAUSE = 1; + public static final int BUTTON_FFWD = 2; + public static final int BUTTON_REW = 3; + public static final int BUTTON_NEXT = 4; + public static final int BUTTON_PREV = 5; + public static final int BUTTON_SUBTITLE = 6; + public static final int BUTTON_FULL_SCREEN = 7; + public static final int BUTTON_OVERFLOW = 8; + public static final int BUTTON_MUTE = 9; + public static final int BUTTON_ASPECT_RATIO = 10; + public static final int BUTTON_SETTINGS = 11; + private final MediaControlView2Provider mProvider; public MediaControlView2(@NonNull Context context) { @@ -172,10 +186,33 @@ public class MediaControlView2 extends FrameLayout { mProvider.hideSubtitle_impl(); } + /** + * Set listeners for previous and next buttons to customize the behavior of clicking them. + * The UI for these buttons are provided as default and will be automatically displayed when + * this method is called. + * + * @param next Listener for clicking next button + * @param prev Listener for clicking previous button + */ + public void setPrevNextListeners(View.OnClickListener next, View.OnClickListener prev) { + mProvider.setPrevNextListeners_impl(next, prev); + } + + /** + * Hides the specified button from view. + * + * @param button the constant integer assigned to individual buttons + * @param visible whether the button should be visible or not + */ + public void setButtonVisibility(int button, boolean visible) { + mProvider.setButtonVisibility_impl(button, visible); + } + @Override protected void onAttachedToWindow() { mProvider.onAttachedToWindow_impl(); } + @Override protected void onDetachedFromWindow() { mProvider.onDetachedFromWindow_impl(); diff --git a/core/java/android/widget/VideoView2.java b/core/java/android/widget/VideoView2.java index 56f3dbd1e94e..156de129873b 100644 --- a/core/java/android/widget/VideoView2.java +++ b/core/java/android/widget/VideoView2.java @@ -235,6 +235,13 @@ public class VideoView2 extends FrameLayout { mProvider.hideSubtitle_impl(); } + /** + * Sets full screen mode. + */ + public void setFullScreen(boolean fullScreen) { + mProvider.setFullScreen_impl(fullScreen); + } + // TODO: This should be revised after integration with MediaPlayer2. /** * Sets playback speed. @@ -399,6 +406,13 @@ public class VideoView2 extends FrameLayout { } /** + * Registers a callback to be invoked when the fullscreen mode should be changed. + */ + public void setFullScreenChangedListener(OnFullScreenChangedListener l) { + mProvider.setFullScreenChangedListener_impl(l); + } + + /** * Interface definition of a callback to be invoked when the viw type has been changed. */ public interface OnViewTypeChangedListener { @@ -466,6 +480,16 @@ public class VideoView2 extends FrameLayout { void onInfo(int what, int extra); } + /** + * Interface definition of a callback to be invoked to inform the fullscreen mode is changed. + */ + public interface OnFullScreenChangedListener { + /** + * Called to indicate a fullscreen mode change. + */ + void onFullScreenChanged(boolean fullScreen); + } + @Override protected void onAttachedToWindow() { mProvider.onAttachedToWindow_impl(); diff --git a/media/java/android/media/update/MediaControlView2Provider.java b/media/java/android/media/update/MediaControlView2Provider.java index b3719c85787f..e0e4cef74693 100644 --- a/media/java/android/media/update/MediaControlView2Provider.java +++ b/media/java/android/media/update/MediaControlView2Provider.java @@ -48,4 +48,6 @@ public interface MediaControlView2Provider extends ViewProvider { boolean canSeekForward_impl(); void showSubtitle_impl(); void hideSubtitle_impl(); + void setPrevNextListeners_impl(View.OnClickListener next, View.OnClickListener prev); + void setButtonVisibility_impl(int button, boolean visible); } diff --git a/media/java/android/media/update/VideoView2Provider.java b/media/java/android/media/update/VideoView2Provider.java index b7a24e59ab3e..a2fd0da3df61 100644 --- a/media/java/android/media/update/VideoView2Provider.java +++ b/media/java/android/media/update/VideoView2Provider.java @@ -50,6 +50,7 @@ public interface VideoView2Provider extends ViewProvider { int getAudioSessionId_impl(); void showSubtitle_impl(); void hideSubtitle_impl(); + void setFullScreen_impl(boolean fullScreen); void setSpeed_impl(float speed); float getSpeed_impl(); void setAudioFocusRequest_impl(int focusGain); @@ -65,4 +66,5 @@ public interface VideoView2Provider extends ViewProvider { void setOnErrorListener_impl(VideoView2.OnErrorListener l); void setOnInfoListener_impl(VideoView2.OnInfoListener l); void setOnViewTypeChangedListener_impl(VideoView2.OnViewTypeChangedListener l); + void setFullScreenChangedListener_impl(VideoView2.OnFullScreenChangedListener l); } |