diff --git a/core/java/android/widget/MediaControlView2.java b/core/java/android/widget/MediaControlView2.java index a4da05f8b9828..39c23b413cc91 100644 --- a/core/java/android/widget/MediaControlView2.java +++ b/core/java/android/widget/MediaControlView2.java @@ -45,6 +45,19 @@ import java.lang.annotation.RetentionPolicy; * developer needs to manually retrieve a MediaController instance and set it to MediaControlView2 * by calling setController(MediaController controller). * + *

+ * There is no separate method that handles the show/hide behavior for MediaControlView2. Instead, + * one can directly change the visibility of this view by calling View.setVisibility(int). The + * values supported are View.VISIBLE and View.GONE. + * In addition, the following customizations are supported: + * 1. Modify default timeout value of 2 seconds by calling setTimeout(long). + * 2. Set focus to the play/pause button by calling requestPlayButtonFocus(). + * + *

+ * It is also possible to add custom buttons with custom icons and actions inside MediaControlView2. + * Those buttons will be shown when the overflow button is clicked. + * See {@link VideoView2#setCustomActions} for more details on how to add. + * * TODO PUBLIC API * @hide */ @@ -164,22 +177,6 @@ public class MediaControlView2 extends FrameLayout { mProvider.setController_impl(controller); } - /** - * Shows the control view on screen. It will disappear automatically after 3 seconds of - * inactivity. - */ - public void show() { - mProvider.show_impl(); - } - - /** - * Shows the control view on screen. It will disappear automatically after {@code timeout} - * milliseconds of inactivity. - */ - public void show(long timeout) { - mProvider.show_impl(timeout); - } - /** * Returns whether the control view is currently shown or hidden. */ @@ -187,13 +184,6 @@ public class MediaControlView2 extends FrameLayout { return mProvider.isShowing_impl(); } - /** - * Hide the control view from the screen. - */ - public void hide() { - mProvider.hide_impl(); - } - /** * Changes the visibility state of an individual button. Default value is View.Visible. * @@ -217,6 +207,36 @@ public class MediaControlView2 extends FrameLayout { mProvider.setButtonVisibility_impl(button, visibility); } + /** + * Requests focus for the play/pause button. + */ + public void requestPlayButtonFocus() { + mProvider.requestPlayButtonFocus_impl(); + } + + /** + * Sets a new timeout value (in milliseconds) for showing MediaControlView2. The default value + * is set as 2 seconds. + * @param timeout the + */ + public void setTimeout(long timeout) { + mProvider.setTimeout_impl(timeout); + } + + /** + * Retrieves current timeout value (in milliseconds) for showing MediaControlView2. The default + * value is set as 2 seconds. + */ + public long getTimeout() { + return mProvider.getTimeout_impl(); + } + + @Override + public void onVisibilityAggregated(boolean isVisible) { + + mProvider.onVisibilityAggregated_impl(isVisible); + } + @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 4464f8f2ac6ee..95fe363171644 100644 --- a/media/java/android/media/update/MediaControlView2Provider.java +++ b/media/java/android/media/update/MediaControlView2Provider.java @@ -36,9 +36,10 @@ import android.view.View; // TODO @SystemApi public interface MediaControlView2Provider extends ViewProvider { void setController_impl(MediaController controller); - void show_impl(); - void show_impl(long timeout); boolean isShowing_impl(); - void hide_impl(); void setButtonVisibility_impl(int button, int visibility); + void requestPlayButtonFocus_impl(); + void onVisibilityAggregated_impl(boolean isVisible); + void setTimeout_impl(long timeout); + long getTimeout_impl(); }