diff options
-rw-r--r-- | api/current.txt | 14 | ||||
-rw-r--r-- | core/java/android/widget/MediaControlView2.java | 43 | ||||
-rw-r--r-- | media/java/android/media/update/MediaControlView2Provider.java | 14 |
3 files changed, 60 insertions, 11 deletions
diff --git a/api/current.txt b/api/current.txt index 5671177ec0b7..0f1981fa0b97 100644 --- a/api/current.txt +++ b/api/current.txt @@ -53262,6 +53262,20 @@ package android.widget { method public void update(); } + public class MediaControlView2 extends android.view.ViewGroup { + ctor public MediaControlView2(android.content.Context); + ctor public MediaControlView2(android.content.Context, android.util.AttributeSet); + ctor public MediaControlView2(android.content.Context, android.util.AttributeSet, int); + ctor public MediaControlView2(android.content.Context, android.util.AttributeSet, int, int); + method public void requestPlayButtonFocus(); + method public void setMediaSessionToken(android.media.SessionToken2); + method public void setOnFullScreenListener(android.widget.MediaControlView2.OnFullScreenListener); + } + + public static abstract interface MediaControlView2.OnFullScreenListener { + method public abstract void onFullScreen(android.view.View, boolean); + } + public class MediaController extends android.widget.FrameLayout { ctor public MediaController(android.content.Context, android.util.AttributeSet); ctor public MediaController(android.content.Context, boolean); diff --git a/core/java/android/widget/MediaControlView2.java b/core/java/android/widget/MediaControlView2.java index 273b9edb4629..4fb303e14990 100644 --- a/core/java/android/widget/MediaControlView2.java +++ b/core/java/android/widget/MediaControlView2.java @@ -20,15 +20,18 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; +import android.media.SessionToken2; import android.media.session.MediaController; import android.media.update.ApiLoader; import android.media.update.MediaControlView2Provider; import android.media.update.ViewGroupHelper; import android.util.AttributeSet; +import android.view.View; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +// TODO: Use link annotation to refer VideoView2 once VideoView2 became unhidden. /** * A View that contains the controls for MediaPlayer2. * It provides a wide range of UI including buttons such as "Play/Pause", "Rewind", "Fast Forward", @@ -55,10 +58,7 @@ import java.lang.annotation.RetentionPolicy; * <p> * 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 + * See VideoView2#setCustomActions for more details on how to add. */ public class MediaControlView2 extends ViewGroupHelper<MediaControlView2Provider> { /** @hide */ @@ -137,16 +137,18 @@ public class MediaControlView2 extends ViewGroupHelper<MediaControlView2Provider /** * String for receiving command to show subtitle from MediaSession. Can be checked by * implementing {@link android.media.session.MediaSession.Callback#onCommand} + * @hide */ public static final String COMMAND_SHOW_SUBTITLE = "showSubtitle"; /** * String for receiving command to hide subtitle from MediaSession. Can be checked by * implementing {@link android.media.session.MediaSession.Callback#onCommand} + * @hide */ public static final String COMMAND_HIDE_SUBTITLE = "hideSubtitle"; + /** - * String for receiving command to set fullscreen from MediaSession. Can be checked by - * implementing {@link android.media.session.MediaSession.Callback#onCommand} + * @hide TODO: remove once the implementation is revised */ public static final String COMMAND_SET_FULLSCREEN = "setFullscreen"; @@ -174,10 +176,24 @@ public class MediaControlView2 extends ViewGroupHelper<MediaControlView2Provider } /** - * Sets MediaController instance to control corresponding MediaSession. + * Sets MediaSession2 token to control corresponding MediaSession2. + */ + public void setMediaSessionToken(SessionToken2 token) { + mProvider.setMediaSessionToken_impl(token); + } + + /** + * Registers a callback to be invoked when the fullscreen mode should be changed. + * @param l The callback that will be run + */ + public void setOnFullScreenListener(OnFullScreenListener l) { + mProvider.setOnFullScreenListener_impl(l); + } + + /** + * @hide TODO: remove once the implementation is revised */ public void setController(MediaController controller) { - mProvider.setController_impl(controller); } /** @@ -215,4 +231,15 @@ public class MediaControlView2 extends ViewGroupHelper<MediaControlView2Provider protected void onLayout(boolean changed, int l, int t, int r, int b) { mProvider.onLayout_impl(changed, l, t, r, b); } + + /** + * Interface definition of a callback to be invoked to inform the fullscreen mode is changed. + * Application should handle the fullscreen mode accordingly. + */ + public interface OnFullScreenListener { + /** + * Called to indicate a fullscreen mode change. + */ + void onFullScreen(View view, boolean fullScreen); + } } diff --git a/media/java/android/media/update/MediaControlView2Provider.java b/media/java/android/media/update/MediaControlView2Provider.java index ebde3fefac36..8e69653c6a31 100644 --- a/media/java/android/media/update/MediaControlView2Provider.java +++ b/media/java/android/media/update/MediaControlView2Provider.java @@ -16,10 +16,10 @@ package android.media.update; -import android.annotation.SystemApi; +import android.media.SessionToken2; import android.media.session.MediaController; import android.util.AttributeSet; -import android.view.View; +import android.widget.MediaControlView2; /** * Interface for connecting the public API to an updatable implementation. @@ -34,11 +34,19 @@ import android.view.View; * * @hide */ -// TODO @SystemApi +// TODO: @SystemApi public interface MediaControlView2Provider extends ViewGroupProvider { void initialize(AttributeSet attrs, int defStyleAttr, int defStyleRes); + void setMediaSessionToken_impl(SessionToken2 token); + void setOnFullScreenListener_impl(MediaControlView2.OnFullScreenListener l); + /** + * @hide TODO: remove + */ void setController_impl(MediaController controller); + /** + * @hide + */ void setButtonVisibility_impl(int button, int visibility); void requestPlayButtonFocus_impl(); } |