diff options
| author | 2018-03-01 03:39:31 +0000 | |
|---|---|---|
| committer | 2018-03-01 03:39:31 +0000 | |
| commit | c7c1ce8012ab224e14d62c7140f5ecc4613960f0 (patch) | |
| tree | 03c7cbd56def4bb642a340f5f5f23523f5298906 | |
| parent | 81b3bb99f92c7aab2ce446c3af2a772a55301eac (diff) | |
| parent | aa080a80a6a152cda5879a2c2510f9c76b9b5f9d (diff) | |
Merge "MediaSession2: Refine APIs"
| -rw-r--r-- | api/current.txt | 33 | ||||
| -rw-r--r-- | media/java/android/media/MediaController2.java | 17 | ||||
| -rw-r--r-- | media/java/android/media/MediaLibraryService2.java | 15 | ||||
| -rw-r--r-- | media/java/android/media/MediaPlayerBase.java | 2 | ||||
| -rw-r--r-- | media/java/android/media/MediaSession2.java | 183 | ||||
| -rw-r--r-- | media/java/android/media/VolumeProvider2.java | 2 | ||||
| -rw-r--r-- | media/java/android/media/update/MediaController2Provider.java | 2 | ||||
| -rw-r--r-- | media/java/android/media/update/MediaSession2Provider.java | 16 | ||||
| -rw-r--r-- | media/java/android/media/update/StaticProvider.java | 6 |
9 files changed, 173 insertions, 103 deletions
diff --git a/api/current.txt b/api/current.txt index 941205628c55..a82ca6ac9c07 100644 --- a/api/current.txt +++ b/api/current.txt @@ -23378,6 +23378,7 @@ package android.media { method public void rewind(); method public void seekTo(long); method public void sendCustomCommand(android.media.MediaSession2.Command, android.os.Bundle, android.os.ResultReceiver); + method public void setPlaybackSpeed(float); method public void setPlaylistParams(android.media.MediaSession2.PlaylistParams); method public void setRating(java.lang.String, android.media.Rating2); method public void setVolumeTo(int, int); @@ -23396,13 +23397,13 @@ package android.media { method public void onCustomCommand(android.media.MediaSession2.Command, android.os.Bundle, android.os.ResultReceiver); method public void onCustomLayoutChanged(java.util.List<android.media.MediaSession2.CommandButton>); method public void onDisconnected(); - method public void onError(int, int); + method public void onError(int, android.os.Bundle); method public void onPlaybackInfoChanged(android.media.MediaController2.PlaybackInfo); method public void onPlaybackSpeedChanged(float); method public void onPlayerStateChanged(int); method public void onPlaylistChanged(java.util.List<android.media.MediaItem2>); method public void onPlaylistParamsChanged(android.media.MediaSession2.PlaylistParams); - method public void onPositionUpdated(long, long); + method public void onPositionChanged(long, long); } public static final class MediaController2.PlaybackInfo { @@ -23854,9 +23855,11 @@ package android.media { } public static final class MediaLibraryService2.MediaLibrarySession.Builder { - ctor public MediaLibraryService2.MediaLibrarySession.Builder(android.media.MediaLibraryService2, android.media.MediaPlayerBase, java.util.concurrent.Executor, android.media.MediaLibraryService2.MediaLibrarySession.MediaLibrarySessionCallback); + ctor public MediaLibraryService2.MediaLibrarySession.Builder(android.media.MediaLibraryService2, java.util.concurrent.Executor, android.media.MediaLibraryService2.MediaLibrarySession.MediaLibrarySessionCallback); method public android.media.MediaLibraryService2.MediaLibrarySession build(); method public android.media.MediaLibraryService2.MediaLibrarySession.Builder setId(java.lang.String); + method public android.media.MediaLibraryService2.MediaLibrarySession.Builder setPlayer(android.media.MediaPlayerBase); + method public android.media.MediaLibraryService2.MediaLibrarySession.Builder setPlaylistController(android.media.MediaPlaylistController); method public android.media.MediaLibraryService2.MediaLibrarySession.Builder setSessionActivity(android.app.PendingIntent); method public android.media.MediaLibraryService2.MediaLibrarySession.Builder setSessionCallback(java.util.concurrent.Executor, android.media.MediaLibraryService2.MediaLibrarySession.MediaLibrarySessionCallback); method public android.media.MediaLibraryService2.MediaLibrarySession.Builder setVolumeProvider(android.media.VolumeProvider2); @@ -24806,15 +24809,17 @@ package android.media { public class MediaSession2 implements java.lang.AutoCloseable android.media.MediaPlaylistController { method public void addPlaylistItem(int, android.media.MediaItem2); method public void close(); - method public void editPlaylistItem(android.media.MediaItem2); method public void fastForward(); method public java.util.List<android.media.MediaSession2.ControllerInfo> getConnectedControllers(); method public android.media.MediaItem2 getCurrentPlaylistItem(); + method public android.media.MediaPlaylistController getMediaPlaylistController(); + method public float getPlaybackSpeed(); method public android.media.MediaPlayerBase getPlayer(); method public java.util.List<android.media.MediaItem2> getPlaylist(); method public android.media.MediaSession2.PlaylistParams getPlaylistParams(); method public android.media.SessionToken2 getToken(); - method public void notifyError(int, int); + method public android.media.VolumeProvider2 getVolumeProvider(); + method public void notifyError(int, android.os.Bundle); method public void pause(); method public void play(); method public void prepare(); @@ -24826,14 +24831,14 @@ package android.media { method public void sendCustomCommand(android.media.MediaSession2.ControllerInfo, android.media.MediaSession2.Command, android.os.Bundle, android.os.ResultReceiver); method public void setAllowedCommands(android.media.MediaSession2.ControllerInfo, android.media.MediaSession2.CommandGroup); method public void setCustomLayout(android.media.MediaSession2.ControllerInfo, java.util.List<android.media.MediaSession2.CommandButton>); - method public void setPlayer(android.media.MediaPlayerBase); - method public void setPlayer(android.media.MediaPlayerBase, android.media.VolumeProvider2); + method public void setPlaybackSpeed(float); method public void setPlaylist(java.util.List<android.media.MediaItem2>); method public void setPlaylistParams(android.media.MediaSession2.PlaylistParams); method public void skipToNext(); method public void skipToPlaylistItem(android.media.MediaItem2); method public void skipToPrevious(); method public void stop(); + method public void updatePlayer(android.media.MediaPlayerBase, android.media.MediaPlaylistController, android.media.VolumeProvider2); field public static final int COMMAND_CODE_BROWSER = 22; // 0x16 field public static final int COMMAND_CODE_CUSTOM = 0; // 0x0 field public static final int COMMAND_CODE_PLAYBACK_FAST_FORWARD = 7; // 0x7 @@ -24842,10 +24847,10 @@ package android.media { field public static final int COMMAND_CODE_PLAYBACK_PREPARE = 6; // 0x6 field public static final int COMMAND_CODE_PLAYBACK_REWIND = 8; // 0x8 field public static final int COMMAND_CODE_PLAYBACK_SEEK_TO = 9; // 0x9 - field public static final int COMMAND_CODE_PLAYBACK_SET_CURRENT_PLAYLIST_ITEM = 10; // 0xa field public static final int COMMAND_CODE_PLAYBACK_SET_PLAYLIST_PARAMS = 11; // 0xb field public static final int COMMAND_CODE_PLAYBACK_SKIP_NEXT_ITEM = 4; // 0x4 field public static final int COMMAND_CODE_PLAYBACK_SKIP_PREV_ITEM = 5; // 0x5 + field public static final int COMMAND_CODE_PLAYBACK_SKIP_TO_PLAYLIST_ITEM = 10; // 0xa field public static final int COMMAND_CODE_PLAYBACK_STOP = 3; // 0x3 field public static final int COMMAND_CODE_PLAYLIST_ADD = 12; // 0xc field public static final int COMMAND_CODE_PLAYLIST_GET = 14; // 0xe @@ -24873,10 +24878,11 @@ package android.media { } public static final class MediaSession2.Builder { - ctor public MediaSession2.Builder(android.content.Context, android.media.MediaPlayerBase); - ctor public MediaSession2.Builder(android.content.Context, android.media.MediaPlayerBase, android.media.MediaPlaylistController); + ctor public MediaSession2.Builder(android.content.Context); method public android.media.MediaSession2 build(); method public android.media.MediaSession2.Builder setId(java.lang.String); + method public android.media.MediaSession2.Builder setPlayer(android.media.MediaPlayerBase); + method public android.media.MediaSession2.Builder setPlaylistController(android.media.MediaPlaylistController); method public android.media.MediaSession2.Builder setSessionActivity(android.app.PendingIntent); method public android.media.MediaSession2.Builder setSessionCallback(java.util.concurrent.Executor, android.media.MediaSession2.SessionCallback); method public android.media.MediaSession2.Builder setVolumeProvider(android.media.VolumeProvider2); @@ -24887,13 +24893,13 @@ package android.media { ctor public MediaSession2.Command(android.content.Context, java.lang.String, android.os.Bundle); method public int getCommandCode(); method public java.lang.String getCustomCommand(); - method public android.os.Bundle getExtra(); + method public android.os.Bundle getExtras(); } public static final class MediaSession2.CommandButton { method public android.media.MediaSession2.Command getCommand(); method public java.lang.String getDisplayName(); - method public android.os.Bundle getExtra(); + method public android.os.Bundle getExtras(); method public int getIconResId(); method public boolean isEnabled(); } @@ -24904,7 +24910,7 @@ package android.media { method public android.media.MediaSession2.CommandButton.Builder setCommand(android.media.MediaSession2.Command); method public android.media.MediaSession2.CommandButton.Builder setDisplayName(java.lang.String); method public android.media.MediaSession2.CommandButton.Builder setEnabled(boolean); - method public android.media.MediaSession2.CommandButton.Builder setExtra(android.os.Bundle); + method public android.media.MediaSession2.CommandButton.Builder setExtras(android.os.Bundle); method public android.media.MediaSession2.CommandButton.Builder setIconResId(int); } @@ -24913,6 +24919,7 @@ package android.media { ctor public MediaSession2.CommandGroup(android.content.Context, android.media.MediaSession2.CommandGroup); method public void addAllPredefinedCommands(); method public void addCommand(android.media.MediaSession2.Command); + method public java.util.List<android.media.MediaSession2.Command> getCommands(); method public boolean hasCommand(android.media.MediaSession2.Command); method public boolean hasCommand(int); method public void removeCommand(android.media.MediaSession2.Command); diff --git a/media/java/android/media/MediaController2.java b/media/java/android/media/MediaController2.java index c99a19bf1846..38d50004a95f 100644 --- a/media/java/android/media/MediaController2.java +++ b/media/java/android/media/MediaController2.java @@ -156,7 +156,7 @@ public class MediaController2 implements AutoCloseable, MediaPlaylistController * @param updateTimeMs timestamp when the position information is sent from the session * @param positionMs position in millis */ - public void onPositionUpdated(long updateTimeMs, long positionMs) { } + public void onPositionChanged(long updateTimeMs, long positionMs) { } /** * Called when playback speed is changed. @@ -176,9 +176,9 @@ public class MediaController2 implements AutoCloseable, MediaPlaylistController * Called when a error from * * @param errorCode error code - * @param extra extra information + * @param extras extra information */ - public void onError(@ErrorCode int errorCode, int extra) { } + public void onError(@ErrorCode int errorCode, @Nullable Bundle extras) { } /** * Called when the player's current playing item is changed @@ -599,7 +599,7 @@ public class MediaController2 implements AutoCloseable, MediaPlaylistController } /** - * Get the lastly cached position from {@link ControllerCallback#onPositionUpdated(long, long)}. + * Get the lastly cached position from {@link ControllerCallback#onPositionChanged(long, long)}. * <p> * This returns the calculated value of the position, based on the difference between the * update time and current time. @@ -621,6 +621,13 @@ public class MediaController2 implements AutoCloseable, MediaPlaylistController } /** + * Set the playback speed. + */ + public void setPlaybackSpeed(float speed) { + // TODO: implement this + } + + /** * Get the lastly cached buffered position from * {@link ControllerCallback#onBufferedPositionChanged(long)}. * @@ -700,7 +707,7 @@ public class MediaController2 implements AutoCloseable, MediaPlaylistController /** * Removes the media item at index in the playlist. *<p> - * If index is same as the current index of the playlist, current playback + * If the item is the currently playing item of the playlist, current playback * will be stopped and playback moves to next source in the list. */ @Override diff --git a/media/java/android/media/MediaLibraryService2.java b/media/java/android/media/MediaLibraryService2.java index 768d044f1583..5917190b17de 100644 --- a/media/java/android/media/MediaLibraryService2.java +++ b/media/java/android/media/MediaLibraryService2.java @@ -198,16 +198,25 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 { // Ideally it's better to make it inner class of service to enforce, it violates API // guideline that Builders should be the inner class of the building target. public Builder(@NonNull MediaLibraryService2 service, - @NonNull MediaPlayerBase player, @NonNull @CallbackExecutor Executor callbackExecutor, @NonNull MediaLibrarySessionCallback callback) { super((instance) -> ApiLoader.getProvider(service) - .createMediaLibraryService2Builder(service, (Builder) instance, player, + .createMediaLibraryService2Builder(service, (Builder) instance, callbackExecutor, callback)); } @Override - public Builder setVolumeProvider(@Nullable VolumeProvider2 volumeProvider) { + public Builder setPlayer(@NonNull MediaPlayerBase player) { + return super.setPlayer(player); + } + + @Override + public Builder setPlaylistController(@NonNull MediaPlaylistController mplc) { + return super.setPlaylistController(mplc); + } + + @Override + public Builder setVolumeProvider(@NonNull VolumeProvider2 volumeProvider) { return super.setVolumeProvider(volumeProvider); } diff --git a/media/java/android/media/MediaPlayerBase.java b/media/java/android/media/MediaPlayerBase.java index bc4ae7a8a696..f14bb8ac35cd 100644 --- a/media/java/android/media/MediaPlayerBase.java +++ b/media/java/android/media/MediaPlayerBase.java @@ -16,11 +16,9 @@ package android.media; -import android.annotation.CallbackExecutor; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; -import android.media.MediaSession2.PlaylistParams; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/media/java/android/media/MediaSession2.java b/media/java/android/media/MediaSession2.java index 7bfaeeff00fa..d49ae87e9647 100644 --- a/media/java/android/media/MediaSession2.java +++ b/media/java/android/media/MediaSession2.java @@ -24,6 +24,7 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.media.MediaPlayerBase.PlayerEventCallback; +import android.media.MediaPlaylistController; import android.media.session.MediaSession; import android.media.session.MediaSession.Callback; import android.media.session.PlaybackState; @@ -69,7 +70,7 @@ import java.util.concurrent.Executor; * <p> * When a session receive transport control commands, the session sends the commands directly to * the the underlying media player set by {@link Builder} or - * {@link #setPlayer(MediaPlayerBase)}. + * {@link #updatePlayer}. * <p> * When an app is finished performing playback it must call {@link #close()} to clean up the session * and notify any controllers. @@ -117,7 +118,7 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { public static final int COMMAND_CODE_PLAYBACK_STOP = 3; /** - * Command code for {@link MediaController2#skipToNext()} ()}. + * Command code for {@link MediaController2#skipToNext()}. * <p> * Command would be sent directly to the player if the session doesn't reject the request * through the {@link SessionCallback#onCommandRequest(ControllerInfo, Command)}. @@ -125,7 +126,7 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { public static final int COMMAND_CODE_PLAYBACK_SKIP_NEXT_ITEM = 4; /** - * Command code for {@link MediaController2#skipToPrevious()} ()}. + * Command code for {@link MediaController2#skipToPrevious()}. * <p> * Command would be sent directly to the player if the session doesn't reject the request * through the {@link SessionCallback#onCommandRequest(ControllerInfo, Command)}. @@ -170,10 +171,10 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { * Command would be sent directly to the player if the session doesn't reject the request * through the {@link SessionCallback#onCommandRequest(ControllerInfo, Command)}. */ - public static final int COMMAND_CODE_PLAYBACK_SET_CURRENT_PLAYLIST_ITEM = 10; + public static final int COMMAND_CODE_PLAYBACK_SKIP_TO_PLAYLIST_ITEM = 10; /** - * Command code for {@link MediaController2#setPlaylistParams(PlaylistParams)} ()}. + * Command code for {@link MediaController2#setPlaylistParams(PlaylistParams)}. * <p> * Command would be sent directly to the player if the session doesn't reject the request * through the {@link SessionCallback#onCommandRequest(ControllerInfo, Command)}. @@ -347,12 +348,12 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { .createMediaSession2Command(this, commandCode, null, null); } - public Command(@NonNull Context context, @NonNull String action, @Nullable Bundle extra) { + public Command(@NonNull Context context, @NonNull String action, @Nullable Bundle extras) { if (action == null) { throw new IllegalArgumentException("action shouldn't be null"); } mProvider = ApiLoader.getProvider(context) - .createMediaSession2Command(this, COMMAND_CODE_CUSTOM, action, extra); + .createMediaSession2Command(this, COMMAND_CODE_CUSTOM, action, extras); } public int getCommandCode() { @@ -363,8 +364,8 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { return mProvider.getCustomCommand_impl(); } - public @Nullable Bundle getExtra() { - return mProvider.getExtra_impl(); + public @Nullable Bundle getExtras() { + return mProvider.getExtras_impl(); } /** @@ -433,6 +434,11 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { return mProvider.hasCommand_impl(code); } + public List<Command> getCommands() { + // TODO: implement this + return null; + } + /** * @hide */ @@ -512,7 +518,7 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { * @see #COMMAND_CODE_PLAYBACK_FAST_FORWARD * @see #COMMAND_CODE_PLAYBACK_REWIND * @see #COMMAND_CODE_PLAYBACK_SEEK_TO - * @see #COMMAND_CODE_PLAYBACK_SET_CURRENT_PLAYLIST_ITEM + * @see #COMMAND_CODE_PLAYBACK_SKIP_TO_PLAYLIST_ITEM * @see #COMMAND_CODE_PLAYBACK_SET_PLAYLIST_PARAMS * @see #COMMAND_CODE_PLAYLIST_ADD * @see #COMMAND_CODE_PLAYLIST_REMOVE @@ -685,16 +691,38 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { } /** - * Set volume provider to configure this session to use remote volume handling. - * This must be called to receive volume button events, otherwise the system - * will adjust the appropriate stream volume for this session's player. + * Set the underlying {@link MediaPlayerBase} for this session to dispatch incoming event + * to. * <p> - * Set {@code null} to reset. * - * @param volumeProvider The provider that will handle volume changes. Can be {@code null}. + * @param player a {@link MediaPlayerBase} that handles actual media playback in your app. + */ + U setPlayer(@NonNull MediaPlayerBase player) { + // TODO: Change the provider properly + mProvider.setPlayer_impl(player, null, null); + return (U) this; + } + + /** + * Set the {@link MediaPlaylistController} for this session to manages playlist of the + * underlying {@link MediaPlayerBase player}. + * + * @param mplc a {@link MediaPlaylistController} that manages playlist of the + * {@code player.} + */ + U setPlaylistController(@NonNull MediaPlaylistController mplc) { + // TODO: implement this + return (U) this; + } + + /** + * Set the {@link VolumeProvider2} for this session to receive volume button events. If not + * set, system will adjust the appropriate stream volume for this session's player. + * + * @param volumeProvider The provider that will receive volume button events. */ - U setVolumeProvider(@Nullable VolumeProvider2 volumeProvider) { - mProvider.setVolumeProvider_impl(volumeProvider); + U setVolumeProvider(@NonNull VolumeProvider2 volumeProvider) { + // TODO: implement this return (U) this; } @@ -759,23 +787,32 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { // Override all methods just to show them with the type instead of generics in Javadoc. // This workarounds javadoc issue described in the MediaSession2.BuilderBase. public static final class Builder extends BuilderBase<MediaSession2, Builder, SessionCallback> { - public Builder(Context context, @NonNull MediaPlayerBase player) { + public Builder(Context context) { super((instance) -> ApiLoader.getProvider(context).createMediaSession2Builder( - context, (Builder) instance, player)); + context, (Builder) instance)); } - public Builder(Context context, @NonNull MediaPlayerBase player, - @NonNull MediaPlaylistController mplc) { - //TODO use the MediaPlaylistController - super((instance) -> ApiLoader.getProvider(context).createMediaSession2Builder( - context, (Builder) instance, player)); + @Override + public Builder setPlayer(@NonNull MediaPlayerBase player) { + if (player == null) { + throw new IllegalArgumentException("Illegal null MediaPlayerBase"); + } + return super.setPlayer(player); + } + + @Override + public Builder setPlaylistController(@NonNull MediaPlaylistController mplc) { if (mplc == null) { - throw new IllegalArgumentException("Illegal null PlaylistController"); + throw new IllegalArgumentException("Illegal null MediaPlaylistController"); } + return super.setPlaylistController(mplc); } @Override - public Builder setVolumeProvider(@Nullable VolumeProvider2 volumeProvider) { + public Builder setVolumeProvider(@NonNull VolumeProvider2 volumeProvider) { + if (volumeProvider == null) { + throw new IllegalArgumentException("Illegal null VolumeProvider2"); + } return super.setVolumeProvider(volumeProvider); } @@ -922,8 +959,8 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { * * @return */ - public @Nullable Bundle getExtra() { - return mProvider.getExtra_impl(); + public @Nullable Bundle getExtras() { + return mProvider.getExtras_impl(); } /** @@ -969,8 +1006,8 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { return mProvider.setEnabled_impl(enabled); } - public Builder setExtra(Bundle extra) { - return mProvider.setExtra_impl(extra); + public Builder setExtras(Bundle extras) { + return mProvider.setExtras_impl(extras); } public CommandButton build() { @@ -1135,28 +1172,17 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { * Set the underlying {@link MediaPlayerBase} for this session to dispatch incoming event * to. Events from the {@link MediaController2} will be sent directly to the underlying * player on the {@link Handler} where the session is created on. - * <p> - * For the remote playback case which you want to handle volume by yourself, use - * {@link #setPlayer(MediaPlayerBase, VolumeProvider2)}. * * @param player a {@link MediaPlayerBase} that handles actual media playback in your app. - * @throws IllegalArgumentException if the player is {@code null}. - */ - public void setPlayer(@NonNull MediaPlayerBase player) { - mProvider.setPlayer_impl(player); - } - - /** - * Set the underlying {@link MediaPlayerBase} with the volume provider for remote playback. - * - * @param player a {@link MediaPlayerBase} that handles actual media playback in your app. - * @param volumeProvider a volume provider - * @see #setPlayer(MediaPlayerBase) - * @see Builder#setVolumeProvider(VolumeProvider2) - */ - public void setPlayer(@NonNull MediaPlayerBase player, - @NonNull VolumeProvider2 volumeProvider) { - mProvider.setPlayer_impl(player, volumeProvider); + * @param mplc a {@link MediaPlaylistController} that manages playlist of the + * {@code player.} + * @param volumeProvider The provider that will receive volume button events. If + * {@code null}, system will adjust the appropriate stream volume for this session's player. + */ + public void updatePlayer(@NonNull MediaPlayerBase player, + @Nullable MediaPlaylistController mplc, @NonNull VolumeProvider2 volumeProvider) { + // TODO: rename setPlayer_impl to updatePlayer_impl + mProvider.setPlayer_impl(player, mplc, volumeProvider); } @Override @@ -1173,6 +1199,24 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { } /** + * @return playlist controller + */ + public @Nullable + MediaPlaylistController getMediaPlaylistController() { + // TODO: implement this + return null; + } + + /** + * @return volume provider + */ + public @Nullable + VolumeProvider2 getVolumeProvider() { + // TODO: implement this + return null; + } + + /** * Returns the {@link SessionToken2} for creating {@link MediaController2}. */ public @NonNull @@ -1368,9 +1412,9 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { } /** - * Remove the media item at index in the play list. + * Remove the media item in the play list. * <p> - * If index is same as the current index of the playlist, current playback + * If the item is the currently playing item of the playlist, current playback * will be stopped and playback moves to next source in the list. * * @throws IllegalArgumentException if the play list is null @@ -1398,18 +1442,6 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { } /** - * Edit the media item to the play list at position index. This is expected to be called when - * the metadata information is updated. - * <p> - * This will not change the currently playing media item. - * - * @param item the media item you want to add to the play list - */ - public void editPlaylistItem(@NonNull MediaItem2 item) { - mProvider.editPlaylistItem_impl(item); - } - - /** * Replace the media item at index in the playlist. * @param index the index of the item to replace * @param item the new item @@ -1462,10 +1494,10 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { * Notify errors to the connected controllers * * @param errorCode error code - * @param extra extra + * @param extras extras */ - public void notifyError(@ErrorCode int errorCode, int extra) { - mProvider.notifyError_impl(errorCode, extra); + public void notifyError(@ErrorCode int errorCode, @Nullable Bundle extras) { + mProvider.notifyError_impl(errorCode, extras); } /** @@ -1506,4 +1538,21 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController { public PlaybackState2 getPlaybackState() { return mProvider.getPlaybackState_impl(); } + + /** + * Get the playback speed. + * + * @return speed + */ + public float getPlaybackSpeed() { + // TODO: implement this + return -1; + } + + /** + * Set the playback speed. + */ + public void setPlaybackSpeed(float speed) { + // TODO: implement this + } } diff --git a/media/java/android/media/VolumeProvider2.java b/media/java/android/media/VolumeProvider2.java index 8e1cfbf3b5de..711f51f81013 100644 --- a/media/java/android/media/VolumeProvider2.java +++ b/media/java/android/media/VolumeProvider2.java @@ -31,7 +31,7 @@ import java.lang.annotation.RetentionPolicy; * {@link #setCurrentVolume(int)} each time the volume being provided changes. * <p> * You can set a volume provider on a session by calling - * {@link MediaSession2#setPlayer(MediaPlayerBase, VolumeProvider2)}. + * {@link MediaSession2#updatePlayer}. */ // New version of VolumeProvider with following changes // - Don't implement Parcelable for updatable support. diff --git a/media/java/android/media/update/MediaController2Provider.java b/media/java/android/media/update/MediaController2Provider.java index 6d1b1b1cd0f5..8d036be2c3aa 100644 --- a/media/java/android/media/update/MediaController2Provider.java +++ b/media/java/android/media/update/MediaController2Provider.java @@ -59,9 +59,9 @@ public interface MediaController2Provider extends TransportControlProvider { void sendCustomCommand_impl(Command command, Bundle args, ResultReceiver cb); List<MediaItem2> getPlaylist_impl(); - void removePlaylistItem_impl(MediaItem2 index); void addPlaylistItem_impl(int index, MediaItem2 item); void replacePlaylistItem_impl(int index, MediaItem2 item); + void removePlaylistItem_impl(MediaItem2 item); PlaylistParams getPlaylistParams_impl(); void setPlaylistParams_impl(PlaylistParams params); diff --git a/media/java/android/media/update/MediaSession2Provider.java b/media/java/android/media/update/MediaSession2Provider.java index d0b11b7385d5..d0ec10443a40 100644 --- a/media/java/android/media/update/MediaSession2Provider.java +++ b/media/java/android/media/update/MediaSession2Provider.java @@ -22,6 +22,7 @@ import android.media.MediaItem2; import android.media.MediaMetadata2; import android.media.MediaPlayerBase; import android.media.MediaPlayerBase.PlayerEventCallback; +import android.media.MediaPlaylistController; import android.media.MediaSession2; import android.media.MediaSession2.Command; import android.media.MediaSession2.CommandButton; @@ -43,8 +44,8 @@ import java.util.concurrent.Executor; */ public interface MediaSession2Provider extends TransportControlProvider { void close_impl(); - void setPlayer_impl(MediaPlayerBase player); - void setPlayer_impl(MediaPlayerBase player, VolumeProvider2 volumeProvider); + void setPlayer_impl(MediaPlayerBase player, MediaPlaylistController mplc, + VolumeProvider2 volumeProvider); MediaPlayerBase getPlayer_impl(); SessionToken2 getToken_impl(); List<ControllerInfo> getConnectedControllers_impl(); @@ -63,14 +64,14 @@ public interface MediaSession2Provider extends TransportControlProvider { MediaItem2 getCurrentPlaylistItem_impl(); void setPlaylistParams_impl(PlaylistParams params); PlaylistParams getPlaylistParams_impl(); - void notifyError_impl(int errorCode, int extra); + void notifyError_impl(int errorCode, Bundle extras); void registerPlayerEventCallback_impl(Executor executor, PlayerEventCallback callback); void unregisterPlayerEventCallback_impl(PlayerEventCallback callback); interface CommandProvider { int getCommandCode_impl(); String getCustomCommand_impl(); - Bundle getExtra_impl(); + Bundle getExtras_impl(); Bundle toBundle_impl(); boolean equals_impl(Object ob); @@ -90,7 +91,7 @@ public interface MediaSession2Provider extends TransportControlProvider { Command getCommand_impl(); int getIconResId_impl(); String getDisplayName_impl(); - Bundle getExtra_impl(); + Bundle getExtras_impl(); boolean isEnabled_impl(); interface BuilderProvider { @@ -98,7 +99,7 @@ public interface MediaSession2Provider extends TransportControlProvider { Builder setIconResId_impl(int resId); Builder setDisplayName_impl(String displayName); Builder setEnabled_impl(boolean enabled); - Builder setExtra_impl(Bundle extra); + Builder setExtras_impl(Bundle extras); CommandButton build_impl(); } } @@ -119,7 +120,8 @@ public interface MediaSession2Provider extends TransportControlProvider { } interface BuilderBaseProvider<T extends MediaSession2, C extends SessionCallback> { - void setVolumeProvider_impl(VolumeProvider2 volumeProvider); + void setPlayer_impl(MediaPlayerBase player, MediaPlaylistController mplc, + VolumeProvider2 volumeProvider); void setSessionActivity_impl(PendingIntent pi); void setId_impl(String id); void setSessionCallback_impl(Executor executor, C callback); diff --git a/media/java/android/media/update/StaticProvider.java b/media/java/android/media/update/StaticProvider.java index 62759eb15a2b..47f5ed3287bf 100644 --- a/media/java/android/media/update/StaticProvider.java +++ b/media/java/android/media/update/StaticProvider.java @@ -30,7 +30,6 @@ import android.media.MediaLibraryService2.LibraryRoot; import android.media.MediaLibraryService2.MediaLibrarySession; import android.media.MediaLibraryService2.MediaLibrarySession.MediaLibrarySessionCallback; import android.media.MediaMetadata2; -import android.media.MediaPlayerBase; import android.media.MediaSession2; import android.media.MediaSession2.CommandButton.Builder; import android.media.MediaSession2.PlaylistParams; @@ -88,7 +87,7 @@ public interface StaticProvider { CommandButtonProvider.BuilderProvider createMediaSession2CommandButtonBuilder(Context context, MediaSession2.CommandButton.Builder builder); BuilderBaseProvider<MediaSession2, SessionCallback> createMediaSession2Builder( - Context context, MediaSession2.Builder instance, MediaPlayerBase player); + Context context, MediaSession2.Builder instance); MediaController2Provider createMediaController2(Context context, MediaController2 instance, SessionToken2 token, Executor executor, ControllerCallback callback); @@ -104,8 +103,7 @@ public interface StaticProvider { BuilderBaseProvider<MediaLibrarySession, MediaLibrarySessionCallback> createMediaLibraryService2Builder( MediaLibraryService2 service, MediaLibrarySession.Builder instance, - MediaPlayerBase player, Executor callbackExecutor, - MediaLibrarySessionCallback callback); + Executor callbackExecutor, MediaLibrarySessionCallback callback); LibraryRootProvider createMediaLibraryService2LibraryRoot(Context context, LibraryRoot instance, String rootId, Bundle extras); |