summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jaewan Kim <jaewan@google.com> 2018-03-07 00:02:09 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-03-07 00:02:09 +0000
commitccf41b87a990f12cc76bd57f67f1466bd48408c6 (patch)
treecb41c1143d44c49081eecb2a48acc9a25f0f44b3
parent540a2903cd39c7fc4533be078dd8451a861031d2 (diff)
parent42a36c341dcac1e12d178ef063e73669eec12cf1 (diff)
Merge changes from topic "session2-pi-listcallback" into pi-dev
* changes: MediaSession2: Pass player info for the callbacks from MediaPlayerBase MediaSession2: Add MediaPlaylistController.PlaylistEventCallback
-rw-r--r--api/current.txt100
-rw-r--r--media/java/android/media/MediaController2.java142
-rw-r--r--media/java/android/media/MediaPlayerBase.java2
-rw-r--r--media/java/android/media/MediaPlaylistController.java234
-rw-r--r--media/java/android/media/MediaSession2.java419
5 files changed, 705 insertions, 192 deletions
diff --git a/api/current.txt b/api/current.txt
index 307fc4bfcb37..7fe87e4365f0 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -23363,10 +23363,12 @@ package android.media {
method public float getPlaybackSpeed();
method public int getPlayerState();
method public java.util.List<android.media.MediaItem2> getPlaylist();
- method public android.media.MediaSession2.PlaylistParams getPlaylistParams();
+ method public android.media.MediaMetadata2 getPlaylistMetadata();
method public long getPosition();
+ method public int getRepeatMode();
method public android.app.PendingIntent getSessionActivity();
method public android.media.SessionToken2 getSessionToken();
+ method public int getShuffleMode();
method public boolean isConnected();
method public void pause();
method public void play();
@@ -23377,19 +23379,24 @@ package android.media {
method public void prepareFromMediaId(java.lang.String, android.os.Bundle);
method public void prepareFromSearch(java.lang.String, android.os.Bundle);
method public void prepareFromUri(android.net.Uri, android.os.Bundle);
+ method public void registerPlaylistControllerCallback(java.util.concurrent.Executor, android.media.MediaPlaylistController.PlaylistEventCallback);
method public void removePlaylistItem(android.media.MediaItem2);
method public void replacePlaylistItem(int, android.media.MediaItem2);
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 setPlaylist(java.util.List<android.media.MediaItem2>, android.media.MediaMetadata2);
method public void setRating(java.lang.String, android.media.Rating2);
+ method public void setRepeatMode(int);
+ method public void setShuffleMode(int);
method public void setVolumeTo(int, int);
method public void skipToNext();
method public void skipToPlaylistItem(android.media.MediaItem2);
method public void skipToPrevious();
method public void stop();
+ method public void unregisterPlaylistControllerCallback(android.media.MediaPlaylistController.PlaylistEventCallback);
+ method public void updatePlaylistMetadata(android.media.MediaMetadata2);
}
public static abstract class MediaController2.ControllerCallback {
@@ -23405,8 +23412,6 @@ package android.media {
method public void onPlaybackInfoChanged(android.media.MediaController2, android.media.MediaController2.PlaybackInfo);
method public void onPlaybackSpeedChanged(android.media.MediaController2, float);
method public void onPlayerStateChanged(android.media.MediaController2, int);
- method public void onPlaylistChanged(android.media.MediaController2, java.util.List<android.media.MediaItem2>);
- method public void onPlaylistParamsChanged(android.media.MediaController2, android.media.MediaSession2.PlaylistParams);
method public void onPositionChanged(android.media.MediaController2, long, long);
}
@@ -24541,9 +24546,33 @@ package android.media {
method public abstract void addPlaylistItem(int, android.media.MediaItem2);
method public abstract android.media.MediaItem2 getCurrentPlaylistItem();
method public abstract java.util.List<android.media.MediaItem2> getPlaylist();
+ method public abstract android.media.MediaMetadata2 getPlaylistMetadata();
+ method public abstract int getRepeatMode();
+ method public abstract int getShuffleMode();
+ method public abstract void registerPlaylistControllerCallback(java.util.concurrent.Executor, android.media.MediaPlaylistController.PlaylistEventCallback);
method public abstract void removePlaylistItem(android.media.MediaItem2);
method public abstract void replacePlaylistItem(int, android.media.MediaItem2);
+ method public abstract void setPlaylist(java.util.List<android.media.MediaItem2>, android.media.MediaMetadata2);
+ method public abstract void setRepeatMode(int);
+ method public abstract void setShuffleMode(int);
method public abstract void skipToPlaylistItem(android.media.MediaItem2);
+ method public abstract void unregisterPlaylistControllerCallback(android.media.MediaPlaylistController.PlaylistEventCallback);
+ method public abstract void updatePlaylistMetadata(android.media.MediaMetadata2);
+ field public static final int REPEAT_MODE_ALL = 2; // 0x2
+ field public static final int REPEAT_MODE_GROUP = 3; // 0x3
+ field public static final int REPEAT_MODE_NONE = 0; // 0x0
+ field public static final int REPEAT_MODE_ONE = 1; // 0x1
+ field public static final int SHUFFLE_MODE_ALL = 1; // 0x1
+ field public static final int SHUFFLE_MODE_GROUP = 2; // 0x2
+ field public static final int SHUFFLE_MODE_NONE = 0; // 0x0
+ }
+
+ public static abstract class MediaPlaylistController.PlaylistEventCallback {
+ ctor public MediaPlaylistController.PlaylistEventCallback();
+ method public void onPlaylistChanged(android.media.MediaPlaylistController, java.util.List<android.media.MediaItem2>, android.media.MediaMetadata2);
+ method public void onPlaylistMetadataChanged(android.media.MediaPlaylistController, android.media.MediaMetadata2);
+ method public void onRepeatModeChanged(android.media.MediaPlaylistController, int);
+ method public void onShuffleModeChanged(android.media.MediaPlaylistController, int);
}
public class MediaRecorder implements android.media.AudioRouting {
@@ -24832,13 +24861,16 @@ package android.media {
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.MediaMetadata2 getPlaylistMetadata();
+ method public int getRepeatMode();
+ method public int getShuffleMode();
method public android.media.SessionToken2 getToken();
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();
+ method public void registerPlaylistControllerCallback(java.util.concurrent.Executor, android.media.MediaPlaylistController.PlaylistEventCallback);
method public void removePlaylistItem(android.media.MediaItem2);
method public void replacePlaylistItem(int, android.media.MediaItem2);
method public void rewind();
@@ -24849,36 +24881,45 @@ package android.media {
method public void setAudioFocusRequest(android.media.AudioFocusRequest);
method public void setCustomLayout(android.media.MediaSession2.ControllerInfo, java.util.List<android.media.MediaSession2.CommandButton>);
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 setPlaylist(java.util.List<android.media.MediaItem2>, android.media.MediaMetadata2);
+ method public void setRepeatMode(int);
+ method public void setShuffleMode(int);
method public void skipToNext();
method public void skipToPlaylistItem(android.media.MediaItem2);
method public void skipToPrevious();
method public void stop();
+ method public void unregisterPlaylistControllerCallback(android.media.MediaPlaylistController.PlaylistEventCallback);
method public void updatePlayer(android.media.MediaPlayerBase, android.media.MediaPlaylistController, android.media.VolumeProvider2);
- field public static final int COMMAND_CODE_BROWSER = 22; // 0x16
+ method public void updatePlaylistMetadata(android.media.MediaMetadata2);
+ field public static final int COMMAND_CODE_BROWSER = 28; // 0x1c
field public static final int COMMAND_CODE_CUSTOM = 0; // 0x0
+ field public static final int COMMAND_CODE_PLAYBACK_ADJUST_VOLUME = 11; // 0xb
field public static final int COMMAND_CODE_PLAYBACK_FAST_FORWARD = 7; // 0x7
field public static final int COMMAND_CODE_PLAYBACK_PAUSE = 2; // 0x2
field public static final int COMMAND_CODE_PLAYBACK_PLAY = 1; // 0x1
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_PLAYLIST_PARAMS = 11; // 0xb
+ field public static final int COMMAND_CODE_PLAYBACK_SET_VOLUME = 10; // 0xa
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
- field public static final int COMMAND_CODE_PLAYLIST_REMOVE = 13; // 0xd
- field public static final int COMMAND_CODE_PLAY_FROM_MEDIA_ID = 16; // 0x10
- field public static final int COMMAND_CODE_PLAY_FROM_SEARCH = 18; // 0x12
- field public static final int COMMAND_CODE_PLAY_FROM_URI = 17; // 0x11
- field public static final int COMMAND_CODE_PREPARE_FROM_MEDIA_ID = 19; // 0x13
- field public static final int COMMAND_CODE_PREPARE_FROM_SEARCH = 21; // 0x15
- field public static final int COMMAND_CODE_PREPARE_FROM_URI = 20; // 0x14
- field public static final int COMMAND_CODE_SET_VOLUME = 15; // 0xf
+ field public static final int COMMAND_CODE_PLAYLIST_ADD_ITEM = 15; // 0xf
+ field public static final int COMMAND_CODE_PLAYLIST_GET_LIST = 18; // 0x12
+ field public static final int COMMAND_CODE_PLAYLIST_GET_LIST_METADATA = 20; // 0x14
+ field public static final int COMMAND_CODE_PLAYLIST_REMOVE_ITEM = 16; // 0x10
+ field public static final int COMMAND_CODE_PLAYLIST_REPLACE_ITEM = 17; // 0x11
+ field public static final int COMMAND_CODE_PLAYLIST_SET_LIST = 19; // 0x13
+ field public static final int COMMAND_CODE_PLAYLIST_SET_LIST_METADATA = 21; // 0x15
+ field public static final int COMMAND_CODE_PLAYLIST_SET_REPEAT_MODE = 14; // 0xe
+ field public static final int COMMAND_CODE_PLAYLIST_SET_SHUFFLE_MODE = 13; // 0xd
+ field public static final int COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM = 12; // 0xc
+ field public static final int COMMAND_CODE_PLAY_FROM_MEDIA_ID = 22; // 0x16
+ field public static final int COMMAND_CODE_PLAY_FROM_SEARCH = 24; // 0x18
+ field public static final int COMMAND_CODE_PLAY_FROM_URI = 23; // 0x17
+ field public static final int COMMAND_CODE_PREPARE_FROM_MEDIA_ID = 25; // 0x19
+ field public static final int COMMAND_CODE_PREPARE_FROM_SEARCH = 27; // 0x1b
+ field public static final int COMMAND_CODE_PREPARE_FROM_URI = 26; // 0x1a
field public static final int ERROR_CODE_ACTION_ABORTED = 10; // 0xa
field public static final int ERROR_CODE_APP_ERROR = 1; // 0x1
field public static final int ERROR_CODE_AUTHENTICATION_EXPIRED = 3; // 0x3
@@ -24948,31 +24989,18 @@ package android.media {
method public boolean isTrusted();
}
- public static final class MediaSession2.PlaylistParams {
- ctor public MediaSession2.PlaylistParams(android.content.Context, int, int, android.media.MediaMetadata2);
- method public static android.media.MediaSession2.PlaylistParams fromBundle(android.content.Context, android.os.Bundle);
- method public android.media.MediaMetadata2 getPlaylistMetadata();
- method public int getRepeatMode();
- method public int getShuffleMode();
- method public android.os.Bundle toBundle();
- field public static final int REPEAT_MODE_ALL = 2; // 0x2
- field public static final int REPEAT_MODE_GROUP = 3; // 0x3
- field public static final int REPEAT_MODE_NONE = 0; // 0x0
- field public static final int REPEAT_MODE_ONE = 1; // 0x1
- field public static final int SHUFFLE_MODE_ALL = 1; // 0x1
- field public static final int SHUFFLE_MODE_GROUP = 2; // 0x2
- field public static final int SHUFFLE_MODE_NONE = 0; // 0x0
- }
-
public static abstract class MediaSession2.SessionCallback {
ctor public MediaSession2.SessionCallback(android.content.Context);
+ method public void onBufferingStateChanged(android.media.MediaSession2, android.media.MediaPlayerBase, android.media.MediaItem2, int);
method public boolean onCommandRequest(android.media.MediaSession2, android.media.MediaSession2.ControllerInfo, android.media.MediaSession2.Command);
method public android.media.MediaSession2.CommandGroup onConnect(android.media.MediaSession2, android.media.MediaSession2.ControllerInfo);
method public void onCustomCommand(android.media.MediaSession2, android.media.MediaSession2.ControllerInfo, android.media.MediaSession2.Command, android.os.Bundle, android.os.ResultReceiver);
method public void onDisconnected(android.media.MediaSession2, android.media.MediaSession2.ControllerInfo);
+ method public void onMediaPrepared(android.media.MediaSession2, android.media.MediaPlayerBase, android.media.MediaItem2);
method public void onPlayFromMediaId(android.media.MediaSession2, android.media.MediaSession2.ControllerInfo, java.lang.String, android.os.Bundle);
method public void onPlayFromSearch(android.media.MediaSession2, android.media.MediaSession2.ControllerInfo, java.lang.String, android.os.Bundle);
method public void onPlayFromUri(android.media.MediaSession2, android.media.MediaSession2.ControllerInfo, android.net.Uri, android.os.Bundle);
+ method public void onPlayerStateChanged(android.media.MediaSession2, android.media.MediaPlayerBase, int);
method public void onPrepareFromMediaId(android.media.MediaSession2, android.media.MediaSession2.ControllerInfo, java.lang.String, android.os.Bundle);
method public void onPrepareFromSearch(android.media.MediaSession2, android.media.MediaSession2.ControllerInfo, java.lang.String, android.os.Bundle);
method public void onPrepareFromUri(android.media.MediaSession2, android.media.MediaSession2.ControllerInfo, android.net.Uri, android.os.Bundle);
diff --git a/media/java/android/media/MediaController2.java b/media/java/android/media/MediaController2.java
index df7b5afc83e3..25188fb1ba3c 100644
--- a/media/java/android/media/MediaController2.java
+++ b/media/java/android/media/MediaController2.java
@@ -147,7 +147,9 @@ public class MediaController2 implements AutoCloseable, MediaPlaylistController
* @see #onPositionChanged(MediaController2, long, long)
* @see #onBufferedPositionChanged(MediaController2, long)
* @see #onCurrentPlaylistItemChanged(MediaController2, MediaItem2)
+ * @hide
*/
+ // TODO(jaewan): Remove (b/74174728)
public void onPlaylistChanged(@NonNull MediaController2 controller,
@NonNull List<MediaItem2> playlist) { }
@@ -228,7 +230,9 @@ public class MediaController2 implements AutoCloseable, MediaPlaylistController
*
* @param controller the controller for this event
* @param params The new play list parameters.
+ * @hide
*/
+ // TODO(jaewan): Remove (b/74116823)
public void onPlaylistParamsChanged(@NonNull MediaController2 controller,
@NonNull PlaylistParams params) { }
}
@@ -440,24 +444,14 @@ public class MediaController2 implements AutoCloseable, MediaPlaylistController
}
/**
- * Sets the index of current DataSourceDesc in the play list to be played.
- *
- * @param item the index of DataSourceDesc in the play list you want to play
- * @throws IllegalArgumentException if the play list is null
- * @throws NullPointerException if index is outside play list range
- */
- @Override
- public void skipToPlaylistItem(@NonNull MediaItem2 item) {
- mProvider.skipToPlaylistItem_impl(item);
- }
-
- /**
* Sets the {@link PlaylistParams} for the current play list. Repeat/shuffle mode and metadata
* for the list can be set by calling this method.
*
* @param params A {@link PlaylistParams} object to set.
* @throws IllegalArgumentException if given {@param param} is null.
+ * @hide
*/
+ // TODO(jaewan): Remove (b/74116823)
public void setPlaylistParams(@NonNull PlaylistParams params) {
mProvider.setPlaylistParams_impl(params);
}
@@ -672,17 +666,6 @@ public class MediaController2 implements AutoCloseable, MediaPlaylistController
}
/**
- * Get the lastly cached current item from
- * {@link ControllerCallback#onCurrentPlaylistItemChanged(MediaController2, MediaItem2)}.
- *
- * @return index of the current item
- */
- @Override
- public MediaItem2 getCurrentPlaylistItem() {
- return mProvider.getCurrentPlaylistItem_impl();
- }
-
- /**
* Get the current playback info for this session.
*
* @return The current playback info or null.
@@ -720,6 +703,35 @@ public class MediaController2 implements AutoCloseable, MediaPlaylistController
}
/**
+ * Register {@link MediaPlaylistController.PlaylistEventCallback} to listen changes in the
+ * underlying {@link MediaPlaylistController}, regardless of the change in the controller.
+ * <p>
+ * Registered callbacks will be also called when the controller is changed.
+ *
+ * @param executor a callback Executor
+ * @param callback a PlaylistEventCallback
+ * @throws IllegalArgumentException if executor or callback is {@code null}.
+ */
+ @Override
+ public void registerPlaylistControllerCallback(@NonNull @CallbackExecutor Executor executor,
+ @NonNull PlaylistEventCallback callback) {
+ // TODO(jaewan): Implement (b/74169681)
+ //mProvider.registerPlaylistControllerCallback_impl(executor, callback);
+ }
+
+ /**
+ * Unregister the previously registered {@link MediaPlaylistController.PlaylistEventCallback}.
+ *
+ * @param callback the callback to be removed
+ * @throws IllegalArgumentException if the callback is {@code null}.
+ */
+ @Override
+ public void unregisterPlaylistControllerCallback(@NonNull PlaylistEventCallback callback) {
+ // TODO(jaewan): Implement (b/74169681)
+ //mProvider.unregisterPlaylistControllerCallback_impl(callback);
+ }
+
+ /**
* Return playlist from the session.
*
* @return playlist. Can be {@code null} if the controller doesn't have enough permission.
@@ -729,16 +741,51 @@ public class MediaController2 implements AutoCloseable, MediaPlaylistController
return mProvider.getPlaylist_impl();
}
+
+ @Override
+ public void setPlaylist(@NonNull List<MediaItem2> list, @Nullable MediaMetadata2 metadata) {
+ // TODO(jaewan): Implement (b/74174649)
+ }
+
+ @Override
+ public void updatePlaylistMetadata(@Nullable MediaMetadata2 metadata) {
+ // TODO(jaewan): Implement (b/74174649)
+ }
+
+ @Override
+ public @Nullable MediaMetadata2 getPlaylistMetadata() {
+ // TODO(jaewan): Implement (b/74174649)
+ return null;
+ }
+
/**
* Returns the {@link PlaylistParams} for the current play list.
* Can return {@code null} if the controller doesn't have enough permission, or if the session
* has not set the parameters.
+ * @hide
*/
+ // TODO(jaewan): Remove (b/74116823)
public @Nullable PlaylistParams getPlaylistParams() {
return mProvider.getPlaylistParams_impl();
}
/**
+ * Inserts the media item to the play list at position index.
+ * <p>
+ * This will not change the currently playing media item.
+ * If index is less than or equal to the current index of the play list,
+ * the current index of the play list will be incremented correspondingly.
+ *
+ * @param index the index you want to add
+ * @param item the media item you want to add
+ * @throws IndexOutOfBoundsException if index is outside play list range
+ */
+ @Override
+ public void addPlaylistItem(int index, @NonNull MediaItem2 item) {
+ mProvider.addPlaylistItem_impl(index, item);
+ }
+
+ /**
* Removes the media item at index in the playlist.
*<p>
* If the item is the currently playing item of the playlist, current playback
@@ -760,18 +807,47 @@ public class MediaController2 implements AutoCloseable, MediaPlaylistController
}
/**
- * Inserts the media item to the play list at position index.
- * <p>
- * This will not change the currently playing media item.
- * If index is less than or equal to the current index of the play list,
- * the current index of the play list will be incremented correspondingly.
+ * Get the lastly cached current item from
+ * {@link ControllerCallback#onCurrentPlaylistItemChanged(MediaController2, MediaItem2)}.
*
- * @param index the index you want to add
- * @param item the media item you want to add
- * @throws IndexOutOfBoundsException if index is outside play list range
+ * @return index of the current item
*/
@Override
- public void addPlaylistItem(int index, @NonNull MediaItem2 item) {
- mProvider.addPlaylistItem_impl(index, item);
+ public MediaItem2 getCurrentPlaylistItem() {
+ return mProvider.getCurrentPlaylistItem_impl();
+ }
+
+ /**
+ * Sets the index of current DataSourceDesc in the play list to be played.
+ *
+ * @param item the index of DataSourceDesc in the play list you want to play
+ * @throws IllegalArgumentException if the play list is null
+ * @throws NullPointerException if index is outside play list range
+ */
+ @Override
+ public void skipToPlaylistItem(@NonNull MediaItem2 item) {
+ mProvider.skipToPlaylistItem_impl(item);
+ }
+
+ @Override
+ public @RepeatMode int getRepeatMode() {
+ // TODO(jaewan): Implement (b/74118768)
+ return 0;
+ }
+
+ @Override
+ public void setRepeatMode(int repeatMode) {
+ // TODO(jaewan): Implement (b/74118768)
+ }
+
+ @Override
+ public @ShuffleMode int getShuffleMode() {
+ // TODO(jaewan): Implement (b/74118768)
+ return 0;
+ }
+
+ @Override
+ public void setShuffleMode(int shuffleMode) {
+ // TODO(jaewan): Implement (b/74118768)
}
}
diff --git a/media/java/android/media/MediaPlayerBase.java b/media/java/android/media/MediaPlayerBase.java
index 24274f1356e3..70a36bf201dd 100644
--- a/media/java/android/media/MediaPlayerBase.java
+++ b/media/java/android/media/MediaPlayerBase.java
@@ -278,7 +278,7 @@ public abstract class MediaPlayerBase implements AutoCloseable {
*/
public static abstract class PlayerEventCallback {
/**
- * Called when the player's curretn data source has changed.
+ * Called when the player's current data source has changed.
* @param mpb the player whose data source changed.
* @param dsd the new current data source.
*/
diff --git a/media/java/android/media/MediaPlaylistController.java b/media/java/android/media/MediaPlaylistController.java
index c98d50e2c5e7..1ad56178b757 100644
--- a/media/java/android/media/MediaPlaylistController.java
+++ b/media/java/android/media/MediaPlaylistController.java
@@ -16,9 +16,18 @@
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 android.media.MediaSession2.PlaylistParams.RepeatMode;
+import android.media.MediaSession2.PlaylistParams.ShuffleMode;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.List;
+import java.util.concurrent.Executor;
/**
* Controller interface for playlist management.
@@ -30,10 +39,231 @@ import java.util.List;
// Note that setPlaylist() isn't added on purpose because it's considered session-specific.
public interface MediaPlaylistController {
+ /**
+ * @hide
+ */
+ @IntDef({REPEAT_MODE_NONE, REPEAT_MODE_ONE, REPEAT_MODE_ALL,
+ REPEAT_MODE_GROUP})
+ @Retention(RetentionPolicy.SOURCE)
+ @interface RepeatMode {}
+
+ /**
+ * Playback will be stopped at the end of the playing media list.
+ */
+ int REPEAT_MODE_NONE = 0;
+
+ /**
+ * Playback of the current playing media item will be repeated.
+ */
+ int REPEAT_MODE_ONE = 1;
+
+ /**
+ * Playing media list will be repeated.
+ */
+ int REPEAT_MODE_ALL = 2;
+
+ /**
+ * Playback of the playing media group will be repeated.
+ * A group is a logical block of media items which is specified in the section 5.7 of the
+ * Bluetooth AVRCP 1.6. An example of a group is the playlist.
+ */
+ int REPEAT_MODE_GROUP = 3;
+
+ /**
+ * @hide
+ */
+ @IntDef({SHUFFLE_MODE_NONE, SHUFFLE_MODE_ALL, SHUFFLE_MODE_GROUP})
+ @Retention(RetentionPolicy.SOURCE)
+ @interface ShuffleMode {}
+
+ /**
+ * Media list will be played in order.
+ */
+ int SHUFFLE_MODE_NONE = 0;
+
+ /**
+ * Media list will be played in shuffled order.
+ */
+ int SHUFFLE_MODE_ALL = 1;
+
+ /**
+ * Media group will be played in shuffled order.
+ * A group is a logical block of media items which is specified in the section 5.7 of the
+ * Bluetooth AVRCP 1.6. An example of a group is the playlist.
+ */
+ int SHUFFLE_MODE_GROUP = 2;
+
+ abstract class PlaylistEventCallback {
+ /**
+ * Called when a playlist is changed.
+ *
+ * @param mplc playlist controller for this event
+ * @param list new playlist
+ * @param metadata new metadata
+ */
+ public void onPlaylistChanged(@NonNull MediaPlaylistController mplc,
+ @NonNull List<MediaItem2> list, @Nullable MediaMetadata2 metadata) { }
+
+ /**
+ * Called when a playlist is changed.
+ *
+ * @param mplc playlist controller for this event
+ * @param metadata new metadata
+ */
+ public void onPlaylistMetadataChanged(@NonNull MediaPlaylistController mplc,
+ @Nullable MediaMetadata2 metadata) { }
+
+ /**
+ * Called when a playlist is changed.
+ *
+ * @param mplc playlist controller for this event
+ * @param shuffleMode repeat mode
+ * @see #SHUFFLE_MODE_NONE
+ * @see #SHUFFLE_MODE_ALL
+ * @see #SHUFFLE_MODE_GROUP
+ */
+ public void onShuffleModeChanged(@NonNull MediaPlaylistController mplc,
+ @ShuffleMode int shuffleMode) { }
+
+ /**
+ * Called when a playlist is changed.
+ *
+ * @param mplc playlist controller for this event
+ * @param repeatMode repeat mode
+ * @see #REPEAT_MODE_NONE
+ * @see #REPEAT_MODE_ONE
+ * @see #REPEAT_MODE_ALL
+ * @see #REPEAT_MODE_GROUP
+ */
+ public void onRepeatModeChanged(@NonNull MediaPlaylistController mplc,
+ @RepeatMode int repeatMode) { }
+ }
+
+ /**
+ * Register {@link PlaylistEventCallback} to listen changes in the underlying
+ * {@link MediaPlaylistController}, regardless of the change in the controller.
+ *
+ * @param executor a callback Executor
+ * @param callback a PlaylistEventCallback
+ * @throws IllegalArgumentException if executor or callback is {@code null}.
+ */
+ void registerPlaylistControllerCallback(@NonNull @CallbackExecutor Executor executor,
+ @NonNull PlaylistEventCallback callback);
+
+ /**
+ * Unregister the previously registered {@link PlaylistEventCallback}.
+ *
+ * @param callback the callback to be removed
+ * @throws IllegalArgumentException if the callback is {@code null}.
+ */
+ void unregisterPlaylistControllerCallback(@NonNull PlaylistEventCallback callback);
+
+ /**
+ * Returns the playlist
+ *
+ * @return playlist, or null if none is set.
+ */
+ @Nullable List<MediaItem2> getPlaylist();
+
+ /**
+ * Sets the playlist.
+ *
+ * @param list playlist
+ * @param metadata metadata of the playlist
+ */
+ void setPlaylist(@NonNull List<MediaItem2> list, @Nullable MediaMetadata2 metadata);
+
+ /**
+ * Returns the playlist metadata
+ *
+ * @return metadata metadata of the playlist, or null if none is set
+ */
+ @Nullable MediaMetadata2 getPlaylistMetadata();
+
+ /**
+ * Updates the playlist metadata
+ *
+ * @param metadata metadata of the playlist
+ */
+ void updatePlaylistMetadata(@Nullable MediaMetadata2 metadata);
+
+ /**
+ * Adds the media item to the playlist at the index
+ *
+ * @param index index
+ * @param item media item to add
+ */
void addPlaylistItem(int index, @NonNull MediaItem2 item);
+
+ /**
+ * Removes the media item from the playlist
+ *
+ * @param item media item to remove
+ */
void removePlaylistItem(@NonNull MediaItem2 item);
+
+ /**
+ * Replaces the media item with the .
+ * <p>
+ * This can be used to update metadata of a MediaItem.
+ *
+ * @param index index
+ * @param item
+ */
+ void replacePlaylistItem(int index, @NonNull MediaItem2 item);
+
+ /**
+ * Returns the current media item.
+ * @return the current media item, or null if none is set, or none available to play.
+ */
MediaItem2 getCurrentPlaylistItem();
+
+ /**
+ * Skips to the the media item, and plays from it.
+ *
+ * @param item media item to start playing from
+ */
void skipToPlaylistItem(@NonNull MediaItem2 item);
- void replacePlaylistItem(int index, @NonNull MediaItem2 item);
- List<MediaItem2> getPlaylist();
+
+ /**
+ * Get repeat mode
+ *
+ * @return repeat mode
+ * @see #REPEAT_MODE_NONE
+ * @see #REPEAT_MODE_ONE
+ * @see #REPEAT_MODE_ALL
+ * @see #REPEAT_MODE_GROUP
+ */
+ @RepeatMode int getRepeatMode();
+
+ /**
+ * Set repeat mode
+ *
+ * @param repeatMode repeat mode
+ * @see #REPEAT_MODE_NONE
+ * @see #REPEAT_MODE_ONE
+ * @see #REPEAT_MODE_ALL
+ * @see #REPEAT_MODE_GROUP
+ */
+ void setRepeatMode(@RepeatMode int repeatMode);
+
+ /**
+ * Get shuffle mode
+ *
+ * @return shuffle mode
+ * @see #SHUFFLE_MODE_NONE
+ * @see #SHUFFLE_MODE_ALL
+ * @see #SHUFFLE_MODE_GROUP
+ */
+ @ShuffleMode int getShuffleMode();
+
+ /**
+ * Set shuffle mode
+ *
+ * @param shuffleMode shuffle mode
+ * @see #SHUFFLE_MODE_NONE
+ * @see #SHUFFLE_MODE_ALL
+ * @see #SHUFFLE_MODE_GROUP
+ */
+ void setShuffleMode(@ShuffleMode int shuffleMode);
}
diff --git a/media/java/android/media/MediaSession2.java b/media/java/android/media/MediaSession2.java
index cad63e3950a1..ddb51c3e697d 100644
--- a/media/java/android/media/MediaSession2.java
+++ b/media/java/android/media/MediaSession2.java
@@ -23,7 +23,9 @@ import android.annotation.Nullable;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
+import android.media.MediaPlayerBase.BuffState;
import android.media.MediaPlayerBase.PlayerEventCallback;
+import android.media.MediaPlayerBase.PlayerState;
import android.media.session.MediaSession;
import android.media.session.MediaSession.Callback;
import android.media.session.PlaybackState;
@@ -81,7 +83,6 @@ import java.util.concurrent.Executor;
public class MediaSession2 implements AutoCloseable, MediaPlaylistController {
private final MediaSession2Provider mProvider;
- // Next ID: 23
/**
* Command code for the custom command which can be defined by string action in the
* {@link Command}.
@@ -160,94 +161,173 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController {
* through the {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
*/
public static final int COMMAND_CODE_PLAYBACK_SEEK_TO = 9;
+
/**
- * Command code for {@link MediaController2#skipToPlaylistItem(MediaItem2)}.
+ * Command code for both {@link MediaController2#setVolumeTo(int, int)}.
* <p>
- * Command would be sent directly to the player if the session doesn't reject the request
- * through the {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
+ * Command would set the device volume or send to the volume provider directly if the session
+ * doesn't reject the request through the
+ * {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
+ */
+ public static final int COMMAND_CODE_PLAYBACK_SET_VOLUME = 10;
+
+ /**
+ * Command code for both {@link MediaController2#adjustVolume(int, int)}.
+ * <p>
+ * Command would adjust the device volume or send to the volume provider directly if the session
+ * doesn't reject the request through the
+ * {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
*/
- public static final int COMMAND_CODE_PLAYBACK_SKIP_TO_PLAYLIST_ITEM = 10;
+ public static final int COMMAND_CODE_PLAYBACK_ADJUST_VOLUME = 11;
/**
* 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(MediaSession2, ControllerInfo, Command)}.
+ * @hide
*/
- public static final int COMMAND_CODE_PLAYBACK_SET_PLAYLIST_PARAMS = 11;
+ // TODO(jaewan): Remove (b/74116823)
+ public static final int COMMAND_CODE_PLAYBACK_SET_PLAYLIST_PARAMS = 12;
+
+ /**
+ * Command code for {@link MediaController2#skipToPlaylistItem(MediaItem2)}.
+ * <p>
+ * Command would be sent directly to the playlist controller if the session doesn't reject the
+ * request through the
+ * {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
+ */
+ public static final int COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM = 12;
+
+ /**
+ * Command code for {@link MediaController2#setShuffleMode(int)}.
+ * <p>
+ * Command would be sent directly to the playlist controller if the session doesn't reject the
+ * request through the
+ * {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
+ */
+ public static final int COMMAND_CODE_PLAYLIST_SET_SHUFFLE_MODE = 13;
+
+ /**
+ * Command code for {@link MediaController2#setRepeatMode(int)}.
+ * <p>
+ * Command would be sent directly to the playlist controller if the session doesn't reject the
+ * request through the
+ * {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
+ */
+ public static final int COMMAND_CODE_PLAYLIST_SET_REPEAT_MODE = 14;
/**
* Command code for {@link MediaController2#addPlaylistItem(int, MediaItem2)}.
* <p>
- * Command would be sent directly to the player if the session doesn't reject the request
- * through the {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
+ * Command would be sent directly to the playlist controller if the session doesn't reject the
+ * request through the
+ * {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
*/
- public static final int COMMAND_CODE_PLAYLIST_ADD = 12;
+ public static final int COMMAND_CODE_PLAYLIST_ADD_ITEM = 15;
/**
* Command code for {@link MediaController2#addPlaylistItem(int, MediaItem2)}.
* <p>
- * Command would be sent directly to the player if the session doesn't reject the request
- * through the {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
+ * Command would be sent directly to the playlist controller if the session doesn't reject the
+ * request through the
+ * {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
*/
- public static final int COMMAND_CODE_PLAYLIST_REMOVE = 13;
+ public static final int COMMAND_CODE_PLAYLIST_REMOVE_ITEM = 16;
/**
- * Command code for {@link MediaController2#getPlaylist()}.
+ * Command code for {@link MediaController2#replacePlaylistItem(int, MediaItem2)}.
* <p>
- * Command would be sent directly to the player if the session doesn't reject the request
- * through the {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
+ * Command would be sent directly to the playlist controller if the session doesn't reject the
+ * request through the
+ * {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
*/
- public static final int COMMAND_CODE_PLAYLIST_GET = 14;
+ public static final int COMMAND_CODE_PLAYLIST_REPLACE_ITEM = 17;
/**
- * Command code for both {@link MediaController2#setVolumeTo(int, int)} and
- * {@link MediaController2#adjustVolume(int, int)}.
+ * Command code for {@link MediaController2#getPlaylist()}. This will expose metadata
+ * information to the controller.
* <p>
- * Command would adjust the volume or sent to the volume provider directly if the session
- * doesn't reject the request through the
+ * Command would be sent directly to the playlist controller if the session doesn't reject the
+ * request through the
+ * {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
+ */
+ public static final int COMMAND_CODE_PLAYLIST_GET_LIST = 18;
+
+ /**
+ * Command code for {@link MediaController2#setPlaylist(List, MediaMetadata2).
+ * <p>
+ * Command would be sent directly to the playlist controller if the session doesn't reject the
+ * request through the
+ * {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
+ */
+ public static final int COMMAND_CODE_PLAYLIST_SET_LIST = 19;
+
+ /**
+ * Command code for {@link MediaController2#getPlaylistMetadata()} ()}. This will expose
+ * metadata information to the controller.
+ * *
+ * Command code for {@link MediaController2#setPlaylist(List, MediaMetadata2)} and
+ * {@link MediaController2#updatePlaylistMetadata(MediaMetadata2)}.
+ * <p>
+ * Command would be sent directly to the playlist controller if the session doesn't reject the
+ * request through the
+ * {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
+ */
+ public static final int COMMAND_CODE_PLAYLIST_GET_LIST_METADATA = 20;
+
+ /**
+ * Command code for {@link MediaController2#updatePlaylistMetadata(MediaMetadata2)}.
+ * <p>
+ * Command would be sent directly to the playlist controller if the session doesn't reject the
+ * request through the
* {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
*/
- public static final int COMMAND_CODE_SET_VOLUME = 15;
+ public static final int COMMAND_CODE_PLAYLIST_SET_LIST_METADATA = 21;
/**
* Command code for {@link MediaController2#playFromMediaId(String, Bundle)}.
*/
- public static final int COMMAND_CODE_PLAY_FROM_MEDIA_ID = 16;
+ public static final int COMMAND_CODE_PLAY_FROM_MEDIA_ID = 22;
/**
* Command code for {@link MediaController2#playFromUri(Uri, Bundle)}.
*/
- public static final int COMMAND_CODE_PLAY_FROM_URI = 17;
+ public static final int COMMAND_CODE_PLAY_FROM_URI = 23;
/**
* Command code for {@link MediaController2#playFromSearch(String, Bundle)}.
*/
- public static final int COMMAND_CODE_PLAY_FROM_SEARCH = 18;
+ public static final int COMMAND_CODE_PLAY_FROM_SEARCH = 24;
/**
* Command code for {@link MediaController2#prepareFromMediaId(String, Bundle)}.
*/
- public static final int COMMAND_CODE_PREPARE_FROM_MEDIA_ID = 19;
+ public static final int COMMAND_CODE_PREPARE_FROM_MEDIA_ID = 25;
/**
* Command code for {@link MediaController2#prepareFromUri(Uri, Bundle)}.
*/
- public static final int COMMAND_CODE_PREPARE_FROM_URI = 20;
+ public static final int COMMAND_CODE_PREPARE_FROM_URI = 26;
/**
* Command code for {@link MediaController2#prepareFromSearch(String, Bundle)}.
*/
- public static final int COMMAND_CODE_PREPARE_FROM_SEARCH = 21;
+ public static final int COMMAND_CODE_PREPARE_FROM_SEARCH = 27;
/**
* Command code for {@link MediaBrowser2} specific functions that allows navigation and search
- * from the {@link MediaLibraryService2}. This would be ignored if a {@link MediaSession2},
- * not {@link android.media.MediaLibraryService2.MediaLibrarySession}, specify this.
+ * from the {@link MediaLibraryService2}. This would be ignored for a {@link MediaSession2},
+ * not {@link android.media.MediaLibraryService2.MediaLibrarySession}.
*
* @see MediaBrowser2
*/
- public static final int COMMAND_CODE_BROWSER = 22;
+ public static final int COMMAND_CODE_BROWSER = 28;
+
+ /**
+ * @hide
+ */
+ public static final int COMMAND_CODE_MAX = 28;
/**
* @hide
@@ -516,12 +596,12 @@ 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_SKIP_TO_PLAYLIST_ITEM
+ * @see #COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM
* @see #COMMAND_CODE_PLAYBACK_SET_PLAYLIST_PARAMS
- * @see #COMMAND_CODE_PLAYLIST_ADD
- * @see #COMMAND_CODE_PLAYLIST_REMOVE
- * @see #COMMAND_CODE_PLAYLIST_GET
- * @see #COMMAND_CODE_SET_VOLUME
+ * @see #COMMAND_CODE_PLAYLIST_ADD_ITEM
+ * @see #COMMAND_CODE_PLAYLIST_REMOVE_ITEM
+ * @see #COMMAND_CODE_PLAYLIST_GET_LIST
+ * @see #COMMAND_CODE_PLAYBACK_SET_VOLUME
*/
public boolean onCommandRequest(@NonNull MediaSession2 session,
@NonNull ControllerInfo controller, @NonNull Command command) {
@@ -674,6 +754,36 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController {
*/
public void onPrepareFromUri(@NonNull MediaSession2 session,
@NonNull ControllerInfo controller, @NonNull Uri uri, @Nullable Bundle extras) { }
+
+ /**
+ * Called when the player is <i>prepared</i>, i.e. it is ready to play the content
+ * referenced by the given data source.
+ * @param session the session for this event
+ * @param mpb the player for this event
+ * @param item the media item for which buffering is happening
+ */
+ public void onMediaPrepared(@NonNull MediaSession2 session, @NonNull MediaPlayerBase mpb,
+ @NonNull MediaItem2 item) { }
+
+ /**
+ * Called to indicate that the state of the player has changed.
+ * See {@link MediaPlayerBase#getPlayerState()} for polling the player state.
+ * @param session the session for this event
+ * @param mpb the player for this event
+ * @param state the new state of the player.
+ */
+ public void onPlayerStateChanged(@NonNull MediaSession2 session,
+ @NonNull MediaPlayerBase mpb, @PlayerState int state) { }
+
+ /**
+ * Called to report buffering events for a data source.
+ * @param session the session for this event
+ * @param mpb the player for this event
+ * @param item the media item for which buffering is happening.
+ * @param state the new buffering state.
+ */
+ public void onBufferingStateChanged(@NonNull MediaSession2 session,
+ @NonNull MediaPlayerBase mpb, @NonNull MediaItem2 item, @BuffState int state) { }
};
/**
@@ -1012,7 +1122,9 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController {
/**
* Parameter for the playlist.
+ * @hide
*/
+ // TODO(jaewan): Remove (b/74116823)
public final static class PlaylistParams {
/**
* @hide
@@ -1307,16 +1419,10 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController {
mProvider.stop_impl();
}
- /**
- * Rewind playback
- */
public void skipToPrevious() {
mProvider.skipToPrevious_impl();
}
- /**
- * Rewind playback
- */
public void skipToNext() {
mProvider.skipToNext_impl();
}
@@ -1356,17 +1462,6 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController {
}
/**
- * Skip to the item in the play list.
- *
- * @param item item in the play list you want to play
- * @throws IllegalArgumentException if the play list is null
- * @throws NullPointerException if index is outside play list range
- */
- public void skipToPlaylistItem(MediaItem2 item) {
- mProvider.skipToPlaylistItem_impl(item);
- }
-
- /**
* @hide
*/
public void skipForward() {
@@ -1381,80 +1476,14 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController {
}
/**
- * Set a list of {@link MediaItem2} as the current play list.
- *
- * @param playlist A list of {@link MediaItem2} objects to set as a play list.
- * @throws IllegalArgumentException if given {@param playlist} is null.
- */
- public void setPlaylist(@NonNull List<MediaItem2> playlist) {
- mProvider.setPlaylist_impl(playlist);
- }
-
- /**
- * Remove the media item in the play list.
- * <p>
- * 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
- */
- public void removePlaylistItem(MediaItem2 item) {
- mProvider.removePlaylistItem_impl(item);
- }
-
- /**
- * Add the media item to the play list at position index.
- * <p>
- * This will not change the currently playing media item.
- * If index is less than or equal to the current index of the play list,
- * the current index of the play list will be incremented correspondingly.
- *
- * @param index the index you want to add
- * @param item the media item you want to add
- * @throws IndexOutOfBoundsException if index is outside play list range
- */
- @Override
- public void addPlaylistItem(int index, @NonNull MediaItem2 item) {
- mProvider.addPlaylistItem_impl(index, item);
- }
-
- /**
- * Replace the media item at index in the playlist.
- * @param index the index of the item to replace
- * @param item the new item
- */
- @Override
- public void replacePlaylistItem(int index, @NonNull MediaItem2 item) {
- mProvider.replacePlaylistItem_impl(index, item);
- }
-
- /**
- * Return the playlist which is lastly set.
- *
- * @return playlist
- */
- @Override
- public List<MediaItem2> getPlaylist() {
- return mProvider.getPlaylist_impl();
- }
-
- /**
- * Return currently playing media item.
- *
- * @return currently playing media item
- */
- @Override
- public MediaItem2 getCurrentPlaylistItem() {
- return mProvider.getCurrentPlaylistItem_impl();
- }
-
- /**
* Sets the {@link PlaylistParams} for the current play list. Repeat/shuffle mode and metadata
* for the list can be set by calling this method.
*
* @param params A {@link PlaylistParams} object to set.
* @throws IllegalArgumentException if given {@param param} is null.
+ * @hide
*/
+ // TODO(jaewan): Remove (b/74116823)
public void setPlaylistParams(PlaylistParams params) {
mProvider.setPlaylistParams_impl(params);
}
@@ -1462,7 +1491,9 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController {
/**
* Returns the {@link PlaylistParams} for the current play list.
* Returns {@code null} if not set.
+ * @hide
*/
+ // TODO(jaewan): Remove (b/74116823)
public PlaylistParams getPlaylistParams() {
return mProvider.getPlaylistParams_impl();
}
@@ -1532,4 +1563,152 @@ public class MediaSession2 implements AutoCloseable, MediaPlaylistController {
public void setPlaybackSpeed(float speed) {
// TODO(jaewan): implement this (b/74093080)
}
+
+ /**
+ * Register {@link MediaPlaylistController.PlaylistEventCallback} to listen changes in the
+ * underlying {@link MediaPlaylistController}, regardless of the change in the controller.
+ * <p>
+ * Registered callbacks will be also called when the controller is changed.
+ *
+ * @param executor a callback Executor
+ * @param callback a PlaylistEventCallback
+ * @throws IllegalArgumentException if executor or callback is {@code null}.
+ */
+ @Override
+ public void registerPlaylistControllerCallback(@NonNull @CallbackExecutor Executor executor,
+ @NonNull PlaylistEventCallback callback) {
+ // TODO(jaewan): Implement (b/74169681)
+ //mProvider.registerPlaylistControllerCallback_impl(executor, callback);
+ }
+
+ /**
+ * Unregister the previously registered {@link MediaPlaylistController.PlaylistEventCallback}.
+ *
+ * @param callback the callback to be removed
+ * @throws IllegalArgumentException if the callback is {@code null}.
+ */
+ @Override
+ public void unregisterPlaylistControllerCallback(@NonNull PlaylistEventCallback callback) {
+ // TODO(jaewan): Implement (b/74169681)
+ //mProvider.unregisterPlaylistControllerCallback_impl(callback);
+ }
+
+ /**
+ * Return the playlist which is lastly set.
+ *
+ * @return playlist
+ */
+ @Override
+ public List<MediaItem2> getPlaylist() {
+ return mProvider.getPlaylist_impl();
+ }
+
+ /**
+ * Set a list of {@link MediaItem2} as the current play list.
+ *
+ * @param playlist A list of {@link MediaItem2} objects to set as a play list.
+ * @throws IllegalArgumentException if given {@param playlist} is null.
+ * @hide
+ */
+ // TODO(jaewan): Remove
+ public void setPlaylist(@NonNull List<MediaItem2> playlist) {
+ mProvider.setPlaylist_impl(playlist);
+ }
+
+ @Override
+ public void setPlaylist(@NonNull List<MediaItem2> list, @Nullable MediaMetadata2 metadata) {
+ // TODO(jaewan): Implement (b/74174649)
+ }
+
+ /**
+ * Skip to the item in the play list.
+ *
+ * @param item item in the play list you want to play
+ * @throws IllegalArgumentException if the play list is null
+ * @throws NullPointerException if index is outside play list range
+ */
+ public void skipToPlaylistItem(MediaItem2 item) {
+ mProvider.skipToPlaylistItem_impl(item);
+ }
+
+ @Override
+ public MediaMetadata2 getPlaylistMetadata() {
+ // TODO(jaewan): Implement (b/74174649)
+ return null;
+ }
+
+ /**
+ * Add the media item to the play list at position index.
+ * <p>
+ * This will not change the currently playing media item.
+ * If index is less than or equal to the current index of the play list,
+ * the current index of the play list will be incremented correspondingly.
+ *
+ * @param index the index you want to add
+ * @param item the media item you want to add
+ * @throws IndexOutOfBoundsException if index is outside play list range
+ */
+ @Override
+ public void addPlaylistItem(int index, @NonNull MediaItem2 item) {
+ mProvider.addPlaylistItem_impl(index, item);
+ }
+
+ /**
+ * Remove the media item in the play list.
+ * <p>
+ * 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
+ */
+ public void removePlaylistItem(MediaItem2 item) {
+ mProvider.removePlaylistItem_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
+ */
+ @Override
+ public void replacePlaylistItem(int index, @NonNull MediaItem2 item) {
+ mProvider.replacePlaylistItem_impl(index, item);
+ }
+
+ /**
+ * Return currently playing media item.
+ *
+ * @return currently playing media item
+ */
+ @Override
+ public MediaItem2 getCurrentPlaylistItem() {
+ return mProvider.getCurrentPlaylistItem_impl();
+ }
+
+ @Override
+ public void updatePlaylistMetadata(@Nullable MediaMetadata2 metadata) {
+ // TODO(jaewan): Implement (b/74174649)
+ }
+
+ @Override
+ public int getRepeatMode() {
+ // TODO(jaewan): Implement (b/74118768)
+ return 0;
+ }
+
+ @Override
+ public void setRepeatMode(int repeatMode) {
+ // TODO(jaewan): Implement (b/74118768)
+ }
+
+ @Override
+ public int getShuffleMode() {
+ // TODO(jaewan): Implement (b/74118768)
+ return 0;
+ }
+
+ @Override
+ public void setShuffleMode(int shuffleMode) {
+ // TODO(jaewan): Implement (b/74118768)
+ }
}