diff options
author | tonihei <tonihei@google.com> | 2023-11-01 15:03:04 +0000 |
---|---|---|
committer | tonihei <tonihei@google.com> | 2023-11-03 10:06:24 +0000 |
commit | 4cd753fb384e52187bf20742da73a059204902b4 (patch) | |
tree | e96cb1d67a74bbb709cc8d28379bee8e858e3bf8 | |
parent | d98cbbe24b869af7299a81db21d1b30757382e4d (diff) | |
download | support-4cd753fb384e52187bf20742da73a059204902b4.tar.gz |
Deprecate androidx.media2
Bug: 289814421
Test: Check api/current.txt and ensure all classes are deprecated
Relnote: "Deprecate androidx.media2. Use androidx.media3 instead."
Change-Id: I5316437d008c0a3030927cd8956b71cd2582ab20
53 files changed, 3266 insertions, 2700 deletions
diff --git a/media2/media2-common/api/current.txt b/media2/media2-common/api/current.txt index 7992d7b1cad..3ba4f06913c 100644 --- a/media2/media2-common/api/current.txt +++ b/media2/media2-common/api/current.txt @@ -1,221 +1,221 @@ // Signature format: 4.0 package androidx.media2.common { - public class CallbackMediaItem extends androidx.media2.common.MediaItem implements androidx.versionedparcelable.VersionedParcelable { - method public androidx.media2.common.DataSourceCallback getDataSourceCallback(); + @Deprecated public class CallbackMediaItem extends androidx.media2.common.MediaItem implements androidx.versionedparcelable.VersionedParcelable { + method @Deprecated public androidx.media2.common.DataSourceCallback getDataSourceCallback(); } - public static final class CallbackMediaItem.Builder extends androidx.media2.common.MediaItem.Builder { - ctor public CallbackMediaItem.Builder(androidx.media2.common.DataSourceCallback); - method public androidx.media2.common.CallbackMediaItem build(); - method public androidx.media2.common.CallbackMediaItem.Builder setEndPosition(long); - method public androidx.media2.common.CallbackMediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); - method public androidx.media2.common.CallbackMediaItem.Builder setStartPosition(long); + @Deprecated public static final class CallbackMediaItem.Builder extends androidx.media2.common.MediaItem.Builder { + ctor @Deprecated public CallbackMediaItem.Builder(androidx.media2.common.DataSourceCallback); + method @Deprecated public androidx.media2.common.CallbackMediaItem build(); + method @Deprecated public androidx.media2.common.CallbackMediaItem.Builder setEndPosition(long); + method @Deprecated public androidx.media2.common.CallbackMediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); + method @Deprecated public androidx.media2.common.CallbackMediaItem.Builder setStartPosition(long); } - public abstract class DataSourceCallback implements java.io.Closeable { - ctor public DataSourceCallback(); - method public abstract long getSize() throws java.io.IOException; - method public abstract int readAt(long, byte[], int, int) throws java.io.IOException; + @Deprecated public abstract class DataSourceCallback implements java.io.Closeable { + ctor @Deprecated public DataSourceCallback(); + method @Deprecated public abstract long getSize() throws java.io.IOException; + method @Deprecated public abstract int readAt(long, byte[], int, int) throws java.io.IOException; } - public class FileMediaItem extends androidx.media2.common.MediaItem implements androidx.versionedparcelable.VersionedParcelable { - method public long getFileDescriptorLength(); - method public long getFileDescriptorOffset(); - method public android.os.ParcelFileDescriptor getParcelFileDescriptor(); - field public static final long FD_LENGTH_UNKNOWN = 576460752303423487L; // 0x7ffffffffffffffL + @Deprecated public class FileMediaItem extends androidx.media2.common.MediaItem implements androidx.versionedparcelable.VersionedParcelable { + method @Deprecated public long getFileDescriptorLength(); + method @Deprecated public long getFileDescriptorOffset(); + method @Deprecated public android.os.ParcelFileDescriptor getParcelFileDescriptor(); + field @Deprecated public static final long FD_LENGTH_UNKNOWN = 576460752303423487L; // 0x7ffffffffffffffL } - public static final class FileMediaItem.Builder extends androidx.media2.common.MediaItem.Builder { - ctor public FileMediaItem.Builder(android.os.ParcelFileDescriptor); - method public androidx.media2.common.FileMediaItem build(); - method public androidx.media2.common.FileMediaItem.Builder setEndPosition(long); - method public androidx.media2.common.FileMediaItem.Builder setFileDescriptorLength(long); - method public androidx.media2.common.FileMediaItem.Builder setFileDescriptorOffset(long); - method public androidx.media2.common.FileMediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); - method public androidx.media2.common.FileMediaItem.Builder setStartPosition(long); + @Deprecated public static final class FileMediaItem.Builder extends androidx.media2.common.MediaItem.Builder { + ctor @Deprecated public FileMediaItem.Builder(android.os.ParcelFileDescriptor); + method @Deprecated public androidx.media2.common.FileMediaItem build(); + method @Deprecated public androidx.media2.common.FileMediaItem.Builder setEndPosition(long); + method @Deprecated public androidx.media2.common.FileMediaItem.Builder setFileDescriptorLength(long); + method @Deprecated public androidx.media2.common.FileMediaItem.Builder setFileDescriptorOffset(long); + method @Deprecated public androidx.media2.common.FileMediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); + method @Deprecated public androidx.media2.common.FileMediaItem.Builder setStartPosition(long); } - public class MediaItem implements androidx.versionedparcelable.VersionedParcelable { - method public long getEndPosition(); - method public androidx.media2.common.MediaMetadata? getMetadata(); - method public long getStartPosition(); - method public void setMetadata(androidx.media2.common.MediaMetadata?); - field public static final long POSITION_UNKNOWN = 576460752303423487L; // 0x7ffffffffffffffL + @Deprecated public class MediaItem implements androidx.versionedparcelable.VersionedParcelable { + method @Deprecated public long getEndPosition(); + method @Deprecated public androidx.media2.common.MediaMetadata? getMetadata(); + method @Deprecated public long getStartPosition(); + method @Deprecated public void setMetadata(androidx.media2.common.MediaMetadata?); + field @Deprecated public static final long POSITION_UNKNOWN = 576460752303423487L; // 0x7ffffffffffffffL } - public static class MediaItem.Builder { - ctor public MediaItem.Builder(); - method public androidx.media2.common.MediaItem build(); - method public androidx.media2.common.MediaItem.Builder setEndPosition(long); - method public androidx.media2.common.MediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); - method public androidx.media2.common.MediaItem.Builder setStartPosition(long); + @Deprecated public static class MediaItem.Builder { + ctor @Deprecated public MediaItem.Builder(); + method @Deprecated public androidx.media2.common.MediaItem build(); + method @Deprecated public androidx.media2.common.MediaItem.Builder setEndPosition(long); + method @Deprecated public androidx.media2.common.MediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); + method @Deprecated public androidx.media2.common.MediaItem.Builder setStartPosition(long); } - public final class MediaMetadata implements androidx.versionedparcelable.VersionedParcelable { - method public boolean containsKey(String); - method public android.graphics.Bitmap? getBitmap(String); - method public android.os.Bundle? getExtras(); - method public float getFloat(String); - method public long getLong(String); - method public String? getMediaId(); - method public androidx.media2.common.Rating? getRating(String); - method public String? getString(String); - method public CharSequence? getText(String); - method public java.util.Set<java.lang.String!> keySet(); - method public int size(); - field public static final long BROWSABLE_TYPE_ALBUMS = 2L; // 0x2L - field public static final long BROWSABLE_TYPE_ARTISTS = 3L; // 0x3L - field public static final long BROWSABLE_TYPE_GENRES = 4L; // 0x4L - field public static final long BROWSABLE_TYPE_MIXED = 0L; // 0x0L - field public static final long BROWSABLE_TYPE_NONE = -1L; // 0xffffffffffffffffL - field public static final long BROWSABLE_TYPE_PLAYLISTS = 5L; // 0x5L - field public static final long BROWSABLE_TYPE_TITLES = 1L; // 0x1L - field public static final long BROWSABLE_TYPE_YEARS = 6L; // 0x6L - field public static final String METADATA_KEY_ADVERTISEMENT = "androidx.media2.metadata.ADVERTISEMENT"; - field public static final String METADATA_KEY_ALBUM = "android.media.metadata.ALBUM"; - field public static final String METADATA_KEY_ALBUM_ART = "android.media.metadata.ALBUM_ART"; - field public static final String METADATA_KEY_ALBUM_ARTIST = "android.media.metadata.ALBUM_ARTIST"; - field public static final String METADATA_KEY_ALBUM_ART_URI = "android.media.metadata.ALBUM_ART_URI"; - field public static final String METADATA_KEY_ART = "android.media.metadata.ART"; - field public static final String METADATA_KEY_ARTIST = "android.media.metadata.ARTIST"; - field public static final String METADATA_KEY_ART_URI = "android.media.metadata.ART_URI"; - field public static final String METADATA_KEY_AUTHOR = "android.media.metadata.AUTHOR"; - field public static final String METADATA_KEY_BROWSABLE = "androidx.media2.metadata.BROWSABLE"; - field public static final String METADATA_KEY_COMPILATION = "android.media.metadata.COMPILATION"; - field public static final String METADATA_KEY_COMPOSER = "android.media.metadata.COMPOSER"; - field public static final String METADATA_KEY_DATE = "android.media.metadata.DATE"; - field public static final String METADATA_KEY_DISC_NUMBER = "android.media.metadata.DISC_NUMBER"; - field public static final String METADATA_KEY_DISPLAY_DESCRIPTION = "android.media.metadata.DISPLAY_DESCRIPTION"; - field public static final String METADATA_KEY_DISPLAY_ICON = "android.media.metadata.DISPLAY_ICON"; - field public static final String METADATA_KEY_DISPLAY_ICON_URI = "android.media.metadata.DISPLAY_ICON_URI"; - field public static final String METADATA_KEY_DISPLAY_SUBTITLE = "android.media.metadata.DISPLAY_SUBTITLE"; - field public static final String METADATA_KEY_DISPLAY_TITLE = "android.media.metadata.DISPLAY_TITLE"; - field public static final String METADATA_KEY_DOWNLOAD_STATUS = "androidx.media2.metadata.DOWNLOAD_STATUS"; - field public static final String METADATA_KEY_DURATION = "android.media.metadata.DURATION"; - field public static final String METADATA_KEY_EXTRAS = "androidx.media2.metadata.EXTRAS"; - field public static final String METADATA_KEY_GENRE = "android.media.metadata.GENRE"; - field public static final String METADATA_KEY_MEDIA_ID = "android.media.metadata.MEDIA_ID"; - field public static final String METADATA_KEY_MEDIA_URI = "android.media.metadata.MEDIA_URI"; - field public static final String METADATA_KEY_NUM_TRACKS = "android.media.metadata.NUM_TRACKS"; - field public static final String METADATA_KEY_PLAYABLE = "androidx.media2.metadata.PLAYABLE"; - field public static final String METADATA_KEY_RATING = "android.media.metadata.RATING"; - field public static final String METADATA_KEY_TITLE = "android.media.metadata.TITLE"; - field public static final String METADATA_KEY_TRACK_NUMBER = "android.media.metadata.TRACK_NUMBER"; - field public static final String METADATA_KEY_USER_RATING = "android.media.metadata.USER_RATING"; - field public static final String METADATA_KEY_WRITER = "android.media.metadata.WRITER"; - field public static final String METADATA_KEY_YEAR = "android.media.metadata.YEAR"; - field public static final long STATUS_DOWNLOADED = 2L; // 0x2L - field public static final long STATUS_DOWNLOADING = 1L; // 0x1L - field public static final long STATUS_NOT_DOWNLOADED = 0L; // 0x0L + @Deprecated public final class MediaMetadata implements androidx.versionedparcelable.VersionedParcelable { + method @Deprecated public boolean containsKey(String); + method @Deprecated public android.graphics.Bitmap? getBitmap(String); + method @Deprecated public android.os.Bundle? getExtras(); + method @Deprecated public float getFloat(String); + method @Deprecated public long getLong(String); + method @Deprecated public String? getMediaId(); + method @Deprecated public androidx.media2.common.Rating? getRating(String); + method @Deprecated public String? getString(String); + method @Deprecated public CharSequence? getText(String); + method @Deprecated public java.util.Set<java.lang.String!> keySet(); + method @Deprecated public int size(); + field @Deprecated public static final long BROWSABLE_TYPE_ALBUMS = 2L; // 0x2L + field @Deprecated public static final long BROWSABLE_TYPE_ARTISTS = 3L; // 0x3L + field @Deprecated public static final long BROWSABLE_TYPE_GENRES = 4L; // 0x4L + field @Deprecated public static final long BROWSABLE_TYPE_MIXED = 0L; // 0x0L + field @Deprecated public static final long BROWSABLE_TYPE_NONE = -1L; // 0xffffffffffffffffL + field @Deprecated public static final long BROWSABLE_TYPE_PLAYLISTS = 5L; // 0x5L + field @Deprecated public static final long BROWSABLE_TYPE_TITLES = 1L; // 0x1L + field @Deprecated public static final long BROWSABLE_TYPE_YEARS = 6L; // 0x6L + field @Deprecated public static final String METADATA_KEY_ADVERTISEMENT = "androidx.media2.metadata.ADVERTISEMENT"; + field @Deprecated public static final String METADATA_KEY_ALBUM = "android.media.metadata.ALBUM"; + field @Deprecated public static final String METADATA_KEY_ALBUM_ART = "android.media.metadata.ALBUM_ART"; + field @Deprecated public static final String METADATA_KEY_ALBUM_ARTIST = "android.media.metadata.ALBUM_ARTIST"; + field @Deprecated public static final String METADATA_KEY_ALBUM_ART_URI = "android.media.metadata.ALBUM_ART_URI"; + field @Deprecated public static final String METADATA_KEY_ART = "android.media.metadata.ART"; + field @Deprecated public static final String METADATA_KEY_ARTIST = "android.media.metadata.ARTIST"; + field @Deprecated public static final String METADATA_KEY_ART_URI = "android.media.metadata.ART_URI"; + field @Deprecated public static final String METADATA_KEY_AUTHOR = "android.media.metadata.AUTHOR"; + field @Deprecated public static final String METADATA_KEY_BROWSABLE = "androidx.media2.metadata.BROWSABLE"; + field @Deprecated public static final String METADATA_KEY_COMPILATION = "android.media.metadata.COMPILATION"; + field @Deprecated public static final String METADATA_KEY_COMPOSER = "android.media.metadata.COMPOSER"; + field @Deprecated public static final String METADATA_KEY_DATE = "android.media.metadata.DATE"; + field @Deprecated public static final String METADATA_KEY_DISC_NUMBER = "android.media.metadata.DISC_NUMBER"; + field @Deprecated public static final String METADATA_KEY_DISPLAY_DESCRIPTION = "android.media.metadata.DISPLAY_DESCRIPTION"; + field @Deprecated public static final String METADATA_KEY_DISPLAY_ICON = "android.media.metadata.DISPLAY_ICON"; + field @Deprecated public static final String METADATA_KEY_DISPLAY_ICON_URI = "android.media.metadata.DISPLAY_ICON_URI"; + field @Deprecated public static final String METADATA_KEY_DISPLAY_SUBTITLE = "android.media.metadata.DISPLAY_SUBTITLE"; + field @Deprecated public static final String METADATA_KEY_DISPLAY_TITLE = "android.media.metadata.DISPLAY_TITLE"; + field @Deprecated public static final String METADATA_KEY_DOWNLOAD_STATUS = "androidx.media2.metadata.DOWNLOAD_STATUS"; + field @Deprecated public static final String METADATA_KEY_DURATION = "android.media.metadata.DURATION"; + field @Deprecated public static final String METADATA_KEY_EXTRAS = "androidx.media2.metadata.EXTRAS"; + field @Deprecated public static final String METADATA_KEY_GENRE = "android.media.metadata.GENRE"; + field @Deprecated public static final String METADATA_KEY_MEDIA_ID = "android.media.metadata.MEDIA_ID"; + field @Deprecated public static final String METADATA_KEY_MEDIA_URI = "android.media.metadata.MEDIA_URI"; + field @Deprecated public static final String METADATA_KEY_NUM_TRACKS = "android.media.metadata.NUM_TRACKS"; + field @Deprecated public static final String METADATA_KEY_PLAYABLE = "androidx.media2.metadata.PLAYABLE"; + field @Deprecated public static final String METADATA_KEY_RATING = "android.media.metadata.RATING"; + field @Deprecated public static final String METADATA_KEY_TITLE = "android.media.metadata.TITLE"; + field @Deprecated public static final String METADATA_KEY_TRACK_NUMBER = "android.media.metadata.TRACK_NUMBER"; + field @Deprecated public static final String METADATA_KEY_USER_RATING = "android.media.metadata.USER_RATING"; + field @Deprecated public static final String METADATA_KEY_WRITER = "android.media.metadata.WRITER"; + field @Deprecated public static final String METADATA_KEY_YEAR = "android.media.metadata.YEAR"; + field @Deprecated public static final long STATUS_DOWNLOADED = 2L; // 0x2L + field @Deprecated public static final long STATUS_DOWNLOADING = 1L; // 0x1L + field @Deprecated public static final long STATUS_NOT_DOWNLOADED = 0L; // 0x0L } - public static final class MediaMetadata.Builder { - ctor public MediaMetadata.Builder(); - ctor public MediaMetadata.Builder(androidx.media2.common.MediaMetadata); - method public androidx.media2.common.MediaMetadata build(); - method public androidx.media2.common.MediaMetadata.Builder putBitmap(String, android.graphics.Bitmap?); - method public androidx.media2.common.MediaMetadata.Builder putFloat(String, float); - method public androidx.media2.common.MediaMetadata.Builder putLong(String, long); - method public androidx.media2.common.MediaMetadata.Builder putRating(String, androidx.media2.common.Rating?); - method public androidx.media2.common.MediaMetadata.Builder putString(String, String?); - method public androidx.media2.common.MediaMetadata.Builder putText(String, CharSequence?); - method public androidx.media2.common.MediaMetadata.Builder setExtras(android.os.Bundle?); + @Deprecated public static final class MediaMetadata.Builder { + ctor @Deprecated public MediaMetadata.Builder(); + ctor @Deprecated public MediaMetadata.Builder(androidx.media2.common.MediaMetadata); + method @Deprecated public androidx.media2.common.MediaMetadata build(); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder putBitmap(String, android.graphics.Bitmap?); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder putFloat(String, float); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder putLong(String, long); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder putRating(String, androidx.media2.common.Rating?); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder putString(String, String?); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder putText(String, CharSequence?); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder setExtras(android.os.Bundle?); } - public interface Rating extends androidx.versionedparcelable.VersionedParcelable { - method public boolean isRated(); + @Deprecated public interface Rating extends androidx.versionedparcelable.VersionedParcelable { + method @Deprecated public boolean isRated(); } - public abstract class SessionPlayer implements java.io.Closeable { - ctor public SessionPlayer(); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> addPlaylistItem(int, androidx.media2.common.MediaItem); - method @CallSuper public void close(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> deselectTrack(androidx.media2.common.SessionPlayer.TrackInfo); - method public abstract androidx.media.AudioAttributesCompat? getAudioAttributes(); - method public abstract long getBufferedPosition(); - method public abstract int getBufferingState(); - method protected final java.util.List<androidx.core.util.Pair<androidx.media2.common.SessionPlayer.PlayerCallback!,java.util.concurrent.Executor!>!> getCallbacks(); - method public abstract androidx.media2.common.MediaItem? getCurrentMediaItem(); - method @IntRange(from=androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) public abstract int getCurrentMediaItemIndex(); - method public abstract long getCurrentPosition(); - method public abstract long getDuration(); - method @IntRange(from=androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) public abstract int getNextMediaItemIndex(); - method public abstract float getPlaybackSpeed(); - method public abstract int getPlayerState(); - method public abstract java.util.List<androidx.media2.common.MediaItem!>? getPlaylist(); - method public abstract androidx.media2.common.MediaMetadata? getPlaylistMetadata(); - method @IntRange(from=androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) public abstract int getPreviousMediaItemIndex(); - method public abstract int getRepeatMode(); - method public androidx.media2.common.SessionPlayer.TrackInfo? getSelectedTrack(int); - method public abstract int getShuffleMode(); - method public java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!> getTracks(); - method public androidx.media2.common.VideoSize getVideoSize(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> movePlaylistItem(@IntRange(from=0) int, @IntRange(from=0) int); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> pause(); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> play(); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> prepare(); - method public final void registerPlayerCallback(java.util.concurrent.Executor, androidx.media2.common.SessionPlayer.PlayerCallback); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> removePlaylistItem(@IntRange(from=0) int); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> replacePlaylistItem(int, androidx.media2.common.MediaItem); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> seekTo(long); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> selectTrack(androidx.media2.common.SessionPlayer.TrackInfo); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAudioAttributes(androidx.media.AudioAttributesCompat); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setMediaItem(androidx.media2.common.MediaItem); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaybackSpeed(float); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaylist(java.util.List<androidx.media2.common.MediaItem!>, androidx.media2.common.MediaMetadata?); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setRepeatMode(int); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setShuffleMode(int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setSurface(android.view.Surface?); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToNextPlaylistItem(); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPlaylistItem(@IntRange(from=0) int); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPreviousPlaylistItem(); - method public final void unregisterPlayerCallback(androidx.media2.common.SessionPlayer.PlayerCallback); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> updatePlaylistMetadata(androidx.media2.common.MediaMetadata?); - field public static final int BUFFERING_STATE_BUFFERING_AND_PLAYABLE = 1; // 0x1 - field public static final int BUFFERING_STATE_BUFFERING_AND_STARVED = 2; // 0x2 - field public static final int BUFFERING_STATE_COMPLETE = 3; // 0x3 - field public static final int BUFFERING_STATE_UNKNOWN = 0; // 0x0 - field public static final int INVALID_ITEM_INDEX = -1; // 0xffffffff - field public static final int PLAYER_STATE_ERROR = 3; // 0x3 - field public static final int PLAYER_STATE_IDLE = 0; // 0x0 - field public static final int PLAYER_STATE_PAUSED = 1; // 0x1 - field public static final int PLAYER_STATE_PLAYING = 2; // 0x2 - 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 - field public static final long UNKNOWN_TIME = -9223372036854775808L; // 0x8000000000000000L + @Deprecated public abstract class SessionPlayer implements java.io.Closeable { + ctor @Deprecated public SessionPlayer(); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> addPlaylistItem(int, androidx.media2.common.MediaItem); + method @Deprecated @CallSuper public void close(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> deselectTrack(androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public abstract androidx.media.AudioAttributesCompat? getAudioAttributes(); + method @Deprecated public abstract long getBufferedPosition(); + method @Deprecated public abstract int getBufferingState(); + method @Deprecated protected final java.util.List<androidx.core.util.Pair<androidx.media2.common.SessionPlayer.PlayerCallback!,java.util.concurrent.Executor!>!> getCallbacks(); + method @Deprecated public abstract androidx.media2.common.MediaItem? getCurrentMediaItem(); + method @Deprecated @IntRange(from=androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) public abstract int getCurrentMediaItemIndex(); + method @Deprecated public abstract long getCurrentPosition(); + method @Deprecated public abstract long getDuration(); + method @Deprecated @IntRange(from=androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) public abstract int getNextMediaItemIndex(); + method @Deprecated public abstract float getPlaybackSpeed(); + method @Deprecated public abstract int getPlayerState(); + method @Deprecated public abstract java.util.List<androidx.media2.common.MediaItem!>? getPlaylist(); + method @Deprecated public abstract androidx.media2.common.MediaMetadata? getPlaylistMetadata(); + method @Deprecated @IntRange(from=androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) public abstract int getPreviousMediaItemIndex(); + method @Deprecated public abstract int getRepeatMode(); + method @Deprecated public androidx.media2.common.SessionPlayer.TrackInfo? getSelectedTrack(int); + method @Deprecated public abstract int getShuffleMode(); + method @Deprecated public java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!> getTracks(); + method @Deprecated public androidx.media2.common.VideoSize getVideoSize(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> movePlaylistItem(@IntRange(from=0) int, @IntRange(from=0) int); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> pause(); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> play(); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> prepare(); + method @Deprecated public final void registerPlayerCallback(java.util.concurrent.Executor, androidx.media2.common.SessionPlayer.PlayerCallback); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> removePlaylistItem(@IntRange(from=0) int); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> replacePlaylistItem(int, androidx.media2.common.MediaItem); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> seekTo(long); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> selectTrack(androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAudioAttributes(androidx.media.AudioAttributesCompat); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setMediaItem(androidx.media2.common.MediaItem); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaybackSpeed(float); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaylist(java.util.List<androidx.media2.common.MediaItem!>, androidx.media2.common.MediaMetadata?); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setRepeatMode(int); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setShuffleMode(int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setSurface(android.view.Surface?); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToNextPlaylistItem(); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPlaylistItem(@IntRange(from=0) int); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPreviousPlaylistItem(); + method @Deprecated public final void unregisterPlayerCallback(androidx.media2.common.SessionPlayer.PlayerCallback); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> updatePlaylistMetadata(androidx.media2.common.MediaMetadata?); + field @Deprecated public static final int BUFFERING_STATE_BUFFERING_AND_PLAYABLE = 1; // 0x1 + field @Deprecated public static final int BUFFERING_STATE_BUFFERING_AND_STARVED = 2; // 0x2 + field @Deprecated public static final int BUFFERING_STATE_COMPLETE = 3; // 0x3 + field @Deprecated public static final int BUFFERING_STATE_UNKNOWN = 0; // 0x0 + field @Deprecated public static final int INVALID_ITEM_INDEX = -1; // 0xffffffff + field @Deprecated public static final int PLAYER_STATE_ERROR = 3; // 0x3 + field @Deprecated public static final int PLAYER_STATE_IDLE = 0; // 0x0 + field @Deprecated public static final int PLAYER_STATE_PAUSED = 1; // 0x1 + field @Deprecated public static final int PLAYER_STATE_PLAYING = 2; // 0x2 + field @Deprecated public static final int REPEAT_MODE_ALL = 2; // 0x2 + field @Deprecated public static final int REPEAT_MODE_GROUP = 3; // 0x3 + field @Deprecated public static final int REPEAT_MODE_NONE = 0; // 0x0 + field @Deprecated public static final int REPEAT_MODE_ONE = 1; // 0x1 + field @Deprecated public static final int SHUFFLE_MODE_ALL = 1; // 0x1 + field @Deprecated public static final int SHUFFLE_MODE_GROUP = 2; // 0x2 + field @Deprecated public static final int SHUFFLE_MODE_NONE = 0; // 0x0 + field @Deprecated public static final long UNKNOWN_TIME = -9223372036854775808L; // 0x8000000000000000L } - public abstract static class SessionPlayer.PlayerCallback { - ctor public SessionPlayer.PlayerCallback(); - method public void onAudioAttributesChanged(androidx.media2.common.SessionPlayer, androidx.media.AudioAttributesCompat?); - method public void onBufferingStateChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaItem?, int); - method public void onCurrentMediaItemChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaItem?); - method public void onPlaybackCompleted(androidx.media2.common.SessionPlayer); - method public void onPlaybackSpeedChanged(androidx.media2.common.SessionPlayer, float); - method public void onPlayerStateChanged(androidx.media2.common.SessionPlayer, int); - method public void onPlaylistChanged(androidx.media2.common.SessionPlayer, java.util.List<androidx.media2.common.MediaItem!>?, androidx.media2.common.MediaMetadata?); - method public void onPlaylistMetadataChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaMetadata?); - method public void onRepeatModeChanged(androidx.media2.common.SessionPlayer, int); - method public void onSeekCompleted(androidx.media2.common.SessionPlayer, long); - method public void onShuffleModeChanged(androidx.media2.common.SessionPlayer, int); - method public void onSubtitleData(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaItem, androidx.media2.common.SessionPlayer.TrackInfo, androidx.media2.common.SubtitleData); - method public void onTrackDeselected(androidx.media2.common.SessionPlayer, androidx.media2.common.SessionPlayer.TrackInfo); - method public void onTrackSelected(androidx.media2.common.SessionPlayer, androidx.media2.common.SessionPlayer.TrackInfo); - method public void onTracksChanged(androidx.media2.common.SessionPlayer, java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!>); - method public void onVideoSizeChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.VideoSize); + @Deprecated public abstract static class SessionPlayer.PlayerCallback { + ctor @Deprecated public SessionPlayer.PlayerCallback(); + method @Deprecated public void onAudioAttributesChanged(androidx.media2.common.SessionPlayer, androidx.media.AudioAttributesCompat?); + method @Deprecated public void onBufferingStateChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaItem?, int); + method @Deprecated public void onCurrentMediaItemChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaItem?); + method @Deprecated public void onPlaybackCompleted(androidx.media2.common.SessionPlayer); + method @Deprecated public void onPlaybackSpeedChanged(androidx.media2.common.SessionPlayer, float); + method @Deprecated public void onPlayerStateChanged(androidx.media2.common.SessionPlayer, int); + method @Deprecated public void onPlaylistChanged(androidx.media2.common.SessionPlayer, java.util.List<androidx.media2.common.MediaItem!>?, androidx.media2.common.MediaMetadata?); + method @Deprecated public void onPlaylistMetadataChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaMetadata?); + method @Deprecated public void onRepeatModeChanged(androidx.media2.common.SessionPlayer, int); + method @Deprecated public void onSeekCompleted(androidx.media2.common.SessionPlayer, long); + method @Deprecated public void onShuffleModeChanged(androidx.media2.common.SessionPlayer, int); + method @Deprecated public void onSubtitleData(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaItem, androidx.media2.common.SessionPlayer.TrackInfo, androidx.media2.common.SubtitleData); + method @Deprecated public void onTrackDeselected(androidx.media2.common.SessionPlayer, androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public void onTrackSelected(androidx.media2.common.SessionPlayer, androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public void onTracksChanged(androidx.media2.common.SessionPlayer, java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!>); + method @Deprecated public void onVideoSizeChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.VideoSize); } - public static class SessionPlayer.PlayerResult { - ctor public SessionPlayer.PlayerResult(int, androidx.media2.common.MediaItem?); - method public long getCompletionTime(); - method public androidx.media2.common.MediaItem? getMediaItem(); - method public int getResultCode(); + @Deprecated public static class SessionPlayer.PlayerResult { + ctor @Deprecated public SessionPlayer.PlayerResult(int, androidx.media2.common.MediaItem?); + method @Deprecated public long getCompletionTime(); + method @Deprecated public androidx.media2.common.MediaItem? getMediaItem(); + method @Deprecated public int getResultCode(); field public static final int RESULT_ERROR_BAD_VALUE = -3; // 0xfffffffd field public static final int RESULT_ERROR_INVALID_STATE = -2; // 0xfffffffe field public static final int RESULT_ERROR_IO = -5; // 0xfffffffb @@ -226,47 +226,47 @@ package androidx.media2.common { field public static final int RESULT_SUCCESS = 0; // 0x0 } - public static class SessionPlayer.TrackInfo implements androidx.versionedparcelable.VersionedParcelable { - ctor public SessionPlayer.TrackInfo(int, int, android.media.MediaFormat?); - ctor public SessionPlayer.TrackInfo(int, int, android.media.MediaFormat?, boolean); - method public android.media.MediaFormat? getFormat(); - method public int getId(); - method public java.util.Locale getLanguage(); - method public int getTrackType(); - method public boolean isSelectable(); - field public static final int MEDIA_TRACK_TYPE_AUDIO = 2; // 0x2 - field public static final int MEDIA_TRACK_TYPE_METADATA = 5; // 0x5 - field public static final int MEDIA_TRACK_TYPE_SUBTITLE = 4; // 0x4 - field public static final int MEDIA_TRACK_TYPE_UNKNOWN = 0; // 0x0 - field public static final int MEDIA_TRACK_TYPE_VIDEO = 1; // 0x1 + @Deprecated public static class SessionPlayer.TrackInfo implements androidx.versionedparcelable.VersionedParcelable { + ctor @Deprecated public SessionPlayer.TrackInfo(int, int, android.media.MediaFormat?); + ctor @Deprecated public SessionPlayer.TrackInfo(int, int, android.media.MediaFormat?, boolean); + method @Deprecated public android.media.MediaFormat? getFormat(); + method @Deprecated public int getId(); + method @Deprecated public java.util.Locale getLanguage(); + method @Deprecated public int getTrackType(); + method @Deprecated public boolean isSelectable(); + field @Deprecated public static final int MEDIA_TRACK_TYPE_AUDIO = 2; // 0x2 + field @Deprecated public static final int MEDIA_TRACK_TYPE_METADATA = 5; // 0x5 + field @Deprecated public static final int MEDIA_TRACK_TYPE_SUBTITLE = 4; // 0x4 + field @Deprecated public static final int MEDIA_TRACK_TYPE_UNKNOWN = 0; // 0x0 + field @Deprecated public static final int MEDIA_TRACK_TYPE_VIDEO = 1; // 0x1 } - public final class SubtitleData implements androidx.versionedparcelable.VersionedParcelable { - ctor public SubtitleData(long, long, byte[]); - method public byte[] getData(); - method public long getDurationUs(); - method public long getStartTimeUs(); + @Deprecated public final class SubtitleData implements androidx.versionedparcelable.VersionedParcelable { + ctor @Deprecated public SubtitleData(long, long, byte[]); + method @Deprecated public byte[] getData(); + method @Deprecated public long getDurationUs(); + method @Deprecated public long getStartTimeUs(); } - public class UriMediaItem extends androidx.media2.common.MediaItem implements androidx.versionedparcelable.VersionedParcelable { - method public android.net.Uri getUri(); - method public java.util.List<java.net.HttpCookie!>? getUriCookies(); - method public java.util.Map<java.lang.String!,java.lang.String!>? getUriHeaders(); + @Deprecated public class UriMediaItem extends androidx.media2.common.MediaItem implements androidx.versionedparcelable.VersionedParcelable { + method @Deprecated public android.net.Uri getUri(); + method @Deprecated public java.util.List<java.net.HttpCookie!>? getUriCookies(); + method @Deprecated public java.util.Map<java.lang.String!,java.lang.String!>? getUriHeaders(); } - public static final class UriMediaItem.Builder extends androidx.media2.common.MediaItem.Builder { - ctor public UriMediaItem.Builder(android.net.Uri); - ctor public UriMediaItem.Builder(android.net.Uri, java.util.Map<java.lang.String!,java.lang.String!>?, java.util.List<java.net.HttpCookie!>?); - method public androidx.media2.common.UriMediaItem build(); - method public androidx.media2.common.UriMediaItem.Builder setEndPosition(long); - method public androidx.media2.common.UriMediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); - method public androidx.media2.common.UriMediaItem.Builder setStartPosition(long); + @Deprecated public static final class UriMediaItem.Builder extends androidx.media2.common.MediaItem.Builder { + ctor @Deprecated public UriMediaItem.Builder(android.net.Uri); + ctor @Deprecated public UriMediaItem.Builder(android.net.Uri, java.util.Map<java.lang.String!,java.lang.String!>?, java.util.List<java.net.HttpCookie!>?); + method @Deprecated public androidx.media2.common.UriMediaItem build(); + method @Deprecated public androidx.media2.common.UriMediaItem.Builder setEndPosition(long); + method @Deprecated public androidx.media2.common.UriMediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); + method @Deprecated public androidx.media2.common.UriMediaItem.Builder setStartPosition(long); } - public class VideoSize implements androidx.versionedparcelable.VersionedParcelable { - ctor public VideoSize(@IntRange(from=0) int, @IntRange(from=0) int); - method @IntRange(from=0) public int getHeight(); - method @IntRange(from=0) public int getWidth(); + @Deprecated public class VideoSize implements androidx.versionedparcelable.VersionedParcelable { + ctor @Deprecated public VideoSize(@IntRange(from=0) int, @IntRange(from=0) int); + method @Deprecated @IntRange(from=0) public int getHeight(); + method @Deprecated @IntRange(from=0) public int getWidth(); } } diff --git a/media2/media2-common/api/restricted_current.txt b/media2/media2-common/api/restricted_current.txt index 097aa96cd54..b3a7b213bb5 100644 --- a/media2/media2-common/api/restricted_current.txt +++ b/media2/media2-common/api/restricted_current.txt @@ -1,221 +1,221 @@ // Signature format: 4.0 package androidx.media2.common { - public class CallbackMediaItem extends androidx.media2.common.MediaItem { - method public androidx.media2.common.DataSourceCallback getDataSourceCallback(); + @Deprecated public class CallbackMediaItem extends androidx.media2.common.MediaItem { + method @Deprecated public androidx.media2.common.DataSourceCallback getDataSourceCallback(); } - public static final class CallbackMediaItem.Builder extends androidx.media2.common.MediaItem.Builder { - ctor public CallbackMediaItem.Builder(androidx.media2.common.DataSourceCallback); - method public androidx.media2.common.CallbackMediaItem build(); - method public androidx.media2.common.CallbackMediaItem.Builder setEndPosition(long); - method public androidx.media2.common.CallbackMediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); - method public androidx.media2.common.CallbackMediaItem.Builder setStartPosition(long); + @Deprecated public static final class CallbackMediaItem.Builder extends androidx.media2.common.MediaItem.Builder { + ctor @Deprecated public CallbackMediaItem.Builder(androidx.media2.common.DataSourceCallback); + method @Deprecated public androidx.media2.common.CallbackMediaItem build(); + method @Deprecated public androidx.media2.common.CallbackMediaItem.Builder setEndPosition(long); + method @Deprecated public androidx.media2.common.CallbackMediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); + method @Deprecated public androidx.media2.common.CallbackMediaItem.Builder setStartPosition(long); } - public abstract class DataSourceCallback implements java.io.Closeable { - ctor public DataSourceCallback(); - method public abstract long getSize() throws java.io.IOException; - method public abstract int readAt(long, byte[], int, int) throws java.io.IOException; + @Deprecated public abstract class DataSourceCallback implements java.io.Closeable { + ctor @Deprecated public DataSourceCallback(); + method @Deprecated public abstract long getSize() throws java.io.IOException; + method @Deprecated public abstract int readAt(long, byte[], int, int) throws java.io.IOException; } - public class FileMediaItem extends androidx.media2.common.MediaItem { - method public long getFileDescriptorLength(); - method public long getFileDescriptorOffset(); - method public android.os.ParcelFileDescriptor getParcelFileDescriptor(); - field public static final long FD_LENGTH_UNKNOWN = 576460752303423487L; // 0x7ffffffffffffffL + @Deprecated public class FileMediaItem extends androidx.media2.common.MediaItem { + method @Deprecated public long getFileDescriptorLength(); + method @Deprecated public long getFileDescriptorOffset(); + method @Deprecated public android.os.ParcelFileDescriptor getParcelFileDescriptor(); + field @Deprecated public static final long FD_LENGTH_UNKNOWN = 576460752303423487L; // 0x7ffffffffffffffL } - public static final class FileMediaItem.Builder extends androidx.media2.common.MediaItem.Builder { - ctor public FileMediaItem.Builder(android.os.ParcelFileDescriptor); - method public androidx.media2.common.FileMediaItem build(); - method public androidx.media2.common.FileMediaItem.Builder setEndPosition(long); - method public androidx.media2.common.FileMediaItem.Builder setFileDescriptorLength(long); - method public androidx.media2.common.FileMediaItem.Builder setFileDescriptorOffset(long); - method public androidx.media2.common.FileMediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); - method public androidx.media2.common.FileMediaItem.Builder setStartPosition(long); + @Deprecated public static final class FileMediaItem.Builder extends androidx.media2.common.MediaItem.Builder { + ctor @Deprecated public FileMediaItem.Builder(android.os.ParcelFileDescriptor); + method @Deprecated public androidx.media2.common.FileMediaItem build(); + method @Deprecated public androidx.media2.common.FileMediaItem.Builder setEndPosition(long); + method @Deprecated public androidx.media2.common.FileMediaItem.Builder setFileDescriptorLength(long); + method @Deprecated public androidx.media2.common.FileMediaItem.Builder setFileDescriptorOffset(long); + method @Deprecated public androidx.media2.common.FileMediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); + method @Deprecated public androidx.media2.common.FileMediaItem.Builder setStartPosition(long); } - @androidx.versionedparcelable.VersionedParcelize(isCustom=true) public class MediaItem extends androidx.versionedparcelable.CustomVersionedParcelable { - method public long getEndPosition(); - method public androidx.media2.common.MediaMetadata? getMetadata(); - method public long getStartPosition(); - method public void setMetadata(androidx.media2.common.MediaMetadata?); - field public static final long POSITION_UNKNOWN = 576460752303423487L; // 0x7ffffffffffffffL + @Deprecated @androidx.versionedparcelable.VersionedParcelize(isCustom=true) public class MediaItem extends androidx.versionedparcelable.CustomVersionedParcelable { + method @Deprecated public long getEndPosition(); + method @Deprecated public androidx.media2.common.MediaMetadata? getMetadata(); + method @Deprecated public long getStartPosition(); + method @Deprecated public void setMetadata(androidx.media2.common.MediaMetadata?); + field @Deprecated public static final long POSITION_UNKNOWN = 576460752303423487L; // 0x7ffffffffffffffL } - public static class MediaItem.Builder { - ctor public MediaItem.Builder(); - method public androidx.media2.common.MediaItem build(); - method public androidx.media2.common.MediaItem.Builder setEndPosition(long); - method public androidx.media2.common.MediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); - method public androidx.media2.common.MediaItem.Builder setStartPosition(long); + @Deprecated public static class MediaItem.Builder { + ctor @Deprecated public MediaItem.Builder(); + method @Deprecated public androidx.media2.common.MediaItem build(); + method @Deprecated public androidx.media2.common.MediaItem.Builder setEndPosition(long); + method @Deprecated public androidx.media2.common.MediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); + method @Deprecated public androidx.media2.common.MediaItem.Builder setStartPosition(long); } - @androidx.versionedparcelable.VersionedParcelize(isCustom=true) public final class MediaMetadata extends androidx.versionedparcelable.CustomVersionedParcelable { - method public boolean containsKey(String); - method public android.graphics.Bitmap? getBitmap(String); - method public android.os.Bundle? getExtras(); - method public float getFloat(String); - method public long getLong(String); - method public String? getMediaId(); - method public androidx.media2.common.Rating? getRating(String); - method public String? getString(String); - method public CharSequence? getText(String); - method public java.util.Set<java.lang.String!> keySet(); - method public int size(); - field public static final long BROWSABLE_TYPE_ALBUMS = 2L; // 0x2L - field public static final long BROWSABLE_TYPE_ARTISTS = 3L; // 0x3L - field public static final long BROWSABLE_TYPE_GENRES = 4L; // 0x4L - field public static final long BROWSABLE_TYPE_MIXED = 0L; // 0x0L - field public static final long BROWSABLE_TYPE_NONE = -1L; // 0xffffffffffffffffL - field public static final long BROWSABLE_TYPE_PLAYLISTS = 5L; // 0x5L - field public static final long BROWSABLE_TYPE_TITLES = 1L; // 0x1L - field public static final long BROWSABLE_TYPE_YEARS = 6L; // 0x6L - field public static final String METADATA_KEY_ADVERTISEMENT = "androidx.media2.metadata.ADVERTISEMENT"; - field public static final String METADATA_KEY_ALBUM = "android.media.metadata.ALBUM"; - field public static final String METADATA_KEY_ALBUM_ART = "android.media.metadata.ALBUM_ART"; - field public static final String METADATA_KEY_ALBUM_ARTIST = "android.media.metadata.ALBUM_ARTIST"; - field public static final String METADATA_KEY_ALBUM_ART_URI = "android.media.metadata.ALBUM_ART_URI"; - field public static final String METADATA_KEY_ART = "android.media.metadata.ART"; - field public static final String METADATA_KEY_ARTIST = "android.media.metadata.ARTIST"; - field public static final String METADATA_KEY_ART_URI = "android.media.metadata.ART_URI"; - field public static final String METADATA_KEY_AUTHOR = "android.media.metadata.AUTHOR"; - field public static final String METADATA_KEY_BROWSABLE = "androidx.media2.metadata.BROWSABLE"; - field public static final String METADATA_KEY_COMPILATION = "android.media.metadata.COMPILATION"; - field public static final String METADATA_KEY_COMPOSER = "android.media.metadata.COMPOSER"; - field public static final String METADATA_KEY_DATE = "android.media.metadata.DATE"; - field public static final String METADATA_KEY_DISC_NUMBER = "android.media.metadata.DISC_NUMBER"; - field public static final String METADATA_KEY_DISPLAY_DESCRIPTION = "android.media.metadata.DISPLAY_DESCRIPTION"; - field public static final String METADATA_KEY_DISPLAY_ICON = "android.media.metadata.DISPLAY_ICON"; - field public static final String METADATA_KEY_DISPLAY_ICON_URI = "android.media.metadata.DISPLAY_ICON_URI"; - field public static final String METADATA_KEY_DISPLAY_SUBTITLE = "android.media.metadata.DISPLAY_SUBTITLE"; - field public static final String METADATA_KEY_DISPLAY_TITLE = "android.media.metadata.DISPLAY_TITLE"; - field public static final String METADATA_KEY_DOWNLOAD_STATUS = "androidx.media2.metadata.DOWNLOAD_STATUS"; - field public static final String METADATA_KEY_DURATION = "android.media.metadata.DURATION"; - field public static final String METADATA_KEY_EXTRAS = "androidx.media2.metadata.EXTRAS"; - field public static final String METADATA_KEY_GENRE = "android.media.metadata.GENRE"; - field public static final String METADATA_KEY_MEDIA_ID = "android.media.metadata.MEDIA_ID"; - field public static final String METADATA_KEY_MEDIA_URI = "android.media.metadata.MEDIA_URI"; - field public static final String METADATA_KEY_NUM_TRACKS = "android.media.metadata.NUM_TRACKS"; - field public static final String METADATA_KEY_PLAYABLE = "androidx.media2.metadata.PLAYABLE"; - field public static final String METADATA_KEY_RATING = "android.media.metadata.RATING"; - field public static final String METADATA_KEY_TITLE = "android.media.metadata.TITLE"; - field public static final String METADATA_KEY_TRACK_NUMBER = "android.media.metadata.TRACK_NUMBER"; - field public static final String METADATA_KEY_USER_RATING = "android.media.metadata.USER_RATING"; - field public static final String METADATA_KEY_WRITER = "android.media.metadata.WRITER"; - field public static final String METADATA_KEY_YEAR = "android.media.metadata.YEAR"; - field public static final long STATUS_DOWNLOADED = 2L; // 0x2L - field public static final long STATUS_DOWNLOADING = 1L; // 0x1L - field public static final long STATUS_NOT_DOWNLOADED = 0L; // 0x0L + @Deprecated @androidx.versionedparcelable.VersionedParcelize(isCustom=true) public final class MediaMetadata extends androidx.versionedparcelable.CustomVersionedParcelable { + method @Deprecated public boolean containsKey(String); + method @Deprecated public android.graphics.Bitmap? getBitmap(String); + method @Deprecated public android.os.Bundle? getExtras(); + method @Deprecated public float getFloat(String); + method @Deprecated public long getLong(String); + method @Deprecated public String? getMediaId(); + method @Deprecated public androidx.media2.common.Rating? getRating(String); + method @Deprecated public String? getString(String); + method @Deprecated public CharSequence? getText(String); + method @Deprecated public java.util.Set<java.lang.String!> keySet(); + method @Deprecated public int size(); + field @Deprecated public static final long BROWSABLE_TYPE_ALBUMS = 2L; // 0x2L + field @Deprecated public static final long BROWSABLE_TYPE_ARTISTS = 3L; // 0x3L + field @Deprecated public static final long BROWSABLE_TYPE_GENRES = 4L; // 0x4L + field @Deprecated public static final long BROWSABLE_TYPE_MIXED = 0L; // 0x0L + field @Deprecated public static final long BROWSABLE_TYPE_NONE = -1L; // 0xffffffffffffffffL + field @Deprecated public static final long BROWSABLE_TYPE_PLAYLISTS = 5L; // 0x5L + field @Deprecated public static final long BROWSABLE_TYPE_TITLES = 1L; // 0x1L + field @Deprecated public static final long BROWSABLE_TYPE_YEARS = 6L; // 0x6L + field @Deprecated public static final String METADATA_KEY_ADVERTISEMENT = "androidx.media2.metadata.ADVERTISEMENT"; + field @Deprecated public static final String METADATA_KEY_ALBUM = "android.media.metadata.ALBUM"; + field @Deprecated public static final String METADATA_KEY_ALBUM_ART = "android.media.metadata.ALBUM_ART"; + field @Deprecated public static final String METADATA_KEY_ALBUM_ARTIST = "android.media.metadata.ALBUM_ARTIST"; + field @Deprecated public static final String METADATA_KEY_ALBUM_ART_URI = "android.media.metadata.ALBUM_ART_URI"; + field @Deprecated public static final String METADATA_KEY_ART = "android.media.metadata.ART"; + field @Deprecated public static final String METADATA_KEY_ARTIST = "android.media.metadata.ARTIST"; + field @Deprecated public static final String METADATA_KEY_ART_URI = "android.media.metadata.ART_URI"; + field @Deprecated public static final String METADATA_KEY_AUTHOR = "android.media.metadata.AUTHOR"; + field @Deprecated public static final String METADATA_KEY_BROWSABLE = "androidx.media2.metadata.BROWSABLE"; + field @Deprecated public static final String METADATA_KEY_COMPILATION = "android.media.metadata.COMPILATION"; + field @Deprecated public static final String METADATA_KEY_COMPOSER = "android.media.metadata.COMPOSER"; + field @Deprecated public static final String METADATA_KEY_DATE = "android.media.metadata.DATE"; + field @Deprecated public static final String METADATA_KEY_DISC_NUMBER = "android.media.metadata.DISC_NUMBER"; + field @Deprecated public static final String METADATA_KEY_DISPLAY_DESCRIPTION = "android.media.metadata.DISPLAY_DESCRIPTION"; + field @Deprecated public static final String METADATA_KEY_DISPLAY_ICON = "android.media.metadata.DISPLAY_ICON"; + field @Deprecated public static final String METADATA_KEY_DISPLAY_ICON_URI = "android.media.metadata.DISPLAY_ICON_URI"; + field @Deprecated public static final String METADATA_KEY_DISPLAY_SUBTITLE = "android.media.metadata.DISPLAY_SUBTITLE"; + field @Deprecated public static final String METADATA_KEY_DISPLAY_TITLE = "android.media.metadata.DISPLAY_TITLE"; + field @Deprecated public static final String METADATA_KEY_DOWNLOAD_STATUS = "androidx.media2.metadata.DOWNLOAD_STATUS"; + field @Deprecated public static final String METADATA_KEY_DURATION = "android.media.metadata.DURATION"; + field @Deprecated public static final String METADATA_KEY_EXTRAS = "androidx.media2.metadata.EXTRAS"; + field @Deprecated public static final String METADATA_KEY_GENRE = "android.media.metadata.GENRE"; + field @Deprecated public static final String METADATA_KEY_MEDIA_ID = "android.media.metadata.MEDIA_ID"; + field @Deprecated public static final String METADATA_KEY_MEDIA_URI = "android.media.metadata.MEDIA_URI"; + field @Deprecated public static final String METADATA_KEY_NUM_TRACKS = "android.media.metadata.NUM_TRACKS"; + field @Deprecated public static final String METADATA_KEY_PLAYABLE = "androidx.media2.metadata.PLAYABLE"; + field @Deprecated public static final String METADATA_KEY_RATING = "android.media.metadata.RATING"; + field @Deprecated public static final String METADATA_KEY_TITLE = "android.media.metadata.TITLE"; + field @Deprecated public static final String METADATA_KEY_TRACK_NUMBER = "android.media.metadata.TRACK_NUMBER"; + field @Deprecated public static final String METADATA_KEY_USER_RATING = "android.media.metadata.USER_RATING"; + field @Deprecated public static final String METADATA_KEY_WRITER = "android.media.metadata.WRITER"; + field @Deprecated public static final String METADATA_KEY_YEAR = "android.media.metadata.YEAR"; + field @Deprecated public static final long STATUS_DOWNLOADED = 2L; // 0x2L + field @Deprecated public static final long STATUS_DOWNLOADING = 1L; // 0x1L + field @Deprecated public static final long STATUS_NOT_DOWNLOADED = 0L; // 0x0L } - public static final class MediaMetadata.Builder { - ctor public MediaMetadata.Builder(); - ctor public MediaMetadata.Builder(androidx.media2.common.MediaMetadata); - method public androidx.media2.common.MediaMetadata build(); - method public androidx.media2.common.MediaMetadata.Builder putBitmap(String, android.graphics.Bitmap?); - method public androidx.media2.common.MediaMetadata.Builder putFloat(String, float); - method public androidx.media2.common.MediaMetadata.Builder putLong(String, long); - method public androidx.media2.common.MediaMetadata.Builder putRating(String, androidx.media2.common.Rating?); - method public androidx.media2.common.MediaMetadata.Builder putString(String, String?); - method public androidx.media2.common.MediaMetadata.Builder putText(String, CharSequence?); - method public androidx.media2.common.MediaMetadata.Builder setExtras(android.os.Bundle?); + @Deprecated public static final class MediaMetadata.Builder { + ctor @Deprecated public MediaMetadata.Builder(); + ctor @Deprecated public MediaMetadata.Builder(androidx.media2.common.MediaMetadata); + method @Deprecated public androidx.media2.common.MediaMetadata build(); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder putBitmap(String, android.graphics.Bitmap?); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder putFloat(String, float); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder putLong(String, long); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder putRating(String, androidx.media2.common.Rating?); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder putString(String, String?); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder putText(String, CharSequence?); + method @Deprecated public androidx.media2.common.MediaMetadata.Builder setExtras(android.os.Bundle?); } - public interface Rating extends androidx.versionedparcelable.VersionedParcelable { - method public boolean isRated(); + @Deprecated public interface Rating extends androidx.versionedparcelable.VersionedParcelable { + method @Deprecated public boolean isRated(); } - public abstract class SessionPlayer implements java.io.Closeable { - ctor public SessionPlayer(); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> addPlaylistItem(int, androidx.media2.common.MediaItem); - method @CallSuper public void close(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> deselectTrack(androidx.media2.common.SessionPlayer.TrackInfo); - method public abstract androidx.media.AudioAttributesCompat? getAudioAttributes(); - method public abstract long getBufferedPosition(); - method public abstract int getBufferingState(); - method protected final java.util.List<androidx.core.util.Pair<androidx.media2.common.SessionPlayer.PlayerCallback!,java.util.concurrent.Executor!>!> getCallbacks(); - method public abstract androidx.media2.common.MediaItem? getCurrentMediaItem(); - method @IntRange(from=androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) public abstract int getCurrentMediaItemIndex(); - method public abstract long getCurrentPosition(); - method public abstract long getDuration(); - method @IntRange(from=androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) public abstract int getNextMediaItemIndex(); - method public abstract float getPlaybackSpeed(); - method public abstract int getPlayerState(); - method public abstract java.util.List<androidx.media2.common.MediaItem!>? getPlaylist(); - method public abstract androidx.media2.common.MediaMetadata? getPlaylistMetadata(); - method @IntRange(from=androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) public abstract int getPreviousMediaItemIndex(); - method public abstract int getRepeatMode(); - method public androidx.media2.common.SessionPlayer.TrackInfo? getSelectedTrack(int); - method public abstract int getShuffleMode(); - method public java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!> getTracks(); - method public androidx.media2.common.VideoSize getVideoSize(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> movePlaylistItem(@IntRange(from=0) int, @IntRange(from=0) int); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> pause(); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> play(); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> prepare(); - method public final void registerPlayerCallback(java.util.concurrent.Executor, androidx.media2.common.SessionPlayer.PlayerCallback); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> removePlaylistItem(@IntRange(from=0) int); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> replacePlaylistItem(int, androidx.media2.common.MediaItem); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> seekTo(long); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> selectTrack(androidx.media2.common.SessionPlayer.TrackInfo); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAudioAttributes(androidx.media.AudioAttributesCompat); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setMediaItem(androidx.media2.common.MediaItem); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaybackSpeed(float); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaylist(java.util.List<androidx.media2.common.MediaItem!>, androidx.media2.common.MediaMetadata?); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setRepeatMode(int); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setShuffleMode(int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setSurface(android.view.Surface?); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToNextPlaylistItem(); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPlaylistItem(@IntRange(from=0) int); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPreviousPlaylistItem(); - method public final void unregisterPlayerCallback(androidx.media2.common.SessionPlayer.PlayerCallback); - method public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> updatePlaylistMetadata(androidx.media2.common.MediaMetadata?); - field public static final int BUFFERING_STATE_BUFFERING_AND_PLAYABLE = 1; // 0x1 - field public static final int BUFFERING_STATE_BUFFERING_AND_STARVED = 2; // 0x2 - field public static final int BUFFERING_STATE_COMPLETE = 3; // 0x3 - field public static final int BUFFERING_STATE_UNKNOWN = 0; // 0x0 - field public static final int INVALID_ITEM_INDEX = -1; // 0xffffffff - field public static final int PLAYER_STATE_ERROR = 3; // 0x3 - field public static final int PLAYER_STATE_IDLE = 0; // 0x0 - field public static final int PLAYER_STATE_PAUSED = 1; // 0x1 - field public static final int PLAYER_STATE_PLAYING = 2; // 0x2 - 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 - field public static final long UNKNOWN_TIME = -9223372036854775808L; // 0x8000000000000000L + @Deprecated public abstract class SessionPlayer implements java.io.Closeable { + ctor @Deprecated public SessionPlayer(); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> addPlaylistItem(int, androidx.media2.common.MediaItem); + method @Deprecated @CallSuper public void close(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> deselectTrack(androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public abstract androidx.media.AudioAttributesCompat? getAudioAttributes(); + method @Deprecated public abstract long getBufferedPosition(); + method @Deprecated public abstract int getBufferingState(); + method @Deprecated protected final java.util.List<androidx.core.util.Pair<androidx.media2.common.SessionPlayer.PlayerCallback!,java.util.concurrent.Executor!>!> getCallbacks(); + method @Deprecated public abstract androidx.media2.common.MediaItem? getCurrentMediaItem(); + method @Deprecated @IntRange(from=androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) public abstract int getCurrentMediaItemIndex(); + method @Deprecated public abstract long getCurrentPosition(); + method @Deprecated public abstract long getDuration(); + method @Deprecated @IntRange(from=androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) public abstract int getNextMediaItemIndex(); + method @Deprecated public abstract float getPlaybackSpeed(); + method @Deprecated public abstract int getPlayerState(); + method @Deprecated public abstract java.util.List<androidx.media2.common.MediaItem!>? getPlaylist(); + method @Deprecated public abstract androidx.media2.common.MediaMetadata? getPlaylistMetadata(); + method @Deprecated @IntRange(from=androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) public abstract int getPreviousMediaItemIndex(); + method @Deprecated public abstract int getRepeatMode(); + method @Deprecated public androidx.media2.common.SessionPlayer.TrackInfo? getSelectedTrack(int); + method @Deprecated public abstract int getShuffleMode(); + method @Deprecated public java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!> getTracks(); + method @Deprecated public androidx.media2.common.VideoSize getVideoSize(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> movePlaylistItem(@IntRange(from=0) int, @IntRange(from=0) int); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> pause(); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> play(); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> prepare(); + method @Deprecated public final void registerPlayerCallback(java.util.concurrent.Executor, androidx.media2.common.SessionPlayer.PlayerCallback); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> removePlaylistItem(@IntRange(from=0) int); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> replacePlaylistItem(int, androidx.media2.common.MediaItem); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> seekTo(long); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> selectTrack(androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAudioAttributes(androidx.media.AudioAttributesCompat); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setMediaItem(androidx.media2.common.MediaItem); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaybackSpeed(float); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaylist(java.util.List<androidx.media2.common.MediaItem!>, androidx.media2.common.MediaMetadata?); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setRepeatMode(int); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setShuffleMode(int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setSurface(android.view.Surface?); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToNextPlaylistItem(); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPlaylistItem(@IntRange(from=0) int); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPreviousPlaylistItem(); + method @Deprecated public final void unregisterPlayerCallback(androidx.media2.common.SessionPlayer.PlayerCallback); + method @Deprecated public abstract com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> updatePlaylistMetadata(androidx.media2.common.MediaMetadata?); + field @Deprecated public static final int BUFFERING_STATE_BUFFERING_AND_PLAYABLE = 1; // 0x1 + field @Deprecated public static final int BUFFERING_STATE_BUFFERING_AND_STARVED = 2; // 0x2 + field @Deprecated public static final int BUFFERING_STATE_COMPLETE = 3; // 0x3 + field @Deprecated public static final int BUFFERING_STATE_UNKNOWN = 0; // 0x0 + field @Deprecated public static final int INVALID_ITEM_INDEX = -1; // 0xffffffff + field @Deprecated public static final int PLAYER_STATE_ERROR = 3; // 0x3 + field @Deprecated public static final int PLAYER_STATE_IDLE = 0; // 0x0 + field @Deprecated public static final int PLAYER_STATE_PAUSED = 1; // 0x1 + field @Deprecated public static final int PLAYER_STATE_PLAYING = 2; // 0x2 + field @Deprecated public static final int REPEAT_MODE_ALL = 2; // 0x2 + field @Deprecated public static final int REPEAT_MODE_GROUP = 3; // 0x3 + field @Deprecated public static final int REPEAT_MODE_NONE = 0; // 0x0 + field @Deprecated public static final int REPEAT_MODE_ONE = 1; // 0x1 + field @Deprecated public static final int SHUFFLE_MODE_ALL = 1; // 0x1 + field @Deprecated public static final int SHUFFLE_MODE_GROUP = 2; // 0x2 + field @Deprecated public static final int SHUFFLE_MODE_NONE = 0; // 0x0 + field @Deprecated public static final long UNKNOWN_TIME = -9223372036854775808L; // 0x8000000000000000L } - public abstract static class SessionPlayer.PlayerCallback { - ctor public SessionPlayer.PlayerCallback(); - method public void onAudioAttributesChanged(androidx.media2.common.SessionPlayer, androidx.media.AudioAttributesCompat?); - method public void onBufferingStateChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaItem?, int); - method public void onCurrentMediaItemChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaItem?); - method public void onPlaybackCompleted(androidx.media2.common.SessionPlayer); - method public void onPlaybackSpeedChanged(androidx.media2.common.SessionPlayer, float); - method public void onPlayerStateChanged(androidx.media2.common.SessionPlayer, int); - method public void onPlaylistChanged(androidx.media2.common.SessionPlayer, java.util.List<androidx.media2.common.MediaItem!>?, androidx.media2.common.MediaMetadata?); - method public void onPlaylistMetadataChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaMetadata?); - method public void onRepeatModeChanged(androidx.media2.common.SessionPlayer, int); - method public void onSeekCompleted(androidx.media2.common.SessionPlayer, long); - method public void onShuffleModeChanged(androidx.media2.common.SessionPlayer, int); - method public void onSubtitleData(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaItem, androidx.media2.common.SessionPlayer.TrackInfo, androidx.media2.common.SubtitleData); - method public void onTrackDeselected(androidx.media2.common.SessionPlayer, androidx.media2.common.SessionPlayer.TrackInfo); - method public void onTrackSelected(androidx.media2.common.SessionPlayer, androidx.media2.common.SessionPlayer.TrackInfo); - method public void onTracksChanged(androidx.media2.common.SessionPlayer, java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!>); - method public void onVideoSizeChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.VideoSize); + @Deprecated public abstract static class SessionPlayer.PlayerCallback { + ctor @Deprecated public SessionPlayer.PlayerCallback(); + method @Deprecated public void onAudioAttributesChanged(androidx.media2.common.SessionPlayer, androidx.media.AudioAttributesCompat?); + method @Deprecated public void onBufferingStateChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaItem?, int); + method @Deprecated public void onCurrentMediaItemChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaItem?); + method @Deprecated public void onPlaybackCompleted(androidx.media2.common.SessionPlayer); + method @Deprecated public void onPlaybackSpeedChanged(androidx.media2.common.SessionPlayer, float); + method @Deprecated public void onPlayerStateChanged(androidx.media2.common.SessionPlayer, int); + method @Deprecated public void onPlaylistChanged(androidx.media2.common.SessionPlayer, java.util.List<androidx.media2.common.MediaItem!>?, androidx.media2.common.MediaMetadata?); + method @Deprecated public void onPlaylistMetadataChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaMetadata?); + method @Deprecated public void onRepeatModeChanged(androidx.media2.common.SessionPlayer, int); + method @Deprecated public void onSeekCompleted(androidx.media2.common.SessionPlayer, long); + method @Deprecated public void onShuffleModeChanged(androidx.media2.common.SessionPlayer, int); + method @Deprecated public void onSubtitleData(androidx.media2.common.SessionPlayer, androidx.media2.common.MediaItem, androidx.media2.common.SessionPlayer.TrackInfo, androidx.media2.common.SubtitleData); + method @Deprecated public void onTrackDeselected(androidx.media2.common.SessionPlayer, androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public void onTrackSelected(androidx.media2.common.SessionPlayer, androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public void onTracksChanged(androidx.media2.common.SessionPlayer, java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!>); + method @Deprecated public void onVideoSizeChanged(androidx.media2.common.SessionPlayer, androidx.media2.common.VideoSize); } - public static class SessionPlayer.PlayerResult { - ctor public SessionPlayer.PlayerResult(int, androidx.media2.common.MediaItem?); - method public long getCompletionTime(); - method public androidx.media2.common.MediaItem? getMediaItem(); - method public int getResultCode(); + @Deprecated public static class SessionPlayer.PlayerResult { + ctor @Deprecated public SessionPlayer.PlayerResult(int, androidx.media2.common.MediaItem?); + method @Deprecated public long getCompletionTime(); + method @Deprecated public androidx.media2.common.MediaItem? getMediaItem(); + method @Deprecated public int getResultCode(); field public static final int RESULT_ERROR_BAD_VALUE = -3; // 0xfffffffd field public static final int RESULT_ERROR_INVALID_STATE = -2; // 0xfffffffe field public static final int RESULT_ERROR_IO = -5; // 0xfffffffb @@ -226,47 +226,47 @@ package androidx.media2.common { field public static final int RESULT_SUCCESS = 0; // 0x0 } - @androidx.versionedparcelable.VersionedParcelize(isCustom=true) public static class SessionPlayer.TrackInfo extends androidx.versionedparcelable.CustomVersionedParcelable { - ctor public SessionPlayer.TrackInfo(int, int, android.media.MediaFormat?); - ctor public SessionPlayer.TrackInfo(int, int, android.media.MediaFormat?, boolean); - method public android.media.MediaFormat? getFormat(); - method public int getId(); - method public java.util.Locale getLanguage(); - method public int getTrackType(); - method public boolean isSelectable(); - field public static final int MEDIA_TRACK_TYPE_AUDIO = 2; // 0x2 - field public static final int MEDIA_TRACK_TYPE_METADATA = 5; // 0x5 - field public static final int MEDIA_TRACK_TYPE_SUBTITLE = 4; // 0x4 - field public static final int MEDIA_TRACK_TYPE_UNKNOWN = 0; // 0x0 - field public static final int MEDIA_TRACK_TYPE_VIDEO = 1; // 0x1 + @Deprecated @androidx.versionedparcelable.VersionedParcelize(isCustom=true) public static class SessionPlayer.TrackInfo extends androidx.versionedparcelable.CustomVersionedParcelable { + ctor @Deprecated public SessionPlayer.TrackInfo(int, int, android.media.MediaFormat?); + ctor @Deprecated public SessionPlayer.TrackInfo(int, int, android.media.MediaFormat?, boolean); + method @Deprecated public android.media.MediaFormat? getFormat(); + method @Deprecated public int getId(); + method @Deprecated public java.util.Locale getLanguage(); + method @Deprecated public int getTrackType(); + method @Deprecated public boolean isSelectable(); + field @Deprecated public static final int MEDIA_TRACK_TYPE_AUDIO = 2; // 0x2 + field @Deprecated public static final int MEDIA_TRACK_TYPE_METADATA = 5; // 0x5 + field @Deprecated public static final int MEDIA_TRACK_TYPE_SUBTITLE = 4; // 0x4 + field @Deprecated public static final int MEDIA_TRACK_TYPE_UNKNOWN = 0; // 0x0 + field @Deprecated public static final int MEDIA_TRACK_TYPE_VIDEO = 1; // 0x1 } - @androidx.versionedparcelable.VersionedParcelize public final class SubtitleData implements androidx.versionedparcelable.VersionedParcelable { - ctor public SubtitleData(long, long, byte[]); - method public byte[] getData(); - method public long getDurationUs(); - method public long getStartTimeUs(); + @Deprecated @androidx.versionedparcelable.VersionedParcelize public final class SubtitleData implements androidx.versionedparcelable.VersionedParcelable { + ctor @Deprecated public SubtitleData(long, long, byte[]); + method @Deprecated public byte[] getData(); + method @Deprecated public long getDurationUs(); + method @Deprecated public long getStartTimeUs(); } - public class UriMediaItem extends androidx.media2.common.MediaItem { - method public android.net.Uri getUri(); - method public java.util.List<java.net.HttpCookie!>? getUriCookies(); - method public java.util.Map<java.lang.String!,java.lang.String!>? getUriHeaders(); + @Deprecated public class UriMediaItem extends androidx.media2.common.MediaItem { + method @Deprecated public android.net.Uri getUri(); + method @Deprecated public java.util.List<java.net.HttpCookie!>? getUriCookies(); + method @Deprecated public java.util.Map<java.lang.String!,java.lang.String!>? getUriHeaders(); } - public static final class UriMediaItem.Builder extends androidx.media2.common.MediaItem.Builder { - ctor public UriMediaItem.Builder(android.net.Uri); - ctor public UriMediaItem.Builder(android.net.Uri, java.util.Map<java.lang.String!,java.lang.String!>?, java.util.List<java.net.HttpCookie!>?); - method public androidx.media2.common.UriMediaItem build(); - method public androidx.media2.common.UriMediaItem.Builder setEndPosition(long); - method public androidx.media2.common.UriMediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); - method public androidx.media2.common.UriMediaItem.Builder setStartPosition(long); + @Deprecated public static final class UriMediaItem.Builder extends androidx.media2.common.MediaItem.Builder { + ctor @Deprecated public UriMediaItem.Builder(android.net.Uri); + ctor @Deprecated public UriMediaItem.Builder(android.net.Uri, java.util.Map<java.lang.String!,java.lang.String!>?, java.util.List<java.net.HttpCookie!>?); + method @Deprecated public androidx.media2.common.UriMediaItem build(); + method @Deprecated public androidx.media2.common.UriMediaItem.Builder setEndPosition(long); + method @Deprecated public androidx.media2.common.UriMediaItem.Builder setMetadata(androidx.media2.common.MediaMetadata?); + method @Deprecated public androidx.media2.common.UriMediaItem.Builder setStartPosition(long); } - @androidx.versionedparcelable.VersionedParcelize public class VideoSize implements androidx.versionedparcelable.VersionedParcelable { - ctor public VideoSize(@IntRange(from=0) int, @IntRange(from=0) int); - method @IntRange(from=0) public int getHeight(); - method @IntRange(from=0) public int getWidth(); + @Deprecated @androidx.versionedparcelable.VersionedParcelize public class VideoSize implements androidx.versionedparcelable.VersionedParcelable { + ctor @Deprecated public VideoSize(@IntRange(from=0) int, @IntRange(from=0) int); + method @Deprecated @IntRange(from=0) public int getHeight(); + method @Deprecated @IntRange(from=0) public int getWidth(); } } diff --git a/media2/media2-common/src/main/java/androidx/media2/common/BaseResult.java b/media2/media2-common/src/main/java/androidx/media2/common/BaseResult.java index ae43b7e43aa..c4463632f0e 100644 --- a/media2/media2-common/src/main/java/androidx/media2/common/BaseResult.java +++ b/media2/media2-common/src/main/java/androidx/media2/common/BaseResult.java @@ -22,21 +22,27 @@ import androidx.annotation.Nullable; import androidx.annotation.RestrictTo; /** - * Base interface for all result classes in {@link androidx.media2.session.MediaSession}, - * {@link androidx.media2.session.MediaController}, - * and {@link SessionPlayer}, for defining result codes in one place with documentation. + * Base interface for all result classes in {@link androidx.media2.session.MediaSession}, {@link + * androidx.media2.session.MediaController}, and {@link SessionPlayer}, for defining result codes in + * one place with documentation. + * * <ul> - * <li>Error code: Negative integer</li> - * <li>Success code: 0</li> - * <li>Info code: Positive integer</li> + * <li>Error code: Negative integer + * <li>Success code: 0 + * <li>Info code: Positive integer * </ul> + * * <ul> - * <li> 0 < |code| < 100: Session player specific code.</li> - * <li> 100 <= |code| < 500: Session/Controller specific code.</li> - * <li> 500 <= |code| < 1000: Browser/Library session specific code.</li> - * <li>1000 <= |code| : Custom session player result code.</li> + * <li>0 < |code| < 100: Session player specific code. + * <li>100 <= |code| < 500: Session/Controller specific code. + * <li>500 <= |code| < 1000: Browser/Library session specific code. + * <li>1000 <= |code| : Custom session player result code. * </ul> + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated @RestrictTo(LIBRARY_GROUP) public interface BaseResult { /** diff --git a/media2/media2-common/src/main/java/androidx/media2/common/CallbackMediaItem.java b/media2/media2-common/src/main/java/androidx/media2/common/CallbackMediaItem.java index d9d444f8f41..825f2fe1bdd 100644 --- a/media2/media2-common/src/main/java/androidx/media2/common/CallbackMediaItem.java +++ b/media2/media2-common/src/main/java/androidx/media2/common/CallbackMediaItem.java @@ -23,14 +23,17 @@ import androidx.versionedparcelable.ParcelUtils; /** * Structure for media item descriptor for {@link DataSourceCallback}. - * <p> - * Users should use {@link Builder} to create {@link CallbackMediaItem}. - * <p> - * You cannot directly send this object across the process through {@link ParcelUtils}. See + * + * <p>Users should use {@link Builder} to create {@link CallbackMediaItem}. + * + * <p>You cannot directly send this object across the process through {@link ParcelUtils}. See * {@link MediaItem} for detail. * * @see MediaItem + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public class CallbackMediaItem extends MediaItem { private final DataSourceCallback mDataSourceCallback; @@ -52,7 +55,11 @@ public class CallbackMediaItem extends MediaItem { /** * This Builder class simplifies the creation of a {@link CallbackMediaItem} object. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static final class Builder extends MediaItem.Builder { @SuppressWarnings("WeakerAccess") /* synthetic access */ diff --git a/media2/media2-common/src/main/java/androidx/media2/common/DataSourceCallback.java b/media2/media2-common/src/main/java/androidx/media2/common/DataSourceCallback.java index aec577ad0bc..2f8496921d4 100644 --- a/media2/media2-common/src/main/java/androidx/media2/common/DataSourceCallback.java +++ b/media2/media2-common/src/main/java/androidx/media2/common/DataSourceCallback.java @@ -26,13 +26,16 @@ import java.io.IOException; * For supplying media data, implement this if your app has special requirements for the way media * data is obtained. * - * <p class="note">Methods of this interface may be called on multiple different - * threads. There will be a thread synchronization point between each call to ensure that - * modifications to the state of your DataSourceCallback are visible to future calls. This means - * you don't need to do your own synchronization unless you're modifying the - * DataSourceCallback from another thread while it's being used by the media library.</p> + * <p class="note">Methods of this interface may be called on multiple different threads. There will + * be a thread synchronization point between each call to ensure that modifications to the state of + * your DataSourceCallback are visible to future calls. This means you don't need to do your own + * synchronization unless you're modifying the DataSourceCallback from another thread while it's + * being used by the media library. * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public abstract class DataSourceCallback implements Closeable { /** * Called to request data from the given position. diff --git a/media2/media2-common/src/main/java/androidx/media2/common/FileMediaItem.java b/media2/media2-common/src/main/java/androidx/media2/common/FileMediaItem.java index 344a02f8144..8d20a317306 100644 --- a/media2/media2-common/src/main/java/androidx/media2/common/FileMediaItem.java +++ b/media2/media2-common/src/main/java/androidx/media2/common/FileMediaItem.java @@ -32,14 +32,17 @@ import java.io.IOException; /** * Structure for media item for a file. - * <p> - * Users should use {@link Builder} to create {@link FileMediaItem}. - * <p> - * You cannot directly send this object across the process through {@link ParcelUtils}. See + * + * <p>Users should use {@link Builder} to create {@link FileMediaItem}. + * + * <p>You cannot directly send this object across the process through {@link ParcelUtils}. See * {@link MediaItem} for detail. * * @see MediaItem + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public class FileMediaItem extends MediaItem { private static final String TAG = "FileMediaItem"; /** @@ -159,7 +162,11 @@ public class FileMediaItem extends MediaItem { /** * This Builder class simplifies the creation of a {@link FileMediaItem} object. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static final class Builder extends MediaItem.Builder { @SuppressWarnings("WeakerAccess") /* synthetic access */ diff --git a/media2/media2-common/src/main/java/androidx/media2/common/MediaItem.java b/media2/media2-common/src/main/java/androidx/media2/common/MediaItem.java index 5e9d4135151..c445435e7b6 100644 --- a/media2/media2-common/src/main/java/androidx/media2/common/MediaItem.java +++ b/media2/media2-common/src/main/java/androidx/media2/common/MediaItem.java @@ -39,27 +39,31 @@ import java.util.concurrent.Executor; /** * A class with information on a single media item with the metadata information. Here are use * cases. + * * <ul> - * <li>Specify media items to {@link SessionPlayer} for playback. - * <li>Share media items across the processes. + * <li>Specify media items to {@link SessionPlayer} for playback. + * <li>Share media items across the processes. * </ul> - * <p> - * Subclasses of the session player may only accept certain subclasses of the media items. Check + * + * <p>Subclasses of the session player may only accept certain subclasses of the media items. Check * the player documentation that you're interested in. - * <p> - * When it's shared across the processes, we cannot guarantee that they contain the right values + * + * <p>When it's shared across the processes, we cannot guarantee that they contain the right values * because media items are application dependent especially for the metadata. - * <p> - * When an object of the {@link MediaItem}'s subclass is sent across the process between - * {@link androidx.media2.session.MediaSession}/{@link androidx.media2.session.MediaController} or - * {@link androidx.media2.session.MediaLibraryService.MediaLibrarySession}/ - * {@link androidx.media2.session.MediaBrowser}, the - * object will sent as if it's {@link MediaItem}. The recipient cannot get the object with the - * subclasses' type. This will sanitize process specific information (e.g. - * {@link java.io.FileDescriptor}, {@link android.content.Context}, etc). - * <p> - * This object is thread safe. + * + * <p>When an object of the {@link MediaItem}'s subclass is sent across the process between {@link + * androidx.media2.session.MediaSession}/{@link androidx.media2.session.MediaController} or {@link + * androidx.media2.session.MediaLibraryService.MediaLibrarySession}/ {@link + * androidx.media2.session.MediaBrowser}, the object will sent as if it's {@link MediaItem}. The + * recipient cannot get the object with the subclasses' type. This will sanitize process specific + * information (e.g. {@link java.io.FileDescriptor}, {@link android.content.Context}, etc). + * + * <p>This object is thread safe. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated @VersionedParcelize(isCustom = true) public class MediaItem extends CustomVersionedParcelable { private static final String TAG = "MediaItem"; @@ -253,7 +257,11 @@ public class MediaItem extends CustomVersionedParcelable { /** * Builder for {@link MediaItem}. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static class Builder { @SuppressWarnings("WeakerAccess") /* synthetic access */ MediaMetadata mMetadata; diff --git a/media2/media2-common/src/main/java/androidx/media2/common/MediaMetadata.java b/media2/media2-common/src/main/java/androidx/media2/common/MediaMetadata.java index 5bf8ef42506..1959dc1908e 100644 --- a/media2/media2-common/src/main/java/androidx/media2/common/MediaMetadata.java +++ b/media2/media2-common/src/main/java/androidx/media2/common/MediaMetadata.java @@ -47,72 +47,80 @@ import java.util.Set; /** * Contains metadata about an item, such as the title, artist, etc. This is optional, but you'd * better to provide this as much as possible when you're using media widget and/or session APIs. - * <p> - * The media widget components build its UI based on the metadata here. For an example, - * {@link androidx.media2.widget.MediaControlView} will show title from the metadata. - * <p> - * The {@link androidx.media2.session.MediaLibraryService.MediaLibrarySession} would require - * some metadata values when it provides - * {@link MediaItem}s to {@link androidx.media2.session.MediaBrowser}. - * <p> - * Topics covered here: + * + * <p>The media widget components build its UI based on the metadata here. For an example, {@link + * androidx.media2.widget.MediaControlView} will show title from the metadata. + * + * <p>The {@link androidx.media2.session.MediaLibraryService.MediaLibrarySession} would require some + * metadata values when it provides {@link MediaItem}s to {@link + * androidx.media2.session.MediaBrowser}. + * + * <p>Topics covered here: + * * <ol> - * <li><a href="#MediaId">Media ID</a> - * <li><a href="#Browsable">Browsable type</a> - * <li><a href="#Playable">Playable</a> - * <li><a href="#Duration">Duration</a> - * <li><a href="#UserRating">User rating</a> + * <li><a href="#MediaId">Media ID</a> + * <li><a href="#Browsable">Browsable type</a> + * <li><a href="#Playable">Playable</a> + * <li><a href="#Duration">Duration</a> + * <li><a href="#UserRating">User rating</a> * </ol> + * * <h3 id="MediaId">{@link MediaMetadata#METADATA_KEY_MEDIA_ID Media ID}</h3> - * <p> - * If set, the media ID must be the persistent key for the underlying media contents, so - * {@link androidx.media2.session.MediaController} and {@link androidx.media2.session.MediaBrowser} - * can store the information and reuse it later. Some APIs requires a media ID (e.g. - * {@link androidx.media2.session.MediaController#setRating}, so you'd better specify - * one. - * <p> - * Typical example of using media ID is the URI of the contents, but use it with the caution because - * the metadata is shared across the process in plain text. - * <p> - * The {@link androidx.media2.session.MediaLibraryService.MediaLibrarySession} would require it - * for the library root, so {@link androidx.media2.session.MediaBrowser} can call subsequent - * {@link androidx.media2.session.MediaBrowser#getChildren} with the ID. + * + * <p>If set, the media ID must be the persistent key for the underlying media contents, so {@link + * androidx.media2.session.MediaController} and {@link androidx.media2.session.MediaBrowser} can + * store the information and reuse it later. Some APIs requires a media ID (e.g. {@link + * androidx.media2.session.MediaController#setRating}, so you'd better specify one. + * + * <p>Typical example of using media ID is the URI of the contents, but use it with the caution + * because the metadata is shared across the process in plain text. + * + * <p>The {@link androidx.media2.session.MediaLibraryService.MediaLibrarySession} would require it + * for the library root, so {@link androidx.media2.session.MediaBrowser} can call subsequent {@link + * androidx.media2.session.MediaBrowser#getChildren} with the ID. + * * <h3 id="Browsable">{@link MediaMetadata#METADATA_KEY_BROWSABLE Browsable type}</h3> - * <p> - * Browsable defines whether the media item has children and type of children if any. With this, - * {@link androidx.media2.session.MediaBrowser} can know whether the subsequent - * {@link androidx.media2.session.MediaBrowser#getChildren} would successfully run. - * <p> - * The {@link androidx.media2.session.MediaLibraryService.MediaLibrarySession} would require - * the explicit browsable type for the media items returned by the - * {@link + * + * <p>Browsable defines whether the media item has children and type of children if any. With this, + * {@link androidx.media2.session.MediaBrowser} can know whether the subsequent {@link + * androidx.media2.session.MediaBrowser#getChildren} would successfully run. + * + * <p>The {@link androidx.media2.session.MediaLibraryService.MediaLibrarySession} would require the + * explicit browsable type for the media items returned by the {@link * androidx.media2.session.MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback}. + * * <h3 id="Playable">{@link MediaMetadata#METADATA_KEY_PLAYABLE Playable type}</h3> - * <p> - * Playable defines whether the media item can be played or not. It may be possible for a playlist - * to contain a media item which isn't playable in order to show a disabled media item. - * <p> - * The {@link androidx.media2.session.MediaLibraryService.MediaLibrarySession} would require - * the explicit playable value for the media items returned by the - * {@link + * + * <p>Playable defines whether the media item can be played or not. It may be possible for a + * playlist to contain a media item which isn't playable in order to show a disabled media item. + * + * <p>The {@link androidx.media2.session.MediaLibraryService.MediaLibrarySession} would require the + * explicit playable value for the media items returned by the {@link * androidx.media2.session.MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback}. + * * <h3 id="Duration">{@link MediaMetadata#METADATA_KEY_DURATION Duration}</h3> + * * The duration is the length of the contents. The {@link androidx.media2.session.MediaController} * can only get the duration through the metadata. This tells when would the playback ends, and also * tells about the allowed range of {@link androidx.media2.session.MediaController#seekTo(long)}. - * <p> - * If it's not set by developer, {@link androidx.media2.session.MediaSession} would update - * the duration in the metadata with the {@link SessionPlayer#getDuration()}. + * + * <p>If it's not set by developer, {@link androidx.media2.session.MediaSession} would update the + * duration in the metadata with the {@link SessionPlayer#getDuration()}. + * * <h3 id="UserRating">{@link MediaMetadata#METADATA_KEY_USER_RATING User rating}</h3> - * <p> - * Prefer to have unrated user rating instead of {@code null}, so - * {@link androidx.media2.session.MediaController} can know the possible user rating type - * for calling {@link androidx.media2.session.MediaController#setRating(String, Rating)}. + * + * <p>Prefer to have unrated user rating instead of {@code null}, so {@link + * androidx.media2.session.MediaController} can know the possible user rating type for calling + * {@link androidx.media2.session.MediaController#setRating(String, Rating)}. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ // New version of MediaMetadata with following changes // - Don't implement Parcelable for updatable support. // - Also support MediaDescription features. MediaDescription is deprecated instead because // it was insufficient for controller to display media contents. (e.g. duration is missing) +@Deprecated @VersionedParcelize(isCustom = true) public final class MediaMetadata extends CustomVersionedParcelable { private static final String TAG = "MediaMetadata"; @@ -982,9 +990,13 @@ public final class MediaMetadata extends CustomVersionedParcelable { } /** - * Use to build MediaMetadatax objects. The system defined metadata keys must - * use the appropriate data type. + * Use to build MediaMetadatax objects. The system defined metadata keys must use the + * appropriate data type. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static final class Builder { final Bundle mBundle; @@ -1242,7 +1254,11 @@ public final class MediaMetadata extends CustomVersionedParcelable { /** * Stores a bitmap and the matching key. Used for sending bitmaps to other process one-by-one. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated @VersionedParcelize static final class BitmapEntry implements VersionedParcelable { static final int BITMAP_SIZE_LIMIT_IN_BYTES = 256 * 1024; // 256 KB diff --git a/media2/media2-common/src/main/java/androidx/media2/common/Rating.java b/media2/media2-common/src/main/java/androidx/media2/common/Rating.java index 6bfd8cd69d3..f13f75d4ae2 100644 --- a/media2/media2-common/src/main/java/androidx/media2/common/Rating.java +++ b/media2/media2-common/src/main/java/androidx/media2/common/Rating.java @@ -20,7 +20,11 @@ import androidx.versionedparcelable.VersionedParcelable; /** * An interface to encapsulate rating information used as content metadata. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public interface Rating extends VersionedParcelable { /** * Returns whether there is a rating value available. diff --git a/media2/media2-common/src/main/java/androidx/media2/common/SessionPlayer.java b/media2/media2-common/src/main/java/androidx/media2/common/SessionPlayer.java index 3081607a805..4e75658b44d 100644 --- a/media2/media2-common/src/main/java/androidx/media2/common/SessionPlayer.java +++ b/media2/media2-common/src/main/java/androidx/media2/common/SessionPlayer.java @@ -53,15 +53,16 @@ import java.util.concurrent.Executor; /** * Base interface for all media players that want media session. - * <p> - * APIs that return {@link ListenableFuture} should be the asynchronous calls and shouldn't block + * + * <p>APIs that return {@link ListenableFuture} should be the asynchronous calls and shouldn't block * the calling thread. This guarantees the APIs are safe to be called on the main thread. * * <p>Topics covered here are: + * * <ol> - * <li><a href="#BestPractices">Best practices</a> - * <li><a href="#PlayerStates">Player states</a> - * <li><a href="#InvalidStates">Invalid method calls</a> + * <li><a href="#BestPractices">Best practices</a> + * <li><a href="#PlayerStates">Player states</a> + * <li><a href="#InvalidStates">Invalid method calls</a> * </ol> * * <h3 id="BestPractices">Best practices</h3> @@ -69,80 +70,76 @@ import java.util.concurrent.Executor; * Here are best practices when implementing/using SessionPlayer: * * <ul> - * <li>When updating UI, you should respond to {@link PlayerCallback} invocations instead of - * {@link PlayerResult} objects since the player can be controlled by others. - * <li>When a SessionPlayer object is no longer being used, call {@link #close()} as soon as - * possible to release the resources used by the internal player engine associated with the - * SessionPlayer. For example, if a player uses hardware decoder, other player instances may - * fallback to software decoders or fail to play. You cannot use SessionPlayer instance after - * you call {@link #close()}. There is no way to reuse the instance. - * <li>The current playback position can be retrieved with a call to {@link #getCurrentPosition()}, - * which is helpful for applications such as a music player that need to keep track of the playback - * progress. - * <li>The playback position can be adjusted with a call to {@link #seekTo(long)}. Although the - * asynchronous {@link #seekTo} call returns right away, the actual seek operation may take a - * while to finish, especially for audio/video being streamed. - * <li>You can call {@link #seekTo(long)} from the {@link #PLAYER_STATE_PAUSED}. In these cases, if - * you are playing a video stream and the requested position is valid, one video frame may be - * displayed. + * <li>When updating UI, you should respond to {@link PlayerCallback} invocations instead of + * {@link PlayerResult} objects since the player can be controlled by others. + * <li>When a SessionPlayer object is no longer being used, call {@link #close()} as soon as + * possible to release the resources used by the internal player engine associated with the + * SessionPlayer. For example, if a player uses hardware decoder, other player instances may + * fallback to software decoders or fail to play. You cannot use SessionPlayer instance after + * you call {@link #close()}. There is no way to reuse the instance. + * <li>The current playback position can be retrieved with a call to {@link + * #getCurrentPosition()}, which is helpful for applications such as a music player that need + * to keep track of the playback progress. + * <li>The playback position can be adjusted with a call to {@link #seekTo(long)}. Although the + * asynchronous {@link #seekTo} call returns right away, the actual seek operation may take a + * while to finish, especially for audio/video being streamed. + * <li>You can call {@link #seekTo(long)} from the {@link #PLAYER_STATE_PAUSED}. In these cases, + * if you are playing a video stream and the requested position is valid, one video frame may + * be displayed. * </ul> * * <h3 id="PlayerStates">Player states</h3> + * * The playback control of audio/video files is managed as a state machine. The SessionPlayer * defines four states: - * <ol> - * <li>{@link #PLAYER_STATE_IDLE}: Initial state after the instantiation. - * <p> - * While in this state, you should call {@link #setMediaItem(MediaItem)} or - * {@link #setPlaylist(List, MediaMetadata)}. Check returned {@link ListenableFuture} for - * potential error. - * <p> - * Calling {@link #prepare()} transfers this object to {@link #PLAYER_STATE_PAUSED}. - * - * <li>{@link #PLAYER_STATE_PAUSED}: State when the audio/video playback is paused. - * <p> - * Call {@link #play()} to resume or start playback from the position where it paused. - * - * <li>{@link #PLAYER_STATE_PLAYING}: State when the player plays the media item. - * <p> - * In this state, {@link PlayerCallback#onBufferingStateChanged( - * SessionPlayer, MediaItem, int)} will be called regularly to tell the buffering status. - * <p> - * Playback state would remain {@link #PLAYER_STATE_PLAYING} when the currently playing - * media item is changed. - * <p> - * When the playback reaches the end of stream, the behavior depends on repeat mode, set by - * {@link #setRepeatMode(int)}. If the repeat mode was set to {@link #REPEAT_MODE_NONE}, - * the player will transfer to the {@link #PLAYER_STATE_PAUSED}. Otherwise, the - * SessionPlayer object remains in the {@link #PLAYER_STATE_PLAYING} and playback will be - * ongoing. * - * <li>{@link #PLAYER_STATE_ERROR}: State when the playback failed and player cannot be - * recovered by itself. - * <p> - * In general, playback might fail due to various reasons such as unsupported audio/video - * format, poorly interleaved audio/video, resolution too high, streaming timeout, and - * others. In addition, due to programming errors, a playback control operation might be - * performed from an <a href="#InvalidStates">invalid state</a>. In these cases the player - * may transition to this state. + * <ol> + * <li>{@link #PLAYER_STATE_IDLE}: Initial state after the instantiation. + * <p>While in this state, you should call {@link #setMediaItem(MediaItem)} or {@link + * #setPlaylist(List, MediaMetadata)}. Check returned {@link ListenableFuture} for potential + * error. + * <p>Calling {@link #prepare()} transfers this object to {@link #PLAYER_STATE_PAUSED}. + * <li>{@link #PLAYER_STATE_PAUSED}: State when the audio/video playback is paused. + * <p>Call {@link #play()} to resume or start playback from the position where it paused. + * <li>{@link #PLAYER_STATE_PLAYING}: State when the player plays the media item. + * <p>In this state, {@link PlayerCallback#onBufferingStateChanged( SessionPlayer, MediaItem, + * int)} will be called regularly to tell the buffering status. + * <p>Playback state would remain {@link #PLAYER_STATE_PLAYING} when the currently playing + * media item is changed. + * <p>When the playback reaches the end of stream, the behavior depends on repeat mode, set by + * {@link #setRepeatMode(int)}. If the repeat mode was set to {@link #REPEAT_MODE_NONE}, the + * player will transfer to the {@link #PLAYER_STATE_PAUSED}. Otherwise, the SessionPlayer + * object remains in the {@link #PLAYER_STATE_PLAYING} and playback will be ongoing. + * <li>{@link #PLAYER_STATE_ERROR}: State when the playback failed and player cannot be recovered + * by itself. + * <p>In general, playback might fail due to various reasons such as unsupported audio/video + * format, poorly interleaved audio/video, resolution too high, streaming timeout, and others. + * In addition, due to programming errors, a playback control operation might be performed + * from an <a href="#InvalidStates">invalid state</a>. In these cases the player may + * transition to this state. * </ol> + * * Subclasses may have extra methods to reset the player state to {@link #PLAYER_STATE_IDLE} from * other states. Take a look at documentations of specific subclass that you're interested in. + * * <p> * * <h3 id="InvalidStates">Invalid method calls</h3> - * The only method you safely call from the {@link #PLAYER_STATE_ERROR} is {@link #close()}. - * Any other methods might return meaningless data. - * <p> - * Subclasses of the SessionPlayer may have extra methods that are safe to be called in the error + * + * The only method you safely call from the {@link #PLAYER_STATE_ERROR} is {@link #close()}. Any + * other methods might return meaningless data. + * + * <p>Subclasses of the SessionPlayer may have extra methods that are safe to be called in the error * state and/or provide a method to recover from the error state. Take a look at documentations of * specific subclass that you're interested in. + * + * <p>Most methods can be called from any non-Error state. In case they're called in invalid state, + * the implementation should ignore and would return {@link PlayerResult} with {@link + * PlayerResult#RESULT_ERROR_INVALID_STATE}. The following table lists the methods that aren't + * guaranteed to successfully running if they're called from the associated invalid states. + * * <p> - * Most methods can be called from any non-Error state. In case they're called in invalid state, - * the implementation should ignore and would return {@link PlayerResult} with - * {@link PlayerResult#RESULT_ERROR_INVALID_STATE}. The following table lists the methods that - * aren't guaranteed to successfully running if they're called from the associated invalid states. - * <p> + * * <table> * <tr><th>Method Name</th> <th>Invalid States</th></tr> * <tr><td>setAudioAttributes</td> <td>{Paused, Playing}</td></tr> @@ -151,11 +148,15 @@ import java.util.concurrent.Executor; * <tr><td>pause</td> <td>{Idle}</td></tr> * <tr><td>seekTo</td> <td>{Idle}</td></tr> * </table> + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ // Previously MediaSessionCompat.Callback. // Players can extend this directly (e.g. MediaPlayer) or create wrapper and control underlying // player. // Preferably it can be interface, but API guideline requires to use abstract class. +@Deprecated public abstract class SessionPlayer implements Closeable { private static final String TAG = "SessionPlayer"; @@ -1016,18 +1017,22 @@ public abstract class SessionPlayer implements Closeable { /** * Class for the player to return each audio/video/subtitle track's metadata. * - * Note: TrackInfo holds a MediaFormat instance, but only the following key-values will be + * <p>Note: TrackInfo holds a MediaFormat instance, but only the following key-values will be * supported when sending it over different processes: + * * <ul> - * <li>{@link MediaFormat#KEY_LANGUAGE}</li> - * <li>{@link MediaFormat#KEY_MIME}</li> - * <li>{@link MediaFormat#KEY_IS_FORCED_SUBTITLE}</li> - * <li>{@link MediaFormat#KEY_IS_AUTOSELECT}</li> - * <li>{@link MediaFormat#KEY_IS_DEFAULT}</li> + * <li>{@link MediaFormat#KEY_LANGUAGE} + * <li>{@link MediaFormat#KEY_MIME} + * <li>{@link MediaFormat#KEY_IS_FORCED_SUBTITLE} + * <li>{@link MediaFormat#KEY_IS_AUTOSELECT} + * <li>{@link MediaFormat#KEY_IS_DEFAULT} * </ul> * * @see #getTracks + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated @VersionedParcelize(isCustom = true) public static class TrackInfo extends CustomVersionedParcelable { public static final int MEDIA_TRACK_TYPE_UNKNOWN = 0; @@ -1290,9 +1295,13 @@ public abstract class SessionPlayer implements Closeable { } /** - * A callback class to receive notifications for events on the session player. See - * {@link #registerPlayerCallback(Executor, PlayerCallback)} to register this callback. + * A callback class to receive notifications for events on the session player. See {@link + * #registerPlayerCallback(Executor, PlayerCallback)} to register this callback. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public abstract static class PlayerCallback { /** * Called when the state of the player has changed. @@ -1509,17 +1518,23 @@ public abstract class SessionPlayer implements Closeable { /** * Result class of the asynchronous APIs. + * + * <p>Subclass may extend this class for providing more result and/or custom result code. For + * the custom result code, follow the convention below to avoid potential code duplication. + * * <p> - * Subclass may extend this class for providing more result and/or custom result code. For the - * custom result code, follow the convention below to avoid potential code duplication. - * <p> + * * <ul> - * <li>Predefined error code: Negative integers greater than -100. (i.e. -100 < code < 0) - * <li>Custom error code: Negative integers equal to or less than -1000. (i.e. code < -1000) - * <li>Predefined info code: Positive integers less than 100. (i.e. 0 < code < 100) - * <li>Custom Info code: Positive integers equal to or greater than 1000. (i.e. code > +1000) + * <li>Predefined error code: Negative integers greater than -100. (i.e. -100 < code < 0) + * <li>Custom error code: Negative integers equal to or less than -1000. (i.e. code < -1000) + * <li>Predefined info code: Positive integers less than 100. (i.e. 0 < code < 100) + * <li>Custom Info code: Positive integers equal to or greater than 1000. (i.e. code > +1000) * </ul> + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated @SuppressWarnings("HiddenSuperclass") public static class PlayerResult implements BaseResult { /** diff --git a/media2/media2-common/src/main/java/androidx/media2/common/SubtitleData.java b/media2/media2-common/src/main/java/androidx/media2/common/SubtitleData.java index 0b33264941e..e6c71b58444 100644 --- a/media2/media2-common/src/main/java/androidx/media2/common/SubtitleData.java +++ b/media2/media2-common/src/main/java/androidx/media2/common/SubtitleData.java @@ -27,24 +27,26 @@ import java.util.Arrays; import java.util.concurrent.Executor; /** - * Class encapsulating subtitle data, as received through the - * {@link SessionPlayer.PlayerCallback#onSubtitleData} interface. - * The subtitle data includes: + * Class encapsulating subtitle data, as received through the {@link + * SessionPlayer.PlayerCallback#onSubtitleData} interface. The subtitle data includes: + * * <ul> - * <li> the start time (in microseconds) of the data</li> - * <li> the duration (in microseconds) of the data</li> - * <li> the actual data.</li> + * <li>the start time (in microseconds) of the data + * <li>the duration (in microseconds) of the data + * <li>the actual data. * </ul> - * The data is stored in a byte-array, and is encoded in one of the supported in-band - * subtitle formats. The subtitle encoding is determined by the MIME type of the - * {@link SessionPlayer.TrackInfo} of the subtitle track, one of - * {@link android.media.MediaFormat#MIMETYPE_TEXT_CEA_608} or - * {@link android.media.MediaFormat#MIMETYPE_TEXT_CEA_708}. * - * <p> - * Here is an example of iterating over the tracks of a {@link SessionPlayer}, and checking which + * The data is stored in a byte-array, and is encoded in one of the supported in-band subtitle + * formats. The subtitle encoding is determined by the MIME type of the {@link + * SessionPlayer.TrackInfo} of the subtitle track, one of {@link + * android.media.MediaFormat#MIMETYPE_TEXT_CEA_608} or {@link + * android.media.MediaFormat#MIMETYPE_TEXT_CEA_708}. + * + * <p>Here is an example of iterating over the tracks of a {@link SessionPlayer}, and checking which * encoding is used for the subtitle tracks: + * * <p> + * * <pre class="prettyprint"> * // Initialize instance of player that extends SessionPlayer * SessionPlayerExtension player = new SessionPlayerExtension(); @@ -61,11 +63,16 @@ import java.util.concurrent.Executor; * } * } * </pre> + * * <p> + * * @see SessionPlayer#registerPlayerCallback(Executor, SessionPlayer.PlayerCallback) * @see SessionPlayer.PlayerCallback#onSubtitleData(SessionPlayer, MediaItem, - * SessionPlayer.TrackInfo, SubtitleData) + * SessionPlayer.TrackInfo, SubtitleData) + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated @VersionedParcelize public final class SubtitleData implements VersionedParcelable { private static final String TAG = "SubtitleData"; diff --git a/media2/media2-common/src/main/java/androidx/media2/common/UriMediaItem.java b/media2/media2-common/src/main/java/androidx/media2/common/UriMediaItem.java index f8e4f9548b4..5e2273c959f 100644 --- a/media2/media2-common/src/main/java/androidx/media2/common/UriMediaItem.java +++ b/media2/media2-common/src/main/java/androidx/media2/common/UriMediaItem.java @@ -33,14 +33,17 @@ import java.util.Map; /** * Structure for media item descriptor for {@link Uri}. - * <p> - * Users should use {@link Builder} to create {@link UriMediaItem}. - * <p> - * You cannot directly send this object across the process through {@link ParcelUtils}. See + * + * <p>Users should use {@link Builder} to create {@link UriMediaItem}. + * + * <p>You cannot directly send this object across the process through {@link ParcelUtils}. See * {@link MediaItem} for detail. * * @see MediaItem + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public class UriMediaItem extends MediaItem { private final Uri mUri; private final Map<String, String> mUriHeader; @@ -88,7 +91,11 @@ public class UriMediaItem extends MediaItem { /** * This Builder class simplifies the creation of a {@link UriMediaItem} object. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static final class Builder extends MediaItem.Builder { @SuppressWarnings("WeakerAccess") /* synthetic access */ diff --git a/media2/media2-common/src/main/java/androidx/media2/common/VideoSize.java b/media2/media2-common/src/main/java/androidx/media2/common/VideoSize.java index 3a6254c91a8..b14546f111f 100644 --- a/media2/media2-common/src/main/java/androidx/media2/common/VideoSize.java +++ b/media2/media2-common/src/main/java/androidx/media2/common/VideoSize.java @@ -25,7 +25,11 @@ import androidx.versionedparcelable.VersionedParcelize; /** * Immutable class for describing video size. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated @VersionedParcelize public class VideoSize implements VersionedParcelable { @ParcelField(1) diff --git a/media2/media2-player/api/current.txt b/media2/media2-player/api/current.txt index c5e968dbc6a..0b2be000871 100644 --- a/media2/media2-player/api/current.txt +++ b/media2/media2-player/api/current.txt @@ -1,122 +1,122 @@ // Signature format: 4.0 package androidx.media2.player { - public final class MediaPlayer extends androidx.media2.common.SessionPlayer { - ctor public MediaPlayer(android.content.Context); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> addPlaylistItem(int, androidx.media2.common.MediaItem); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> attachAuxEffect(int); - method public androidx.media.AudioAttributesCompat? getAudioAttributes(); - method public int getAudioSessionId(); - method public long getBufferedPosition(); - method public int getBufferingState(); - method public androidx.media2.common.MediaItem? getCurrentMediaItem(); - method public int getCurrentMediaItemIndex(); - method public long getCurrentPosition(); - method public long getDuration(); - method public float getMaxPlayerVolume(); - method public int getNextMediaItemIndex(); - method public androidx.media2.player.PlaybackParams getPlaybackParams(); - method @FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) public float getPlaybackSpeed(); - method public int getPlayerState(); - method public float getPlayerVolume(); - method public java.util.List<androidx.media2.common.MediaItem!>? getPlaylist(); - method public androidx.media2.common.MediaMetadata? getPlaylistMetadata(); - method public int getPreviousMediaItemIndex(); - method public int getRepeatMode(); - method public androidx.media2.player.MediaPlayer.TrackInfo? getSelectedTrack(int); - method public int getShuffleMode(); - method public androidx.media2.player.MediaTimestamp? getTimestamp(); + @Deprecated public final class MediaPlayer extends androidx.media2.common.SessionPlayer { + ctor @Deprecated public MediaPlayer(android.content.Context); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> addPlaylistItem(int, androidx.media2.common.MediaItem); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> attachAuxEffect(int); + method @Deprecated public androidx.media.AudioAttributesCompat? getAudioAttributes(); + method @Deprecated public int getAudioSessionId(); + method @Deprecated public long getBufferedPosition(); + method @Deprecated public int getBufferingState(); + method @Deprecated public androidx.media2.common.MediaItem? getCurrentMediaItem(); + method @Deprecated public int getCurrentMediaItemIndex(); + method @Deprecated public long getCurrentPosition(); + method @Deprecated public long getDuration(); + method @Deprecated public float getMaxPlayerVolume(); + method @Deprecated public int getNextMediaItemIndex(); + method @Deprecated public androidx.media2.player.PlaybackParams getPlaybackParams(); + method @Deprecated @FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) public float getPlaybackSpeed(); + method @Deprecated public int getPlayerState(); + method @Deprecated public float getPlayerVolume(); + method @Deprecated public java.util.List<androidx.media2.common.MediaItem!>? getPlaylist(); + method @Deprecated public androidx.media2.common.MediaMetadata? getPlaylistMetadata(); + method @Deprecated public int getPreviousMediaItemIndex(); + method @Deprecated public int getRepeatMode(); + method @Deprecated public androidx.media2.player.MediaPlayer.TrackInfo? getSelectedTrack(int); + method @Deprecated public int getShuffleMode(); + method @Deprecated public androidx.media2.player.MediaTimestamp? getTimestamp(); method @Deprecated public java.util.List<androidx.media2.player.MediaPlayer.TrackInfo!> getTrackInfo(); - method public androidx.media2.player.VideoSize getVideoSize(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> pause(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> play(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> prepare(); - method public void registerPlayerCallback(java.util.concurrent.Executor, androidx.media2.player.MediaPlayer.PlayerCallback); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> removePlaylistItem(@IntRange(from=0) int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> replacePlaylistItem(int, androidx.media2.common.MediaItem); - method public void reset(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> seekTo(long); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> seekTo(long, int); + method @Deprecated public androidx.media2.player.VideoSize getVideoSize(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> pause(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> play(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> prepare(); + method @Deprecated public void registerPlayerCallback(java.util.concurrent.Executor, androidx.media2.player.MediaPlayer.PlayerCallback); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> removePlaylistItem(@IntRange(from=0) int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> replacePlaylistItem(int, androidx.media2.common.MediaItem); + method @Deprecated public void reset(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> seekTo(long); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> seekTo(long, int); method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> selectTrack(androidx.media2.player.MediaPlayer.TrackInfo); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAudioAttributes(androidx.media.AudioAttributesCompat); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAudioSessionId(int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAuxEffectSendLevel(@FloatRange(from=0, to=1) float); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setMediaItem(androidx.media2.common.MediaItem); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaybackParams(androidx.media2.player.PlaybackParams); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaybackSpeed(@FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) float); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlayerVolume(@FloatRange(from=0, to=1) float); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaylist(java.util.List<androidx.media2.common.MediaItem!>, androidx.media2.common.MediaMetadata?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setRepeatMode(int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setShuffleMode(int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToNextPlaylistItem(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPlaylistItem(@IntRange(from=0) int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPreviousPlaylistItem(); - method public void unregisterPlayerCallback(androidx.media2.player.MediaPlayer.PlayerCallback); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> updatePlaylistMetadata(androidx.media2.common.MediaMetadata?); - field public static final int MEDIA_INFO_AUDIO_NOT_PLAYING = 804; // 0x324 - field public static final int MEDIA_INFO_BAD_INTERLEAVING = 800; // 0x320 - field public static final int MEDIA_INFO_BUFFERING_UPDATE = 704; // 0x2c0 - field public static final int MEDIA_INFO_METADATA_UPDATE = 802; // 0x322 - field public static final int MEDIA_INFO_NOT_SEEKABLE = 801; // 0x321 - field public static final int MEDIA_INFO_VIDEO_NOT_PLAYING = 805; // 0x325 - field public static final int MEDIA_INFO_VIDEO_RENDERING_START = 3; // 0x3 - field public static final int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700; // 0x2bc + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAudioAttributes(androidx.media.AudioAttributesCompat); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAudioSessionId(int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAuxEffectSendLevel(@FloatRange(from=0, to=1) float); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setMediaItem(androidx.media2.common.MediaItem); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaybackParams(androidx.media2.player.PlaybackParams); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaybackSpeed(@FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) float); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlayerVolume(@FloatRange(from=0, to=1) float); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaylist(java.util.List<androidx.media2.common.MediaItem!>, androidx.media2.common.MediaMetadata?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setRepeatMode(int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setShuffleMode(int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToNextPlaylistItem(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPlaylistItem(@IntRange(from=0) int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPreviousPlaylistItem(); + method @Deprecated public void unregisterPlayerCallback(androidx.media2.player.MediaPlayer.PlayerCallback); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> updatePlaylistMetadata(androidx.media2.common.MediaMetadata?); + field @Deprecated public static final int MEDIA_INFO_AUDIO_NOT_PLAYING = 804; // 0x324 + field @Deprecated public static final int MEDIA_INFO_BAD_INTERLEAVING = 800; // 0x320 + field @Deprecated public static final int MEDIA_INFO_BUFFERING_UPDATE = 704; // 0x2c0 + field @Deprecated public static final int MEDIA_INFO_METADATA_UPDATE = 802; // 0x322 + field @Deprecated public static final int MEDIA_INFO_NOT_SEEKABLE = 801; // 0x321 + field @Deprecated public static final int MEDIA_INFO_VIDEO_NOT_PLAYING = 805; // 0x325 + field @Deprecated public static final int MEDIA_INFO_VIDEO_RENDERING_START = 3; // 0x3 + field @Deprecated public static final int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700; // 0x2bc field @Deprecated public static final int NO_TRACK_SELECTED = -2147483648; // 0x80000000 - field public static final int PLAYER_ERROR_IO = -1004; // 0xfffffc14 - field public static final int PLAYER_ERROR_MALFORMED = -1007; // 0xfffffc11 - field public static final int PLAYER_ERROR_TIMED_OUT = -110; // 0xffffff92 - field public static final int PLAYER_ERROR_UNKNOWN = 1; // 0x1 - field public static final int PLAYER_ERROR_UNSUPPORTED = -1010; // 0xfffffc0e - field public static final int SEEK_CLOSEST = 3; // 0x3 - field public static final int SEEK_CLOSEST_SYNC = 2; // 0x2 - field public static final int SEEK_NEXT_SYNC = 1; // 0x1 - field public static final int SEEK_PREVIOUS_SYNC = 0; // 0x0 + field @Deprecated public static final int PLAYER_ERROR_IO = -1004; // 0xfffffc14 + field @Deprecated public static final int PLAYER_ERROR_MALFORMED = -1007; // 0xfffffc11 + field @Deprecated public static final int PLAYER_ERROR_TIMED_OUT = -110; // 0xffffff92 + field @Deprecated public static final int PLAYER_ERROR_UNKNOWN = 1; // 0x1 + field @Deprecated public static final int PLAYER_ERROR_UNSUPPORTED = -1010; // 0xfffffc0e + field @Deprecated public static final int SEEK_CLOSEST = 3; // 0x3 + field @Deprecated public static final int SEEK_CLOSEST_SYNC = 2; // 0x2 + field @Deprecated public static final int SEEK_NEXT_SYNC = 1; // 0x1 + field @Deprecated public static final int SEEK_PREVIOUS_SYNC = 0; // 0x0 } - public abstract static class MediaPlayer.PlayerCallback extends androidx.media2.common.SessionPlayer.PlayerCallback { - ctor public MediaPlayer.PlayerCallback(); - method public void onError(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, int, int); - method public void onInfo(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, int, int); - method public void onMediaTimeDiscontinuity(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, androidx.media2.player.MediaTimestamp); - method public void onTimedMetaDataAvailable(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, androidx.media2.player.TimedMetaData); + @Deprecated public abstract static class MediaPlayer.PlayerCallback extends androidx.media2.common.SessionPlayer.PlayerCallback { + ctor @Deprecated public MediaPlayer.PlayerCallback(); + method @Deprecated public void onError(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, int, int); + method @Deprecated public void onInfo(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, int, int); + method @Deprecated public void onMediaTimeDiscontinuity(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, androidx.media2.player.MediaTimestamp); + method @Deprecated public void onTimedMetaDataAvailable(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, androidx.media2.player.TimedMetaData); method @Deprecated public void onVideoSizeChanged(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, androidx.media2.player.VideoSize); } - public static final class MediaPlayer.TrackInfo extends androidx.media2.common.SessionPlayer.TrackInfo implements androidx.versionedparcelable.VersionedParcelable { + @Deprecated public static final class MediaPlayer.TrackInfo extends androidx.media2.common.SessionPlayer.TrackInfo implements androidx.versionedparcelable.VersionedParcelable { } - public final class MediaTimestamp { - method public long getAnchorMediaTimeUs(); - method public long getAnchorSystemNanoTime(); - method public float getMediaClockRate(); - field public static final androidx.media2.player.MediaTimestamp TIMESTAMP_UNKNOWN; + @Deprecated public final class MediaTimestamp { + method @Deprecated public long getAnchorMediaTimeUs(); + method @Deprecated public long getAnchorSystemNanoTime(); + method @Deprecated public float getMediaClockRate(); + field @Deprecated public static final androidx.media2.player.MediaTimestamp TIMESTAMP_UNKNOWN; } - public final class PlaybackParams { - method public Integer? getAudioFallbackMode(); - method public Float? getPitch(); - method public Float? getSpeed(); - field public static final int AUDIO_FALLBACK_MODE_DEFAULT = 0; // 0x0 - field public static final int AUDIO_FALLBACK_MODE_FAIL = 2; // 0x2 - field public static final int AUDIO_FALLBACK_MODE_MUTE = 1; // 0x1 + @Deprecated public final class PlaybackParams { + method @Deprecated public Integer? getAudioFallbackMode(); + method @Deprecated public Float? getPitch(); + method @Deprecated public Float? getSpeed(); + field @Deprecated public static final int AUDIO_FALLBACK_MODE_DEFAULT = 0; // 0x0 + field @Deprecated public static final int AUDIO_FALLBACK_MODE_FAIL = 2; // 0x2 + field @Deprecated public static final int AUDIO_FALLBACK_MODE_MUTE = 1; // 0x1 } - public static final class PlaybackParams.Builder { - ctor public PlaybackParams.Builder(); - ctor public PlaybackParams.Builder(androidx.media2.player.PlaybackParams); - method public androidx.media2.player.PlaybackParams build(); - method public androidx.media2.player.PlaybackParams.Builder setAudioFallbackMode(int); - method public androidx.media2.player.PlaybackParams.Builder setPitch(@FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) float); - method public androidx.media2.player.PlaybackParams.Builder setSpeed(@FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) float); + @Deprecated public static final class PlaybackParams.Builder { + ctor @Deprecated public PlaybackParams.Builder(); + ctor @Deprecated public PlaybackParams.Builder(androidx.media2.player.PlaybackParams); + method @Deprecated public androidx.media2.player.PlaybackParams build(); + method @Deprecated public androidx.media2.player.PlaybackParams.Builder setAudioFallbackMode(int); + method @Deprecated public androidx.media2.player.PlaybackParams.Builder setPitch(@FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) float); + method @Deprecated public androidx.media2.player.PlaybackParams.Builder setSpeed(@FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) float); } - public class TimedMetaData { - method public byte[]! getMetaData(); - method public long getTimestamp(); + @Deprecated public class TimedMetaData { + method @Deprecated public byte[]! getMetaData(); + method @Deprecated public long getTimestamp(); } - public final class VideoSize extends androidx.media2.common.VideoSize { - ctor public VideoSize(int, int); + @Deprecated public final class VideoSize extends androidx.media2.common.VideoSize { + ctor @Deprecated public VideoSize(int, int); } } diff --git a/media2/media2-player/api/restricted_current.txt b/media2/media2-player/api/restricted_current.txt index 36c803e0ddc..c9996936bc7 100644 --- a/media2/media2-player/api/restricted_current.txt +++ b/media2/media2-player/api/restricted_current.txt @@ -1,122 +1,122 @@ // Signature format: 4.0 package androidx.media2.player { - public final class MediaPlayer extends androidx.media2.common.SessionPlayer { - ctor public MediaPlayer(android.content.Context); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> addPlaylistItem(int, androidx.media2.common.MediaItem); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> attachAuxEffect(int); - method public androidx.media.AudioAttributesCompat? getAudioAttributes(); - method public int getAudioSessionId(); - method public long getBufferedPosition(); - method public int getBufferingState(); - method public androidx.media2.common.MediaItem? getCurrentMediaItem(); - method public int getCurrentMediaItemIndex(); - method public long getCurrentPosition(); - method public long getDuration(); - method public float getMaxPlayerVolume(); - method public int getNextMediaItemIndex(); - method public androidx.media2.player.PlaybackParams getPlaybackParams(); - method @FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) public float getPlaybackSpeed(); - method public int getPlayerState(); - method public float getPlayerVolume(); - method public java.util.List<androidx.media2.common.MediaItem!>? getPlaylist(); - method public androidx.media2.common.MediaMetadata? getPlaylistMetadata(); - method public int getPreviousMediaItemIndex(); - method public int getRepeatMode(); - method public androidx.media2.player.MediaPlayer.TrackInfo? getSelectedTrack(int); - method public int getShuffleMode(); - method public androidx.media2.player.MediaTimestamp? getTimestamp(); + @Deprecated public final class MediaPlayer extends androidx.media2.common.SessionPlayer { + ctor @Deprecated public MediaPlayer(android.content.Context); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> addPlaylistItem(int, androidx.media2.common.MediaItem); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> attachAuxEffect(int); + method @Deprecated public androidx.media.AudioAttributesCompat? getAudioAttributes(); + method @Deprecated public int getAudioSessionId(); + method @Deprecated public long getBufferedPosition(); + method @Deprecated public int getBufferingState(); + method @Deprecated public androidx.media2.common.MediaItem? getCurrentMediaItem(); + method @Deprecated public int getCurrentMediaItemIndex(); + method @Deprecated public long getCurrentPosition(); + method @Deprecated public long getDuration(); + method @Deprecated public float getMaxPlayerVolume(); + method @Deprecated public int getNextMediaItemIndex(); + method @Deprecated public androidx.media2.player.PlaybackParams getPlaybackParams(); + method @Deprecated @FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) public float getPlaybackSpeed(); + method @Deprecated public int getPlayerState(); + method @Deprecated public float getPlayerVolume(); + method @Deprecated public java.util.List<androidx.media2.common.MediaItem!>? getPlaylist(); + method @Deprecated public androidx.media2.common.MediaMetadata? getPlaylistMetadata(); + method @Deprecated public int getPreviousMediaItemIndex(); + method @Deprecated public int getRepeatMode(); + method @Deprecated public androidx.media2.player.MediaPlayer.TrackInfo? getSelectedTrack(int); + method @Deprecated public int getShuffleMode(); + method @Deprecated public androidx.media2.player.MediaTimestamp? getTimestamp(); method @Deprecated public java.util.List<androidx.media2.player.MediaPlayer.TrackInfo!> getTrackInfo(); - method public androidx.media2.player.VideoSize getVideoSize(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> pause(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> play(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> prepare(); - method public void registerPlayerCallback(java.util.concurrent.Executor, androidx.media2.player.MediaPlayer.PlayerCallback); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> removePlaylistItem(@IntRange(from=0) int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> replacePlaylistItem(int, androidx.media2.common.MediaItem); - method public void reset(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> seekTo(long); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> seekTo(long, int); + method @Deprecated public androidx.media2.player.VideoSize getVideoSize(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> pause(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> play(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> prepare(); + method @Deprecated public void registerPlayerCallback(java.util.concurrent.Executor, androidx.media2.player.MediaPlayer.PlayerCallback); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> removePlaylistItem(@IntRange(from=0) int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> replacePlaylistItem(int, androidx.media2.common.MediaItem); + method @Deprecated public void reset(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> seekTo(long); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> seekTo(long, int); method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> selectTrack(androidx.media2.player.MediaPlayer.TrackInfo); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAudioAttributes(androidx.media.AudioAttributesCompat); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAudioSessionId(int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAuxEffectSendLevel(@FloatRange(from=0, to=1) float); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setMediaItem(androidx.media2.common.MediaItem); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaybackParams(androidx.media2.player.PlaybackParams); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaybackSpeed(@FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) float); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlayerVolume(@FloatRange(from=0, to=1) float); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaylist(java.util.List<androidx.media2.common.MediaItem!>, androidx.media2.common.MediaMetadata?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setRepeatMode(int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setShuffleMode(int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToNextPlaylistItem(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPlaylistItem(@IntRange(from=0) int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPreviousPlaylistItem(); - method public void unregisterPlayerCallback(androidx.media2.player.MediaPlayer.PlayerCallback); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> updatePlaylistMetadata(androidx.media2.common.MediaMetadata?); - field public static final int MEDIA_INFO_AUDIO_NOT_PLAYING = 804; // 0x324 - field public static final int MEDIA_INFO_BAD_INTERLEAVING = 800; // 0x320 - field public static final int MEDIA_INFO_BUFFERING_UPDATE = 704; // 0x2c0 - field public static final int MEDIA_INFO_METADATA_UPDATE = 802; // 0x322 - field public static final int MEDIA_INFO_NOT_SEEKABLE = 801; // 0x321 - field public static final int MEDIA_INFO_VIDEO_NOT_PLAYING = 805; // 0x325 - field public static final int MEDIA_INFO_VIDEO_RENDERING_START = 3; // 0x3 - field public static final int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700; // 0x2bc + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAudioAttributes(androidx.media.AudioAttributesCompat); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAudioSessionId(int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setAuxEffectSendLevel(@FloatRange(from=0, to=1) float); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setMediaItem(androidx.media2.common.MediaItem); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaybackParams(androidx.media2.player.PlaybackParams); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaybackSpeed(@FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) float); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlayerVolume(@FloatRange(from=0, to=1) float); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setPlaylist(java.util.List<androidx.media2.common.MediaItem!>, androidx.media2.common.MediaMetadata?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setRepeatMode(int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> setShuffleMode(int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToNextPlaylistItem(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPlaylistItem(@IntRange(from=0) int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> skipToPreviousPlaylistItem(); + method @Deprecated public void unregisterPlayerCallback(androidx.media2.player.MediaPlayer.PlayerCallback); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.common.SessionPlayer.PlayerResult!> updatePlaylistMetadata(androidx.media2.common.MediaMetadata?); + field @Deprecated public static final int MEDIA_INFO_AUDIO_NOT_PLAYING = 804; // 0x324 + field @Deprecated public static final int MEDIA_INFO_BAD_INTERLEAVING = 800; // 0x320 + field @Deprecated public static final int MEDIA_INFO_BUFFERING_UPDATE = 704; // 0x2c0 + field @Deprecated public static final int MEDIA_INFO_METADATA_UPDATE = 802; // 0x322 + field @Deprecated public static final int MEDIA_INFO_NOT_SEEKABLE = 801; // 0x321 + field @Deprecated public static final int MEDIA_INFO_VIDEO_NOT_PLAYING = 805; // 0x325 + field @Deprecated public static final int MEDIA_INFO_VIDEO_RENDERING_START = 3; // 0x3 + field @Deprecated public static final int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700; // 0x2bc field @Deprecated public static final int NO_TRACK_SELECTED = -2147483648; // 0x80000000 - field public static final int PLAYER_ERROR_IO = -1004; // 0xfffffc14 - field public static final int PLAYER_ERROR_MALFORMED = -1007; // 0xfffffc11 - field public static final int PLAYER_ERROR_TIMED_OUT = -110; // 0xffffff92 - field public static final int PLAYER_ERROR_UNKNOWN = 1; // 0x1 - field public static final int PLAYER_ERROR_UNSUPPORTED = -1010; // 0xfffffc0e - field public static final int SEEK_CLOSEST = 3; // 0x3 - field public static final int SEEK_CLOSEST_SYNC = 2; // 0x2 - field public static final int SEEK_NEXT_SYNC = 1; // 0x1 - field public static final int SEEK_PREVIOUS_SYNC = 0; // 0x0 + field @Deprecated public static final int PLAYER_ERROR_IO = -1004; // 0xfffffc14 + field @Deprecated public static final int PLAYER_ERROR_MALFORMED = -1007; // 0xfffffc11 + field @Deprecated public static final int PLAYER_ERROR_TIMED_OUT = -110; // 0xffffff92 + field @Deprecated public static final int PLAYER_ERROR_UNKNOWN = 1; // 0x1 + field @Deprecated public static final int PLAYER_ERROR_UNSUPPORTED = -1010; // 0xfffffc0e + field @Deprecated public static final int SEEK_CLOSEST = 3; // 0x3 + field @Deprecated public static final int SEEK_CLOSEST_SYNC = 2; // 0x2 + field @Deprecated public static final int SEEK_NEXT_SYNC = 1; // 0x1 + field @Deprecated public static final int SEEK_PREVIOUS_SYNC = 0; // 0x0 } - public abstract static class MediaPlayer.PlayerCallback extends androidx.media2.common.SessionPlayer.PlayerCallback { - ctor public MediaPlayer.PlayerCallback(); - method public void onError(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, int, int); - method public void onInfo(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, int, int); - method public void onMediaTimeDiscontinuity(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, androidx.media2.player.MediaTimestamp); - method public void onTimedMetaDataAvailable(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, androidx.media2.player.TimedMetaData); + @Deprecated public abstract static class MediaPlayer.PlayerCallback extends androidx.media2.common.SessionPlayer.PlayerCallback { + ctor @Deprecated public MediaPlayer.PlayerCallback(); + method @Deprecated public void onError(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, int, int); + method @Deprecated public void onInfo(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, int, int); + method @Deprecated public void onMediaTimeDiscontinuity(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, androidx.media2.player.MediaTimestamp); + method @Deprecated public void onTimedMetaDataAvailable(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, androidx.media2.player.TimedMetaData); method @Deprecated public void onVideoSizeChanged(androidx.media2.player.MediaPlayer, androidx.media2.common.MediaItem, androidx.media2.player.VideoSize); } - public static final class MediaPlayer.TrackInfo extends androidx.media2.common.SessionPlayer.TrackInfo { + @Deprecated public static final class MediaPlayer.TrackInfo extends androidx.media2.common.SessionPlayer.TrackInfo { } - public final class MediaTimestamp { - method public long getAnchorMediaTimeUs(); - method public long getAnchorSystemNanoTime(); - method public float getMediaClockRate(); - field public static final androidx.media2.player.MediaTimestamp TIMESTAMP_UNKNOWN; + @Deprecated public final class MediaTimestamp { + method @Deprecated public long getAnchorMediaTimeUs(); + method @Deprecated public long getAnchorSystemNanoTime(); + method @Deprecated public float getMediaClockRate(); + field @Deprecated public static final androidx.media2.player.MediaTimestamp TIMESTAMP_UNKNOWN; } - public final class PlaybackParams { - method public Integer? getAudioFallbackMode(); - method public Float? getPitch(); - method public Float? getSpeed(); - field public static final int AUDIO_FALLBACK_MODE_DEFAULT = 0; // 0x0 - field public static final int AUDIO_FALLBACK_MODE_FAIL = 2; // 0x2 - field public static final int AUDIO_FALLBACK_MODE_MUTE = 1; // 0x1 + @Deprecated public final class PlaybackParams { + method @Deprecated public Integer? getAudioFallbackMode(); + method @Deprecated public Float? getPitch(); + method @Deprecated public Float? getSpeed(); + field @Deprecated public static final int AUDIO_FALLBACK_MODE_DEFAULT = 0; // 0x0 + field @Deprecated public static final int AUDIO_FALLBACK_MODE_FAIL = 2; // 0x2 + field @Deprecated public static final int AUDIO_FALLBACK_MODE_MUTE = 1; // 0x1 } - public static final class PlaybackParams.Builder { - ctor public PlaybackParams.Builder(); - ctor public PlaybackParams.Builder(androidx.media2.player.PlaybackParams); - method public androidx.media2.player.PlaybackParams build(); - method public androidx.media2.player.PlaybackParams.Builder setAudioFallbackMode(int); - method public androidx.media2.player.PlaybackParams.Builder setPitch(@FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) float); - method public androidx.media2.player.PlaybackParams.Builder setSpeed(@FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) float); + @Deprecated public static final class PlaybackParams.Builder { + ctor @Deprecated public PlaybackParams.Builder(); + ctor @Deprecated public PlaybackParams.Builder(androidx.media2.player.PlaybackParams); + method @Deprecated public androidx.media2.player.PlaybackParams build(); + method @Deprecated public androidx.media2.player.PlaybackParams.Builder setAudioFallbackMode(int); + method @Deprecated public androidx.media2.player.PlaybackParams.Builder setPitch(@FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) float); + method @Deprecated public androidx.media2.player.PlaybackParams.Builder setSpeed(@FloatRange(from=0.0f, to=java.lang.Float.MAX_VALUE, fromInclusive=false) float); } - public class TimedMetaData { - method public byte[]! getMetaData(); - method public long getTimestamp(); + @Deprecated public class TimedMetaData { + method @Deprecated public byte[]! getMetaData(); + method @Deprecated public long getTimestamp(); } - public final class VideoSize extends androidx.media2.common.VideoSize { - ctor public VideoSize(int, int); + @Deprecated public final class VideoSize extends androidx.media2.common.VideoSize { + ctor @Deprecated public VideoSize(int, int); } } diff --git a/media2/media2-player/src/main/java/androidx/media2/player/MediaPlayer.java b/media2/media2-player/src/main/java/androidx/media2/player/MediaPlayer.java index d8f8fee120e..aaf3953f46f 100644 --- a/media2/media2-player/src/main/java/androidx/media2/player/MediaPlayer.java +++ b/media2/media2-player/src/main/java/androidx/media2/player/MediaPlayer.java @@ -76,19 +76,22 @@ import java.util.concurrent.Executors; /** * A media player which plays {@link MediaItem}s. The details on playback control and player states * can be found in the documentation of the base class, {@link SessionPlayer}. - * <p> - * Topic covered here: + * + * <p>Topic covered here: + * * <ol> - * <li><a href="#AudioFocusAndNoisyIntent">Audio focus and noisy intent</a> + * <li><a href="#AudioFocusAndNoisyIntent">Audio focus and noisy intent</a> * </ol> + * * <h3 id="AudioFocusAndNoisyIntent">Audio focus and noisy intent</h3> - * <p> - * By default, {@link MediaPlayer} handles audio focus and noisy intent with - * {@link AudioAttributesCompat} set to this player. You need to call - * {@link #setAudioAttributes(AudioAttributesCompat)} set the audio attribute while in the - * {@link #PLAYER_STATE_IDLE}. - * <p> - * Here's the table of automatic audio focus behavior with audio attributes. + * + * <p>By default, {@link MediaPlayer} handles audio focus and noisy intent with {@link + * AudioAttributesCompat} set to this player. You need to call {@link + * #setAudioAttributes(AudioAttributesCompat)} set the audio attribute while in the {@link + * #PLAYER_STATE_IDLE}. + * + * <p>Here's the table of automatic audio focus behavior with audio attributes. + * * <table summary="Audio focus handling overview"> * <tr><th>Audio Attributes</th><th>Audio Focus Gain Type</th><th>Misc</th></tr> * <tr><td>{@link AudioAttributesCompat#USAGE_VOICE_COMMUNICATION_SIGNALLING}</td> @@ -129,15 +132,20 @@ import java.util.concurrent.Executors; * <td>No audio focus handling, and sets the player volume to {@code 0}</td> * <td>This is to handle error</td></tr> * </table> + * + * <p>If an {@link AudioAttributesCompat} is not specified by {@link #setAudioAttributes}, {@link + * #getAudioAttributes} will return {@code null} and the default audio focus behavior will follow + * the {@code null} case on the table above. + * + * <p>For more information about the audio focus, take a look at <a + * href="{@docRoot}guide/topics/media-apps/audio-focus.html">Managing audio focus</a> + * * <p> - * If an {@link AudioAttributesCompat} is not specified by {@link #setAudioAttributes}, - * {@link #getAudioAttributes} will return {@code null} and the default audio focus behavior will - * follow the {@code null} case on the table above. - * <p> - * For more information about the audio focus, take a look at - * <a href="{@docRoot}guide/topics/media-apps/audio-focus.html">Managing audio focus</a> - * <p> + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public final class MediaPlayer extends SessionPlayer { private static final String TAG = "MediaPlayer"; @@ -3479,7 +3487,11 @@ public final class MediaPlayer extends SessionPlayer { /** * Interface definition for callbacks to be invoked when the player has the corresponding * events. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public abstract static class PlayerCallback extends SessionPlayer.PlayerCallback { /** * @deprecated Use @@ -3590,7 +3602,10 @@ public final class MediaPlayer extends SessionPlayer { * Class for the player to return each audio/video/subtitle track's metadata. * * @see #getTracks + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static final class TrackInfo extends SessionPlayer.TrackInfo { TrackInfo(SessionPlayer.TrackInfo infoInternal) { super(infoInternal.getId(), infoInternal.getTrackType(), infoInternal.getFormat(), diff --git a/media2/media2-player/src/main/java/androidx/media2/player/MediaTimestamp.java b/media2/media2-player/src/main/java/androidx/media2/player/MediaTimestamp.java index 890fc5328c6..f3485fdf1d5 100644 --- a/media2/media2-player/src/main/java/androidx/media2/player/MediaTimestamp.java +++ b/media2/media2-player/src/main/java/androidx/media2/player/MediaTimestamp.java @@ -19,22 +19,22 @@ package androidx.media2.player; import androidx.annotation.NonNull; /** - * An immutable object that represents the linear correlation between the media time - * and the system time. It contains the media clock rate, together with the media timestamp - * of an anchor frame and the system time when that frame was presented or is committed - * to be presented. - * <p> - * The phrase "present" means that audio/video produced on device is detectable by an external - * observer off device. - * The time is based on the implementation's best effort, using whatever knowledge - * is available to the system, but cannot account for any delay unknown to the implementation. - * The anchor frame could be any frame, including a just-rendered frame, or even a theoretical - * or in-between frame, based on the source of the MediaTimestamp. - * When the anchor frame is a just-rendered one, the media time stands for - * current position of the playback or recording. + * An immutable object that represents the linear correlation between the media time and the system + * time. It contains the media clock rate, together with the media timestamp of an anchor frame and + * the system time when that frame was presented or is committed to be presented. + * + * <p>The phrase "present" means that audio/video produced on device is detectable by an external + * observer off device. The time is based on the implementation's best effort, using whatever + * knowledge is available to the system, but cannot account for any delay unknown to the + * implementation. The anchor frame could be any frame, including a just-rendered frame, or even a + * theoretical or in-between frame, based on the source of the MediaTimestamp. When the anchor frame + * is a just-rendered one, the media time stands for current position of the playback or recording. * * @see MediaPlayer#getTimestamp + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public final class MediaTimestamp { /** * An unknown media timestamp value diff --git a/media2/media2-player/src/main/java/androidx/media2/player/PlaybackParams.java b/media2/media2-player/src/main/java/androidx/media2/player/PlaybackParams.java index 7f1be4ae8e7..b17f688006e 100644 --- a/media2/media2-player/src/main/java/androidx/media2/player/PlaybackParams.java +++ b/media2/media2-player/src/main/java/androidx/media2/player/PlaybackParams.java @@ -35,45 +35,49 @@ import java.lang.annotation.RetentionPolicy; /** * Structure for common playback params. * - * Used by {@link MediaPlayer} {@link MediaPlayer#getPlaybackParams()} and - * {@link MediaPlayer#setPlaybackParams(PlaybackParams)} - * to control playback behavior. - * <p> - * PlaybackParams returned by {@link MediaPlayer#getPlaybackParams()} will always have values. - * In case of {@link MediaPlayer#setPlaybackParams}, the player will not update the param if the - * value is not set. For example, if pitch is set while speed is not set, only pitch will be - * updated. - * <p> - * Note that the speed value does not change the player state. For example, if - * {@link MediaPlayer#getPlaybackParams()} is called with the speed of 2.0f in - * {@link MediaPlayer#PLAYER_STATE_PAUSED}, the player will just update internal property and stay - * paused. Once {@link MediaPlayer#play()} is called afterwards, the player will start - * playback with the given speed. Calling this with zero speed is not allowed. - * <p> - * <strong>audio fallback mode:</strong> select out-of-range parameter handling. + * <p>Used by {@link MediaPlayer} {@link MediaPlayer#getPlaybackParams()} and {@link + * MediaPlayer#setPlaybackParams(PlaybackParams)} to control playback behavior. + * + * <p>PlaybackParams returned by {@link MediaPlayer#getPlaybackParams()} will always have values. In + * case of {@link MediaPlayer#setPlaybackParams}, the player will not update the param if the value + * is not set. For example, if pitch is set while speed is not set, only pitch will be updated. + * + * <p>Note that the speed value does not change the player state. For example, if {@link + * MediaPlayer#getPlaybackParams()} is called with the speed of 2.0f in {@link + * MediaPlayer#PLAYER_STATE_PAUSED}, the player will just update internal property and stay paused. + * Once {@link MediaPlayer#play()} is called afterwards, the player will start playback with the + * given speed. Calling this with zero speed is not allowed. + * + * <p><strong>audio fallback mode:</strong> select out-of-range parameter handling. + * * <ul> - * <li> {@link PlaybackParams#AUDIO_FALLBACK_MODE_DEFAULT}: - * System will determine best handling. </li> - * <li> {@link PlaybackParams#AUDIO_FALLBACK_MODE_MUTE}: - * Play silence for params normally out of range.</li> - * <li> {@link PlaybackParams#AUDIO_FALLBACK_MODE_FAIL}: - * Return {@link java.lang.IllegalArgumentException} from - * <code>AudioTrack.setPlaybackParams(PlaybackParams)</code>.</li> + * <li>{@link PlaybackParams#AUDIO_FALLBACK_MODE_DEFAULT}: System will determine best handling. + * <li>{@link PlaybackParams#AUDIO_FALLBACK_MODE_MUTE}: Play silence for params normally out of + * range. + * <li>{@link PlaybackParams#AUDIO_FALLBACK_MODE_FAIL}: Return {@link + * java.lang.IllegalArgumentException} from <code>AudioTrack.setPlaybackParams(PlaybackParams) + * </code>. * </ul> - * <p> <strong>pitch:</strong> increases or decreases the tonal frequency of the audio content. - * It is expressed as a multiplicative factor, where normal pitch is 1.0f. - * <p> <strong>speed:</strong> increases or decreases the time to - * play back a set of audio or video frames. - * It is expressed as a multiplicative factor, where normal speed is 1.0f. - * <p> Different combinations of speed and pitch may be used for audio playback; - * some common ones: + * + * <p><strong>pitch:</strong> increases or decreases the tonal frequency of the audio content. It is + * expressed as a multiplicative factor, where normal pitch is 1.0f. + * + * <p><strong>speed:</strong> increases or decreases the time to play back a set of audio or video + * frames. It is expressed as a multiplicative factor, where normal speed is 1.0f. + * + * <p>Different combinations of speed and pitch may be used for audio playback; some common ones: + * * <ul> - * <li> <em>Pitch equals 1.0f.</em> Speed change will be done with pitch preserved, - * often called <em>timestretching</em>.</li> - * <li> <em>Pitch equals speed.</em> Speed change will be done by <em>resampling</em>, - * similar to {@link AudioTrack#setPlaybackRate(int)}.</li> + * <li><em>Pitch equals 1.0f.</em> Speed change will be done with pitch preserved, often called + * <em>timestretching</em>. + * <li><em>Pitch equals speed.</em> Speed change will be done by <em>resampling</em>, similar to + * {@link AudioTrack#setPlaybackRate(int)}. * </ul> + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public final class PlaybackParams { @RestrictTo(LIBRARY) @IntDef( @@ -172,7 +176,11 @@ public final class PlaybackParams { /** * The builder class that makes it easy to chain setters to create a {@link PlaybackParams} * object. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static final class Builder { private Integer mAudioFallbackMode; private Float mPitch; diff --git a/media2/media2-player/src/main/java/androidx/media2/player/TimedMetaData.java b/media2/media2-player/src/main/java/androidx/media2/player/TimedMetaData.java index d3317507ecf..fbf3ffd1290 100644 --- a/media2/media2-player/src/main/java/androidx/media2/player/TimedMetaData.java +++ b/media2/media2-player/src/main/java/androidx/media2/player/TimedMetaData.java @@ -24,12 +24,15 @@ import androidx.annotation.RestrictTo; * Class that embodies one timed metadata access unit, including * * <ul> - * <li> a time stamp, and </li> - * <li> raw uninterpreted byte-array extracted directly from the container. </li> + * <li>a time stamp, and + * <li>raw uninterpreted byte-array extracted directly from the container. * </ul> * * @see MediaPlayer.PlayerCallback#onTimedMetaDataAvailable + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public class TimedMetaData { private static final String TAG = "TimedMetaData"; diff --git a/media2/media2-player/src/main/java/androidx/media2/player/VideoSize.java b/media2/media2-player/src/main/java/androidx/media2/player/VideoSize.java index d469c13cb37..5aa2b31a32e 100644 --- a/media2/media2-player/src/main/java/androidx/media2/player/VideoSize.java +++ b/media2/media2-player/src/main/java/androidx/media2/player/VideoSize.java @@ -20,7 +20,11 @@ import androidx.annotation.NonNull; /** * Immutable class for describing video size. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public final class VideoSize extends androidx.media2.common.VideoSize { VideoSize(@NonNull androidx.media2.common.VideoSize internal) { super(internal.getWidth(), internal.getHeight()); diff --git a/media2/media2-session/api/current.txt b/media2/media2-session/api/current.txt index 95e39e3c6d3..2855a884b78 100644 --- a/media2/media2-session/api/current.txt +++ b/media2/media2-session/api/current.txt @@ -1,22 +1,22 @@ // Signature format: 4.0 package androidx.media2.session { - public final class HeartRating implements androidx.media2.common.Rating { - ctor public HeartRating(); - ctor public HeartRating(boolean); - method public boolean hasHeart(); - method public boolean isRated(); - } - - public class LibraryResult implements androidx.versionedparcelable.VersionedParcelable { - ctor public LibraryResult(int); - ctor public LibraryResult(int, androidx.media2.common.MediaItem?, androidx.media2.session.MediaLibraryService.LibraryParams?); - ctor public LibraryResult(int, java.util.List<androidx.media2.common.MediaItem!>?, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public long getCompletionTime(); - method public androidx.media2.session.MediaLibraryService.LibraryParams? getLibraryParams(); - method public androidx.media2.common.MediaItem? getMediaItem(); - method public java.util.List<androidx.media2.common.MediaItem!>? getMediaItems(); - method public int getResultCode(); + @Deprecated public final class HeartRating implements androidx.media2.common.Rating { + ctor @Deprecated public HeartRating(); + ctor @Deprecated public HeartRating(boolean); + method @Deprecated public boolean hasHeart(); + method @Deprecated public boolean isRated(); + } + + @Deprecated public class LibraryResult implements androidx.versionedparcelable.VersionedParcelable { + ctor @Deprecated public LibraryResult(int); + ctor @Deprecated public LibraryResult(int, androidx.media2.common.MediaItem?, androidx.media2.session.MediaLibraryService.LibraryParams?); + ctor @Deprecated public LibraryResult(int, java.util.List<androidx.media2.common.MediaItem!>?, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public long getCompletionTime(); + method @Deprecated public androidx.media2.session.MediaLibraryService.LibraryParams? getLibraryParams(); + method @Deprecated public androidx.media2.common.MediaItem? getMediaItem(); + method @Deprecated public java.util.List<androidx.media2.common.MediaItem!>? getMediaItems(); + method @Deprecated public int getResultCode(); field public static final int RESULT_ERROR_BAD_VALUE = -3; // 0xfffffffd field public static final int RESULT_ERROR_INVALID_STATE = -2; // 0xfffffffe field public static final int RESULT_ERROR_IO = -5; // 0xfffffffb @@ -35,371 +35,371 @@ package androidx.media2.session { field public static final int RESULT_SUCCESS = 0; // 0x0 } - public class MediaBrowser extends androidx.media2.session.MediaController { - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getChildren(String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getItem(String); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getLibraryRoot(androidx.media2.session.MediaLibraryService.LibraryParams?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getSearchResult(String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> search(String, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> subscribe(String, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> unsubscribe(String); - } - - public static class MediaBrowser.BrowserCallback extends androidx.media2.session.MediaController.ControllerCallback { - ctor public MediaBrowser.BrowserCallback(); - method public void onChildrenChanged(androidx.media2.session.MediaBrowser, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public void onSearchResultChanged(androidx.media2.session.MediaBrowser, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - } - - public static final class MediaBrowser.Builder { - ctor public MediaBrowser.Builder(android.content.Context); - method public androidx.media2.session.MediaBrowser build(); - method public androidx.media2.session.MediaBrowser.Builder setConnectionHints(android.os.Bundle); - method public androidx.media2.session.MediaBrowser.Builder setControllerCallback(java.util.concurrent.Executor, androidx.media2.session.MediaBrowser.BrowserCallback); - method public androidx.media2.session.MediaBrowser.Builder setSessionCompatToken(android.support.v4.media.session.MediaSessionCompat.Token); - method public androidx.media2.session.MediaBrowser.Builder setSessionToken(androidx.media2.session.SessionToken); - } - - public class MediaConstants { - field public static final String MEDIA_URI_AUTHORITY = "media2-session"; - field public static final String MEDIA_URI_PATH_PLAY_FROM_MEDIA_ID = "playFromMediaId"; - field public static final String MEDIA_URI_PATH_PLAY_FROM_SEARCH = "playFromSearch"; - field public static final String MEDIA_URI_PATH_PREPARE_FROM_MEDIA_ID = "prepareFromMediaId"; - field public static final String MEDIA_URI_PATH_PREPARE_FROM_SEARCH = "prepareFromSearch"; - field public static final String MEDIA_URI_PATH_SET_MEDIA_URI = "setMediaUri"; - field public static final String MEDIA_URI_QUERY_ID = "id"; - field public static final String MEDIA_URI_QUERY_QUERY = "query"; - field public static final String MEDIA_URI_QUERY_URI = "uri"; - field public static final String MEDIA_URI_SCHEME = "androidx"; - } - - public class MediaController implements java.io.Closeable { - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> addPlaylistItem(@IntRange(from=0) int, String); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> adjustVolume(int, int); - method public void close(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> deselectTrack(androidx.media2.common.SessionPlayer.TrackInfo); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> fastForward(); - method public androidx.media2.session.SessionCommandGroup? getAllowedCommands(); - method public long getBufferedPosition(); - method public int getBufferingState(); - method public androidx.media2.session.SessionToken? getConnectedToken(); - method public androidx.media2.common.MediaItem? getCurrentMediaItem(); - method public int getCurrentMediaItemIndex(); - method public long getCurrentPosition(); - method public long getDuration(); - method public int getNextMediaItemIndex(); - method public androidx.media2.session.MediaController.PlaybackInfo? getPlaybackInfo(); - method public float getPlaybackSpeed(); - method public int getPlayerState(); - method public java.util.List<androidx.media2.common.MediaItem!>? getPlaylist(); - method public androidx.media2.common.MediaMetadata? getPlaylistMetadata(); - method public int getPreviousMediaItemIndex(); - method public int getRepeatMode(); - method public androidx.media2.common.SessionPlayer.TrackInfo? getSelectedTrack(int); - method public android.app.PendingIntent? getSessionActivity(); - method public int getShuffleMode(); - method public java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!> getTracks(); - method public androidx.media2.common.VideoSize getVideoSize(); - method public boolean isConnected(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> movePlaylistItem(@IntRange(from=0) int, @IntRange(from=0) int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> pause(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> play(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> prepare(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> removePlaylistItem(@IntRange(from=0) int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> replacePlaylistItem(@IntRange(from=0) int, String); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> rewind(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> seekTo(long); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> selectTrack(androidx.media2.common.SessionPlayer.TrackInfo); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> sendCustomCommand(androidx.media2.session.SessionCommand, android.os.Bundle?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setMediaItem(String); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setMediaUri(android.net.Uri, android.os.Bundle?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setPlaybackSpeed(float); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setPlaylist(java.util.List<java.lang.String!>, androidx.media2.common.MediaMetadata?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setRating(String, androidx.media2.common.Rating); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setRepeatMode(int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setShuffleMode(int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setSurface(android.view.Surface?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setVolumeTo(int, int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipBackward(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipForward(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipToNextPlaylistItem(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipToPlaylistItem(@IntRange(from=0) int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipToPreviousPlaylistItem(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> updatePlaylistMetadata(androidx.media2.common.MediaMetadata?); - } - - public static final class MediaController.Builder { - ctor public MediaController.Builder(android.content.Context); - method public androidx.media2.session.MediaController build(); - method public androidx.media2.session.MediaController.Builder setConnectionHints(android.os.Bundle); - method public androidx.media2.session.MediaController.Builder setControllerCallback(java.util.concurrent.Executor, androidx.media2.session.MediaController.ControllerCallback); - method public androidx.media2.session.MediaController.Builder setSessionCompatToken(android.support.v4.media.session.MediaSessionCompat.Token); - method public androidx.media2.session.MediaController.Builder setSessionToken(androidx.media2.session.SessionToken); - } - - public abstract static class MediaController.ControllerCallback { - ctor public MediaController.ControllerCallback(); - method public void onAllowedCommandsChanged(androidx.media2.session.MediaController, androidx.media2.session.SessionCommandGroup); - method public void onBufferingStateChanged(androidx.media2.session.MediaController, androidx.media2.common.MediaItem, int); - method public void onConnected(androidx.media2.session.MediaController, androidx.media2.session.SessionCommandGroup); - method public void onCurrentMediaItemChanged(androidx.media2.session.MediaController, androidx.media2.common.MediaItem?); - method public androidx.media2.session.SessionResult onCustomCommand(androidx.media2.session.MediaController, androidx.media2.session.SessionCommand, android.os.Bundle?); - method public void onDisconnected(androidx.media2.session.MediaController); - method public void onPlaybackCompleted(androidx.media2.session.MediaController); - method public void onPlaybackInfoChanged(androidx.media2.session.MediaController, androidx.media2.session.MediaController.PlaybackInfo); - method public void onPlaybackSpeedChanged(androidx.media2.session.MediaController, float); - method public void onPlayerStateChanged(androidx.media2.session.MediaController, int); - method public void onPlaylistChanged(androidx.media2.session.MediaController, java.util.List<androidx.media2.common.MediaItem!>?, androidx.media2.common.MediaMetadata?); - method public void onPlaylistMetadataChanged(androidx.media2.session.MediaController, androidx.media2.common.MediaMetadata?); - method public void onRepeatModeChanged(androidx.media2.session.MediaController, int); - method public void onSeekCompleted(androidx.media2.session.MediaController, long); - method public int onSetCustomLayout(androidx.media2.session.MediaController, java.util.List<androidx.media2.session.MediaSession.CommandButton!>); - method public void onShuffleModeChanged(androidx.media2.session.MediaController, int); - method public void onSubtitleData(androidx.media2.session.MediaController, androidx.media2.common.MediaItem, androidx.media2.common.SessionPlayer.TrackInfo, androidx.media2.common.SubtitleData); - method public void onTrackDeselected(androidx.media2.session.MediaController, androidx.media2.common.SessionPlayer.TrackInfo); - method public void onTrackSelected(androidx.media2.session.MediaController, androidx.media2.common.SessionPlayer.TrackInfo); - method public void onTracksChanged(androidx.media2.session.MediaController, java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!>); - method public void onVideoSizeChanged(androidx.media2.session.MediaController, androidx.media2.common.VideoSize); - } - - public static final class MediaController.PlaybackInfo implements androidx.versionedparcelable.VersionedParcelable { - method public androidx.media.AudioAttributesCompat? getAudioAttributes(); - method public int getControlType(); - method public int getCurrentVolume(); - method public int getMaxVolume(); - method public int getPlaybackType(); - field public static final int PLAYBACK_TYPE_LOCAL = 1; // 0x1 - field public static final int PLAYBACK_TYPE_REMOTE = 2; // 0x2 - } - - public abstract class MediaLibraryService extends androidx.media2.session.MediaSessionService { - ctor public MediaLibraryService(); - method public abstract androidx.media2.session.MediaLibraryService.MediaLibrarySession? onGetSession(androidx.media2.session.MediaSession.ControllerInfo); - field public static final String SERVICE_INTERFACE = "androidx.media2.session.MediaLibraryService"; - } - - public static final class MediaLibraryService.LibraryParams implements androidx.versionedparcelable.VersionedParcelable { - method public android.os.Bundle? getExtras(); - method public boolean isOffline(); - method public boolean isRecent(); - method public boolean isSuggested(); - } - - public static final class MediaLibraryService.LibraryParams.Builder { - ctor public MediaLibraryService.LibraryParams.Builder(); - method public androidx.media2.session.MediaLibraryService.LibraryParams build(); - method public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setExtras(android.os.Bundle?); - method public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setOffline(boolean); - method public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setRecent(boolean); - method public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setSuggested(boolean); - } - - public static final class MediaLibraryService.MediaLibrarySession extends androidx.media2.session.MediaSession { - method public void notifyChildrenChanged(androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public void notifyChildrenChanged(String, int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public void notifySearchResultChanged(androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - } - - public static final class MediaLibraryService.MediaLibrarySession.Builder { - ctor public MediaLibraryService.MediaLibrarySession.Builder(androidx.media2.session.MediaLibraryService, androidx.media2.common.SessionPlayer, java.util.concurrent.Executor, androidx.media2.session.MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback); - method public androidx.media2.session.MediaLibraryService.MediaLibrarySession build(); - method public androidx.media2.session.MediaLibraryService.MediaLibrarySession.Builder setExtras(android.os.Bundle); - method public androidx.media2.session.MediaLibraryService.MediaLibrarySession.Builder setId(String); - method public androidx.media2.session.MediaLibraryService.MediaLibrarySession.Builder setSessionActivity(android.app.PendingIntent?); - } - - public static class MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback extends androidx.media2.session.MediaSession.SessionCallback { - ctor public MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback(); - method public androidx.media2.session.LibraryResult onGetChildren(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public androidx.media2.session.LibraryResult onGetItem(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String); - method public androidx.media2.session.LibraryResult onGetLibraryRoot(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public androidx.media2.session.LibraryResult onGetSearchResult(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public int onSearch(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public int onSubscribe(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public int onUnsubscribe(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String); - } - - public class MediaSession implements java.io.Closeable { - method public void broadcastCustomCommand(androidx.media2.session.SessionCommand, android.os.Bundle?); - method public void close(); - method public java.util.List<androidx.media2.session.MediaSession.ControllerInfo!> getConnectedControllers(); - method public String getId(); - method public androidx.media2.common.SessionPlayer getPlayer(); - method public android.support.v4.media.session.MediaSessionCompat.Token getSessionCompatToken(); - method public androidx.media2.session.SessionToken getToken(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> sendCustomCommand(androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommand, android.os.Bundle?); - method public void setAllowedCommands(androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommandGroup); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setCustomLayout(androidx.media2.session.MediaSession.ControllerInfo, java.util.List<androidx.media2.session.MediaSession.CommandButton!>); - method public void updatePlayer(androidx.media2.common.SessionPlayer); - } - - public static final class MediaSession.Builder { - ctor public MediaSession.Builder(android.content.Context, androidx.media2.common.SessionPlayer); - method public androidx.media2.session.MediaSession build(); - method public androidx.media2.session.MediaSession.Builder setExtras(android.os.Bundle); - method public androidx.media2.session.MediaSession.Builder setId(String); - method public androidx.media2.session.MediaSession.Builder setSessionActivity(android.app.PendingIntent?); - method public androidx.media2.session.MediaSession.Builder setSessionCallback(java.util.concurrent.Executor, androidx.media2.session.MediaSession.SessionCallback); - } - - public static final class MediaSession.CommandButton implements androidx.versionedparcelable.VersionedParcelable { - method public androidx.media2.session.SessionCommand? getCommand(); - method public CharSequence? getDisplayName(); - method public android.os.Bundle? getExtras(); - method public int getIconResId(); - method public boolean isEnabled(); - } - - public static final class MediaSession.CommandButton.Builder { - ctor public MediaSession.CommandButton.Builder(); - method public androidx.media2.session.MediaSession.CommandButton build(); - method public androidx.media2.session.MediaSession.CommandButton.Builder setCommand(androidx.media2.session.SessionCommand?); - method public androidx.media2.session.MediaSession.CommandButton.Builder setDisplayName(CharSequence?); - method public androidx.media2.session.MediaSession.CommandButton.Builder setEnabled(boolean); - method public androidx.media2.session.MediaSession.CommandButton.Builder setExtras(android.os.Bundle?); - method public androidx.media2.session.MediaSession.CommandButton.Builder setIconResId(int); - } - - public static final class MediaSession.ControllerInfo { - method public android.os.Bundle getConnectionHints(); - method public String getPackageName(); - method public int getUid(); - } - - public abstract static class MediaSession.SessionCallback { - ctor public MediaSession.SessionCallback(); - method public int onCommandRequest(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommand); - method public androidx.media2.session.SessionCommandGroup? onConnect(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - method public androidx.media2.common.MediaItem? onCreateMediaItem(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, String); - method public androidx.media2.session.SessionResult onCustomCommand(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommand, android.os.Bundle?); - method public void onDisconnected(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - method public int onFastForward(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - method public void onPostConnect(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - method public int onRewind(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - method public int onSetMediaUri(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, android.net.Uri, android.os.Bundle?); - method public int onSetRating(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, String, androidx.media2.common.Rating); - method public int onSkipBackward(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - method public int onSkipForward(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - } - - public final class MediaSessionManager { - method public static androidx.media2.session.MediaSessionManager getInstance(android.content.Context); - method public java.util.Set<androidx.media2.session.SessionToken!> getSessionServiceTokens(); - } - - public abstract class MediaSessionService extends android.app.Service { - ctor public MediaSessionService(); - method public final void addSession(androidx.media2.session.MediaSession); - method public final java.util.List<androidx.media2.session.MediaSession!> getSessions(); - method @CallSuper public android.os.IBinder? onBind(android.content.Intent); - method public abstract androidx.media2.session.MediaSession? onGetSession(androidx.media2.session.MediaSession.ControllerInfo); - method public androidx.media2.session.MediaSessionService.MediaNotification? onUpdateNotification(androidx.media2.session.MediaSession); - method public final void removeSession(androidx.media2.session.MediaSession); - field public static final String SERVICE_INTERFACE = "androidx.media2.session.MediaSessionService"; - } - - public static class MediaSessionService.MediaNotification { - ctor public MediaSessionService.MediaNotification(int, android.app.Notification); - method public android.app.Notification getNotification(); - method public int getNotificationId(); - } - - public final class PercentageRating implements androidx.media2.common.Rating { - ctor public PercentageRating(); - ctor public PercentageRating(float); - method public float getPercentRating(); - method public boolean isRated(); - } - - public abstract class RemoteSessionPlayer extends androidx.media2.common.SessionPlayer { - ctor public RemoteSessionPlayer(); - method public abstract java.util.concurrent.Future<androidx.media2.common.SessionPlayer.PlayerResult!> adjustVolume(int); - method public abstract int getMaxVolume(); - method public abstract int getVolume(); - method public abstract int getVolumeControlType(); - method public abstract java.util.concurrent.Future<androidx.media2.common.SessionPlayer.PlayerResult!> setVolume(int); - field public static final int VOLUME_CONTROL_ABSOLUTE = 2; // 0x2 - field public static final int VOLUME_CONTROL_FIXED = 0; // 0x0 - field public static final int VOLUME_CONTROL_RELATIVE = 1; // 0x1 - } - - public static class RemoteSessionPlayer.Callback extends androidx.media2.common.SessionPlayer.PlayerCallback { - ctor public RemoteSessionPlayer.Callback(); - method public void onVolumeChanged(androidx.media2.session.RemoteSessionPlayer, int); - } - - public final class SessionCommand implements androidx.versionedparcelable.VersionedParcelable { - ctor public SessionCommand(int); - ctor public SessionCommand(String, android.os.Bundle?); - method public int getCommandCode(); - method public String? getCustomAction(); - method public android.os.Bundle? getCustomExtras(); - field public static final int COMMAND_CODE_CUSTOM = 0; // 0x0 - field public static final int COMMAND_CODE_LIBRARY_GET_CHILDREN = 50003; // 0xc353 - field public static final int COMMAND_CODE_LIBRARY_GET_ITEM = 50004; // 0xc354 - field public static final int COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT = 50000; // 0xc350 - field public static final int COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT = 50006; // 0xc356 - field public static final int COMMAND_CODE_LIBRARY_SEARCH = 50005; // 0xc355 - field public static final int COMMAND_CODE_LIBRARY_SUBSCRIBE = 50001; // 0xc351 - field public static final int COMMAND_CODE_LIBRARY_UNSUBSCRIBE = 50002; // 0xc352 - field public static final int COMMAND_CODE_PLAYER_ADD_PLAYLIST_ITEM = 10013; // 0x271d - field public static final int COMMAND_CODE_PLAYER_DESELECT_TRACK = 11002; // 0x2afa - field public static final int COMMAND_CODE_PLAYER_GET_CURRENT_MEDIA_ITEM = 10016; // 0x2720 - field public static final int COMMAND_CODE_PLAYER_GET_PLAYLIST = 10005; // 0x2715 - field public static final int COMMAND_CODE_PLAYER_GET_PLAYLIST_METADATA = 10012; // 0x271c - field public static final int COMMAND_CODE_PLAYER_MOVE_PLAYLIST_ITEM = 10019; // 0x2723 - field public static final int COMMAND_CODE_PLAYER_PAUSE = 10001; // 0x2711 - field public static final int COMMAND_CODE_PLAYER_PLAY = 10000; // 0x2710 - field public static final int COMMAND_CODE_PLAYER_PREPARE = 10002; // 0x2712 - field public static final int COMMAND_CODE_PLAYER_REMOVE_PLAYLIST_ITEM = 10014; // 0x271e - field public static final int COMMAND_CODE_PLAYER_REPLACE_PLAYLIST_ITEM = 10015; // 0x271f - field public static final int COMMAND_CODE_PLAYER_SEEK_TO = 10003; // 0x2713 - field public static final int COMMAND_CODE_PLAYER_SELECT_TRACK = 11001; // 0x2af9 - field public static final int COMMAND_CODE_PLAYER_SET_MEDIA_ITEM = 10018; // 0x2722 - field public static final int COMMAND_CODE_PLAYER_SET_PLAYLIST = 10006; // 0x2716 - field public static final int COMMAND_CODE_PLAYER_SET_REPEAT_MODE = 10011; // 0x271b - field public static final int COMMAND_CODE_PLAYER_SET_SHUFFLE_MODE = 10010; // 0x271a - field public static final int COMMAND_CODE_PLAYER_SET_SPEED = 10004; // 0x2714 - field public static final int COMMAND_CODE_PLAYER_SET_SURFACE = 11000; // 0x2af8 - field public static final int COMMAND_CODE_PLAYER_SKIP_TO_NEXT_PLAYLIST_ITEM = 10009; // 0x2719 - field public static final int COMMAND_CODE_PLAYER_SKIP_TO_PLAYLIST_ITEM = 10007; // 0x2717 - field public static final int COMMAND_CODE_PLAYER_SKIP_TO_PREVIOUS_PLAYLIST_ITEM = 10008; // 0x2718 - field public static final int COMMAND_CODE_PLAYER_UPDATE_LIST_METADATA = 10017; // 0x2721 - field public static final int COMMAND_CODE_SESSION_FAST_FORWARD = 40000; // 0x9c40 - field public static final int COMMAND_CODE_SESSION_REWIND = 40001; // 0x9c41 - field public static final int COMMAND_CODE_SESSION_SET_MEDIA_URI = 40011; // 0x9c4b - field public static final int COMMAND_CODE_SESSION_SET_RATING = 40010; // 0x9c4a - field public static final int COMMAND_CODE_SESSION_SKIP_BACKWARD = 40003; // 0x9c43 - field public static final int COMMAND_CODE_SESSION_SKIP_FORWARD = 40002; // 0x9c42 - field public static final int COMMAND_CODE_VOLUME_ADJUST_VOLUME = 30001; // 0x7531 - field public static final int COMMAND_CODE_VOLUME_SET_VOLUME = 30000; // 0x7530 - field public static final int COMMAND_VERSION_1 = 1; // 0x1 - field public static final int COMMAND_VERSION_2 = 2; // 0x2 - } - - public final class SessionCommandGroup implements androidx.versionedparcelable.VersionedParcelable { - ctor public SessionCommandGroup(); - ctor public SessionCommandGroup(java.util.Collection<androidx.media2.session.SessionCommand!>?); - method public java.util.Set<androidx.media2.session.SessionCommand!> getCommands(); - method public boolean hasCommand(androidx.media2.session.SessionCommand); - method public boolean hasCommand(int); - } - - public static final class SessionCommandGroup.Builder { - ctor public SessionCommandGroup.Builder(); - ctor public SessionCommandGroup.Builder(androidx.media2.session.SessionCommandGroup); - method public androidx.media2.session.SessionCommandGroup.Builder addAllPredefinedCommands(int); - method public androidx.media2.session.SessionCommandGroup.Builder addCommand(androidx.media2.session.SessionCommand); - method public androidx.media2.session.SessionCommandGroup build(); - method public androidx.media2.session.SessionCommandGroup.Builder removeCommand(androidx.media2.session.SessionCommand); - } - - public class SessionResult implements androidx.versionedparcelable.VersionedParcelable { - ctor public SessionResult(int, android.os.Bundle?); - method public long getCompletionTime(); - method public android.os.Bundle? getCustomCommandResult(); - method public androidx.media2.common.MediaItem? getMediaItem(); - method public int getResultCode(); + @Deprecated public class MediaBrowser extends androidx.media2.session.MediaController { + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getChildren(String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getItem(String); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getLibraryRoot(androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getSearchResult(String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> search(String, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> subscribe(String, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> unsubscribe(String); + } + + @Deprecated public static class MediaBrowser.BrowserCallback extends androidx.media2.session.MediaController.ControllerCallback { + ctor @Deprecated public MediaBrowser.BrowserCallback(); + method @Deprecated public void onChildrenChanged(androidx.media2.session.MediaBrowser, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public void onSearchResultChanged(androidx.media2.session.MediaBrowser, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + } + + @Deprecated public static final class MediaBrowser.Builder { + ctor @Deprecated public MediaBrowser.Builder(android.content.Context); + method @Deprecated public androidx.media2.session.MediaBrowser build(); + method @Deprecated public androidx.media2.session.MediaBrowser.Builder setConnectionHints(android.os.Bundle); + method @Deprecated public androidx.media2.session.MediaBrowser.Builder setControllerCallback(java.util.concurrent.Executor, androidx.media2.session.MediaBrowser.BrowserCallback); + method @Deprecated public androidx.media2.session.MediaBrowser.Builder setSessionCompatToken(android.support.v4.media.session.MediaSessionCompat.Token); + method @Deprecated public androidx.media2.session.MediaBrowser.Builder setSessionToken(androidx.media2.session.SessionToken); + } + + @Deprecated public class MediaConstants { + field @Deprecated public static final String MEDIA_URI_AUTHORITY = "media2-session"; + field @Deprecated public static final String MEDIA_URI_PATH_PLAY_FROM_MEDIA_ID = "playFromMediaId"; + field @Deprecated public static final String MEDIA_URI_PATH_PLAY_FROM_SEARCH = "playFromSearch"; + field @Deprecated public static final String MEDIA_URI_PATH_PREPARE_FROM_MEDIA_ID = "prepareFromMediaId"; + field @Deprecated public static final String MEDIA_URI_PATH_PREPARE_FROM_SEARCH = "prepareFromSearch"; + field @Deprecated public static final String MEDIA_URI_PATH_SET_MEDIA_URI = "setMediaUri"; + field @Deprecated public static final String MEDIA_URI_QUERY_ID = "id"; + field @Deprecated public static final String MEDIA_URI_QUERY_QUERY = "query"; + field @Deprecated public static final String MEDIA_URI_QUERY_URI = "uri"; + field @Deprecated public static final String MEDIA_URI_SCHEME = "androidx"; + } + + @Deprecated public class MediaController implements java.io.Closeable { + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> addPlaylistItem(@IntRange(from=0) int, String); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> adjustVolume(int, int); + method @Deprecated public void close(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> deselectTrack(androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> fastForward(); + method @Deprecated public androidx.media2.session.SessionCommandGroup? getAllowedCommands(); + method @Deprecated public long getBufferedPosition(); + method @Deprecated public int getBufferingState(); + method @Deprecated public androidx.media2.session.SessionToken? getConnectedToken(); + method @Deprecated public androidx.media2.common.MediaItem? getCurrentMediaItem(); + method @Deprecated public int getCurrentMediaItemIndex(); + method @Deprecated public long getCurrentPosition(); + method @Deprecated public long getDuration(); + method @Deprecated public int getNextMediaItemIndex(); + method @Deprecated public androidx.media2.session.MediaController.PlaybackInfo? getPlaybackInfo(); + method @Deprecated public float getPlaybackSpeed(); + method @Deprecated public int getPlayerState(); + method @Deprecated public java.util.List<androidx.media2.common.MediaItem!>? getPlaylist(); + method @Deprecated public androidx.media2.common.MediaMetadata? getPlaylistMetadata(); + method @Deprecated public int getPreviousMediaItemIndex(); + method @Deprecated public int getRepeatMode(); + method @Deprecated public androidx.media2.common.SessionPlayer.TrackInfo? getSelectedTrack(int); + method @Deprecated public android.app.PendingIntent? getSessionActivity(); + method @Deprecated public int getShuffleMode(); + method @Deprecated public java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!> getTracks(); + method @Deprecated public androidx.media2.common.VideoSize getVideoSize(); + method @Deprecated public boolean isConnected(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> movePlaylistItem(@IntRange(from=0) int, @IntRange(from=0) int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> pause(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> play(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> prepare(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> removePlaylistItem(@IntRange(from=0) int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> replacePlaylistItem(@IntRange(from=0) int, String); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> rewind(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> seekTo(long); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> selectTrack(androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> sendCustomCommand(androidx.media2.session.SessionCommand, android.os.Bundle?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setMediaItem(String); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setMediaUri(android.net.Uri, android.os.Bundle?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setPlaybackSpeed(float); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setPlaylist(java.util.List<java.lang.String!>, androidx.media2.common.MediaMetadata?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setRating(String, androidx.media2.common.Rating); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setRepeatMode(int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setShuffleMode(int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setSurface(android.view.Surface?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setVolumeTo(int, int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipBackward(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipForward(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipToNextPlaylistItem(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipToPlaylistItem(@IntRange(from=0) int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipToPreviousPlaylistItem(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> updatePlaylistMetadata(androidx.media2.common.MediaMetadata?); + } + + @Deprecated public static final class MediaController.Builder { + ctor @Deprecated public MediaController.Builder(android.content.Context); + method @Deprecated public androidx.media2.session.MediaController build(); + method @Deprecated public androidx.media2.session.MediaController.Builder setConnectionHints(android.os.Bundle); + method @Deprecated public androidx.media2.session.MediaController.Builder setControllerCallback(java.util.concurrent.Executor, androidx.media2.session.MediaController.ControllerCallback); + method @Deprecated public androidx.media2.session.MediaController.Builder setSessionCompatToken(android.support.v4.media.session.MediaSessionCompat.Token); + method @Deprecated public androidx.media2.session.MediaController.Builder setSessionToken(androidx.media2.session.SessionToken); + } + + @Deprecated public abstract static class MediaController.ControllerCallback { + ctor @Deprecated public MediaController.ControllerCallback(); + method @Deprecated public void onAllowedCommandsChanged(androidx.media2.session.MediaController, androidx.media2.session.SessionCommandGroup); + method @Deprecated public void onBufferingStateChanged(androidx.media2.session.MediaController, androidx.media2.common.MediaItem, int); + method @Deprecated public void onConnected(androidx.media2.session.MediaController, androidx.media2.session.SessionCommandGroup); + method @Deprecated public void onCurrentMediaItemChanged(androidx.media2.session.MediaController, androidx.media2.common.MediaItem?); + method @Deprecated public androidx.media2.session.SessionResult onCustomCommand(androidx.media2.session.MediaController, androidx.media2.session.SessionCommand, android.os.Bundle?); + method @Deprecated public void onDisconnected(androidx.media2.session.MediaController); + method @Deprecated public void onPlaybackCompleted(androidx.media2.session.MediaController); + method @Deprecated public void onPlaybackInfoChanged(androidx.media2.session.MediaController, androidx.media2.session.MediaController.PlaybackInfo); + method @Deprecated public void onPlaybackSpeedChanged(androidx.media2.session.MediaController, float); + method @Deprecated public void onPlayerStateChanged(androidx.media2.session.MediaController, int); + method @Deprecated public void onPlaylistChanged(androidx.media2.session.MediaController, java.util.List<androidx.media2.common.MediaItem!>?, androidx.media2.common.MediaMetadata?); + method @Deprecated public void onPlaylistMetadataChanged(androidx.media2.session.MediaController, androidx.media2.common.MediaMetadata?); + method @Deprecated public void onRepeatModeChanged(androidx.media2.session.MediaController, int); + method @Deprecated public void onSeekCompleted(androidx.media2.session.MediaController, long); + method @Deprecated public int onSetCustomLayout(androidx.media2.session.MediaController, java.util.List<androidx.media2.session.MediaSession.CommandButton!>); + method @Deprecated public void onShuffleModeChanged(androidx.media2.session.MediaController, int); + method @Deprecated public void onSubtitleData(androidx.media2.session.MediaController, androidx.media2.common.MediaItem, androidx.media2.common.SessionPlayer.TrackInfo, androidx.media2.common.SubtitleData); + method @Deprecated public void onTrackDeselected(androidx.media2.session.MediaController, androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public void onTrackSelected(androidx.media2.session.MediaController, androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public void onTracksChanged(androidx.media2.session.MediaController, java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!>); + method @Deprecated public void onVideoSizeChanged(androidx.media2.session.MediaController, androidx.media2.common.VideoSize); + } + + @Deprecated public static final class MediaController.PlaybackInfo implements androidx.versionedparcelable.VersionedParcelable { + method @Deprecated public androidx.media.AudioAttributesCompat? getAudioAttributes(); + method @Deprecated public int getControlType(); + method @Deprecated public int getCurrentVolume(); + method @Deprecated public int getMaxVolume(); + method @Deprecated public int getPlaybackType(); + field @Deprecated public static final int PLAYBACK_TYPE_LOCAL = 1; // 0x1 + field @Deprecated public static final int PLAYBACK_TYPE_REMOTE = 2; // 0x2 + } + + @Deprecated public abstract class MediaLibraryService extends androidx.media2.session.MediaSessionService { + ctor @Deprecated public MediaLibraryService(); + method @Deprecated public abstract androidx.media2.session.MediaLibraryService.MediaLibrarySession? onGetSession(androidx.media2.session.MediaSession.ControllerInfo); + field @Deprecated public static final String SERVICE_INTERFACE = "androidx.media2.session.MediaLibraryService"; + } + + @Deprecated public static final class MediaLibraryService.LibraryParams implements androidx.versionedparcelable.VersionedParcelable { + method @Deprecated public android.os.Bundle? getExtras(); + method @Deprecated public boolean isOffline(); + method @Deprecated public boolean isRecent(); + method @Deprecated public boolean isSuggested(); + } + + @Deprecated public static final class MediaLibraryService.LibraryParams.Builder { + ctor @Deprecated public MediaLibraryService.LibraryParams.Builder(); + method @Deprecated public androidx.media2.session.MediaLibraryService.LibraryParams build(); + method @Deprecated public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setExtras(android.os.Bundle?); + method @Deprecated public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setOffline(boolean); + method @Deprecated public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setRecent(boolean); + method @Deprecated public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setSuggested(boolean); + } + + @Deprecated public static final class MediaLibraryService.MediaLibrarySession extends androidx.media2.session.MediaSession { + method @Deprecated public void notifyChildrenChanged(androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public void notifyChildrenChanged(String, int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public void notifySearchResultChanged(androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + } + + @Deprecated public static final class MediaLibraryService.MediaLibrarySession.Builder { + ctor @Deprecated public MediaLibraryService.MediaLibrarySession.Builder(androidx.media2.session.MediaLibraryService, androidx.media2.common.SessionPlayer, java.util.concurrent.Executor, androidx.media2.session.MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback); + method @Deprecated public androidx.media2.session.MediaLibraryService.MediaLibrarySession build(); + method @Deprecated public androidx.media2.session.MediaLibraryService.MediaLibrarySession.Builder setExtras(android.os.Bundle); + method @Deprecated public androidx.media2.session.MediaLibraryService.MediaLibrarySession.Builder setId(String); + method @Deprecated public androidx.media2.session.MediaLibraryService.MediaLibrarySession.Builder setSessionActivity(android.app.PendingIntent?); + } + + @Deprecated public static class MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback extends androidx.media2.session.MediaSession.SessionCallback { + ctor @Deprecated public MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback(); + method @Deprecated public androidx.media2.session.LibraryResult onGetChildren(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public androidx.media2.session.LibraryResult onGetItem(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String); + method @Deprecated public androidx.media2.session.LibraryResult onGetLibraryRoot(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public androidx.media2.session.LibraryResult onGetSearchResult(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public int onSearch(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public int onSubscribe(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public int onUnsubscribe(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String); + } + + @Deprecated public class MediaSession implements java.io.Closeable { + method @Deprecated public void broadcastCustomCommand(androidx.media2.session.SessionCommand, android.os.Bundle?); + method @Deprecated public void close(); + method @Deprecated public java.util.List<androidx.media2.session.MediaSession.ControllerInfo!> getConnectedControllers(); + method @Deprecated public String getId(); + method @Deprecated public androidx.media2.common.SessionPlayer getPlayer(); + method @Deprecated public android.support.v4.media.session.MediaSessionCompat.Token getSessionCompatToken(); + method @Deprecated public androidx.media2.session.SessionToken getToken(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> sendCustomCommand(androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommand, android.os.Bundle?); + method @Deprecated public void setAllowedCommands(androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommandGroup); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setCustomLayout(androidx.media2.session.MediaSession.ControllerInfo, java.util.List<androidx.media2.session.MediaSession.CommandButton!>); + method @Deprecated public void updatePlayer(androidx.media2.common.SessionPlayer); + } + + @Deprecated public static final class MediaSession.Builder { + ctor @Deprecated public MediaSession.Builder(android.content.Context, androidx.media2.common.SessionPlayer); + method @Deprecated public androidx.media2.session.MediaSession build(); + method @Deprecated public androidx.media2.session.MediaSession.Builder setExtras(android.os.Bundle); + method @Deprecated public androidx.media2.session.MediaSession.Builder setId(String); + method @Deprecated public androidx.media2.session.MediaSession.Builder setSessionActivity(android.app.PendingIntent?); + method @Deprecated public androidx.media2.session.MediaSession.Builder setSessionCallback(java.util.concurrent.Executor, androidx.media2.session.MediaSession.SessionCallback); + } + + @Deprecated public static final class MediaSession.CommandButton implements androidx.versionedparcelable.VersionedParcelable { + method @Deprecated public androidx.media2.session.SessionCommand? getCommand(); + method @Deprecated public CharSequence? getDisplayName(); + method @Deprecated public android.os.Bundle? getExtras(); + method @Deprecated public int getIconResId(); + method @Deprecated public boolean isEnabled(); + } + + @Deprecated public static final class MediaSession.CommandButton.Builder { + ctor @Deprecated public MediaSession.CommandButton.Builder(); + method @Deprecated public androidx.media2.session.MediaSession.CommandButton build(); + method @Deprecated public androidx.media2.session.MediaSession.CommandButton.Builder setCommand(androidx.media2.session.SessionCommand?); + method @Deprecated public androidx.media2.session.MediaSession.CommandButton.Builder setDisplayName(CharSequence?); + method @Deprecated public androidx.media2.session.MediaSession.CommandButton.Builder setEnabled(boolean); + method @Deprecated public androidx.media2.session.MediaSession.CommandButton.Builder setExtras(android.os.Bundle?); + method @Deprecated public androidx.media2.session.MediaSession.CommandButton.Builder setIconResId(int); + } + + @Deprecated public static final class MediaSession.ControllerInfo { + method @Deprecated public android.os.Bundle getConnectionHints(); + method @Deprecated public String getPackageName(); + method @Deprecated public int getUid(); + } + + @Deprecated public abstract static class MediaSession.SessionCallback { + ctor @Deprecated public MediaSession.SessionCallback(); + method @Deprecated public int onCommandRequest(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommand); + method @Deprecated public androidx.media2.session.SessionCommandGroup? onConnect(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public androidx.media2.common.MediaItem? onCreateMediaItem(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, String); + method @Deprecated public androidx.media2.session.SessionResult onCustomCommand(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommand, android.os.Bundle?); + method @Deprecated public void onDisconnected(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public int onFastForward(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public void onPostConnect(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public int onRewind(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public int onSetMediaUri(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, android.net.Uri, android.os.Bundle?); + method @Deprecated public int onSetRating(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, String, androidx.media2.common.Rating); + method @Deprecated public int onSkipBackward(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public int onSkipForward(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + } + + @Deprecated public final class MediaSessionManager { + method @Deprecated public static androidx.media2.session.MediaSessionManager getInstance(android.content.Context); + method @Deprecated public java.util.Set<androidx.media2.session.SessionToken!> getSessionServiceTokens(); + } + + @Deprecated public abstract class MediaSessionService extends android.app.Service { + ctor @Deprecated public MediaSessionService(); + method @Deprecated public final void addSession(androidx.media2.session.MediaSession); + method @Deprecated public final java.util.List<androidx.media2.session.MediaSession!> getSessions(); + method @Deprecated @CallSuper public android.os.IBinder? onBind(android.content.Intent); + method @Deprecated public abstract androidx.media2.session.MediaSession? onGetSession(androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public androidx.media2.session.MediaSessionService.MediaNotification? onUpdateNotification(androidx.media2.session.MediaSession); + method @Deprecated public final void removeSession(androidx.media2.session.MediaSession); + field @Deprecated public static final String SERVICE_INTERFACE = "androidx.media2.session.MediaSessionService"; + } + + @Deprecated public static class MediaSessionService.MediaNotification { + ctor @Deprecated public MediaSessionService.MediaNotification(int, android.app.Notification); + method @Deprecated public android.app.Notification getNotification(); + method @Deprecated public int getNotificationId(); + } + + @Deprecated public final class PercentageRating implements androidx.media2.common.Rating { + ctor @Deprecated public PercentageRating(); + ctor @Deprecated public PercentageRating(float); + method @Deprecated public float getPercentRating(); + method @Deprecated public boolean isRated(); + } + + @Deprecated public abstract class RemoteSessionPlayer extends androidx.media2.common.SessionPlayer { + ctor @Deprecated public RemoteSessionPlayer(); + method @Deprecated public abstract java.util.concurrent.Future<androidx.media2.common.SessionPlayer.PlayerResult!> adjustVolume(int); + method @Deprecated public abstract int getMaxVolume(); + method @Deprecated public abstract int getVolume(); + method @Deprecated public abstract int getVolumeControlType(); + method @Deprecated public abstract java.util.concurrent.Future<androidx.media2.common.SessionPlayer.PlayerResult!> setVolume(int); + field @Deprecated public static final int VOLUME_CONTROL_ABSOLUTE = 2; // 0x2 + field @Deprecated public static final int VOLUME_CONTROL_FIXED = 0; // 0x0 + field @Deprecated public static final int VOLUME_CONTROL_RELATIVE = 1; // 0x1 + } + + @Deprecated public static class RemoteSessionPlayer.Callback extends androidx.media2.common.SessionPlayer.PlayerCallback { + ctor @Deprecated public RemoteSessionPlayer.Callback(); + method @Deprecated public void onVolumeChanged(androidx.media2.session.RemoteSessionPlayer, int); + } + + @Deprecated public final class SessionCommand implements androidx.versionedparcelable.VersionedParcelable { + ctor @Deprecated public SessionCommand(int); + ctor @Deprecated public SessionCommand(String, android.os.Bundle?); + method @Deprecated public int getCommandCode(); + method @Deprecated public String? getCustomAction(); + method @Deprecated public android.os.Bundle? getCustomExtras(); + field @Deprecated public static final int COMMAND_CODE_CUSTOM = 0; // 0x0 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_GET_CHILDREN = 50003; // 0xc353 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_GET_ITEM = 50004; // 0xc354 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT = 50000; // 0xc350 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT = 50006; // 0xc356 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_SEARCH = 50005; // 0xc355 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_SUBSCRIBE = 50001; // 0xc351 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_UNSUBSCRIBE = 50002; // 0xc352 + field @Deprecated public static final int COMMAND_CODE_PLAYER_ADD_PLAYLIST_ITEM = 10013; // 0x271d + field @Deprecated public static final int COMMAND_CODE_PLAYER_DESELECT_TRACK = 11002; // 0x2afa + field @Deprecated public static final int COMMAND_CODE_PLAYER_GET_CURRENT_MEDIA_ITEM = 10016; // 0x2720 + field @Deprecated public static final int COMMAND_CODE_PLAYER_GET_PLAYLIST = 10005; // 0x2715 + field @Deprecated public static final int COMMAND_CODE_PLAYER_GET_PLAYLIST_METADATA = 10012; // 0x271c + field @Deprecated public static final int COMMAND_CODE_PLAYER_MOVE_PLAYLIST_ITEM = 10019; // 0x2723 + field @Deprecated public static final int COMMAND_CODE_PLAYER_PAUSE = 10001; // 0x2711 + field @Deprecated public static final int COMMAND_CODE_PLAYER_PLAY = 10000; // 0x2710 + field @Deprecated public static final int COMMAND_CODE_PLAYER_PREPARE = 10002; // 0x2712 + field @Deprecated public static final int COMMAND_CODE_PLAYER_REMOVE_PLAYLIST_ITEM = 10014; // 0x271e + field @Deprecated public static final int COMMAND_CODE_PLAYER_REPLACE_PLAYLIST_ITEM = 10015; // 0x271f + field @Deprecated public static final int COMMAND_CODE_PLAYER_SEEK_TO = 10003; // 0x2713 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SELECT_TRACK = 11001; // 0x2af9 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SET_MEDIA_ITEM = 10018; // 0x2722 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SET_PLAYLIST = 10006; // 0x2716 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SET_REPEAT_MODE = 10011; // 0x271b + field @Deprecated public static final int COMMAND_CODE_PLAYER_SET_SHUFFLE_MODE = 10010; // 0x271a + field @Deprecated public static final int COMMAND_CODE_PLAYER_SET_SPEED = 10004; // 0x2714 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SET_SURFACE = 11000; // 0x2af8 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SKIP_TO_NEXT_PLAYLIST_ITEM = 10009; // 0x2719 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SKIP_TO_PLAYLIST_ITEM = 10007; // 0x2717 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SKIP_TO_PREVIOUS_PLAYLIST_ITEM = 10008; // 0x2718 + field @Deprecated public static final int COMMAND_CODE_PLAYER_UPDATE_LIST_METADATA = 10017; // 0x2721 + field @Deprecated public static final int COMMAND_CODE_SESSION_FAST_FORWARD = 40000; // 0x9c40 + field @Deprecated public static final int COMMAND_CODE_SESSION_REWIND = 40001; // 0x9c41 + field @Deprecated public static final int COMMAND_CODE_SESSION_SET_MEDIA_URI = 40011; // 0x9c4b + field @Deprecated public static final int COMMAND_CODE_SESSION_SET_RATING = 40010; // 0x9c4a + field @Deprecated public static final int COMMAND_CODE_SESSION_SKIP_BACKWARD = 40003; // 0x9c43 + field @Deprecated public static final int COMMAND_CODE_SESSION_SKIP_FORWARD = 40002; // 0x9c42 + field @Deprecated public static final int COMMAND_CODE_VOLUME_ADJUST_VOLUME = 30001; // 0x7531 + field @Deprecated public static final int COMMAND_CODE_VOLUME_SET_VOLUME = 30000; // 0x7530 + field @Deprecated public static final int COMMAND_VERSION_1 = 1; // 0x1 + field @Deprecated public static final int COMMAND_VERSION_2 = 2; // 0x2 + } + + @Deprecated public final class SessionCommandGroup implements androidx.versionedparcelable.VersionedParcelable { + ctor @Deprecated public SessionCommandGroup(); + ctor @Deprecated public SessionCommandGroup(java.util.Collection<androidx.media2.session.SessionCommand!>?); + method @Deprecated public java.util.Set<androidx.media2.session.SessionCommand!> getCommands(); + method @Deprecated public boolean hasCommand(androidx.media2.session.SessionCommand); + method @Deprecated public boolean hasCommand(int); + } + + @Deprecated public static final class SessionCommandGroup.Builder { + ctor @Deprecated public SessionCommandGroup.Builder(); + ctor @Deprecated public SessionCommandGroup.Builder(androidx.media2.session.SessionCommandGroup); + method @Deprecated public androidx.media2.session.SessionCommandGroup.Builder addAllPredefinedCommands(int); + method @Deprecated public androidx.media2.session.SessionCommandGroup.Builder addCommand(androidx.media2.session.SessionCommand); + method @Deprecated public androidx.media2.session.SessionCommandGroup build(); + method @Deprecated public androidx.media2.session.SessionCommandGroup.Builder removeCommand(androidx.media2.session.SessionCommand); + } + + @Deprecated public class SessionResult implements androidx.versionedparcelable.VersionedParcelable { + ctor @Deprecated public SessionResult(int, android.os.Bundle?); + method @Deprecated public long getCompletionTime(); + method @Deprecated public android.os.Bundle? getCustomCommandResult(); + method @Deprecated public androidx.media2.common.MediaItem? getMediaItem(); + method @Deprecated public int getResultCode(); field public static final int RESULT_ERROR_BAD_VALUE = -3; // 0xfffffffd field public static final int RESULT_ERROR_INVALID_STATE = -2; // 0xfffffffe field public static final int RESULT_ERROR_IO = -5; // 0xfffffffb @@ -415,34 +415,34 @@ package androidx.media2.session { field public static final int RESULT_ERROR_SESSION_SKIP_LIMIT_REACHED = -107; // 0xffffff95 field public static final int RESULT_ERROR_UNKNOWN = -1; // 0xffffffff field public static final int RESULT_INFO_SKIPPED = 1; // 0x1 - field public static final int RESULT_SUCCESS = 0; // 0x0 - } - - public final class SessionToken implements androidx.versionedparcelable.VersionedParcelable { - ctor public SessionToken(android.content.Context, android.content.ComponentName); - method public android.os.Bundle getExtras(); - method public String getPackageName(); - method public String? getServiceName(); - method public int getType(); - method public int getUid(); - field public static final int TYPE_LIBRARY_SERVICE = 2; // 0x2 - field public static final int TYPE_SESSION = 0; // 0x0 - field public static final int TYPE_SESSION_SERVICE = 1; // 0x1 - } - - public final class StarRating implements androidx.media2.common.Rating { - ctor public StarRating(@IntRange(from=1) int); - ctor public StarRating(@IntRange(from=1) int, float); - method public int getMaxStars(); - method public float getStarRating(); - method public boolean isRated(); - } - - public final class ThumbRating implements androidx.media2.common.Rating { - ctor public ThumbRating(); - ctor public ThumbRating(boolean); - method public boolean isRated(); - method public boolean isThumbUp(); + field @Deprecated public static final int RESULT_SUCCESS = 0; // 0x0 + } + + @Deprecated public final class SessionToken implements androidx.versionedparcelable.VersionedParcelable { + ctor @Deprecated public SessionToken(android.content.Context, android.content.ComponentName); + method @Deprecated public android.os.Bundle getExtras(); + method @Deprecated public String getPackageName(); + method @Deprecated public String? getServiceName(); + method @Deprecated public int getType(); + method @Deprecated public int getUid(); + field @Deprecated public static final int TYPE_LIBRARY_SERVICE = 2; // 0x2 + field @Deprecated public static final int TYPE_SESSION = 0; // 0x0 + field @Deprecated public static final int TYPE_SESSION_SERVICE = 1; // 0x1 + } + + @Deprecated public final class StarRating implements androidx.media2.common.Rating { + ctor @Deprecated public StarRating(@IntRange(from=1) int); + ctor @Deprecated public StarRating(@IntRange(from=1) int, float); + method @Deprecated public int getMaxStars(); + method @Deprecated public float getStarRating(); + method @Deprecated public boolean isRated(); + } + + @Deprecated public final class ThumbRating implements androidx.media2.common.Rating { + ctor @Deprecated public ThumbRating(); + ctor @Deprecated public ThumbRating(boolean); + method @Deprecated public boolean isRated(); + method @Deprecated public boolean isThumbUp(); } } diff --git a/media2/media2-session/api/restricted_current.txt b/media2/media2-session/api/restricted_current.txt index 283a20125ec..a7e3a862c55 100644 --- a/media2/media2-session/api/restricted_current.txt +++ b/media2/media2-session/api/restricted_current.txt @@ -1,22 +1,22 @@ // Signature format: 4.0 package androidx.media2.session { - @androidx.versionedparcelable.VersionedParcelize public final class HeartRating implements androidx.media2.common.Rating { - ctor public HeartRating(); - ctor public HeartRating(boolean); - method public boolean hasHeart(); - method public boolean isRated(); - } - - @androidx.versionedparcelable.VersionedParcelize(isCustom=true) public class LibraryResult extends androidx.versionedparcelable.CustomVersionedParcelable { - ctor public LibraryResult(int); - ctor public LibraryResult(int, androidx.media2.common.MediaItem?, androidx.media2.session.MediaLibraryService.LibraryParams?); - ctor public LibraryResult(int, java.util.List<androidx.media2.common.MediaItem!>?, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public long getCompletionTime(); - method public androidx.media2.session.MediaLibraryService.LibraryParams? getLibraryParams(); - method public androidx.media2.common.MediaItem? getMediaItem(); - method public java.util.List<androidx.media2.common.MediaItem!>? getMediaItems(); - method public int getResultCode(); + @Deprecated @androidx.versionedparcelable.VersionedParcelize public final class HeartRating implements androidx.media2.common.Rating { + ctor @Deprecated public HeartRating(); + ctor @Deprecated public HeartRating(boolean); + method @Deprecated public boolean hasHeart(); + method @Deprecated public boolean isRated(); + } + + @Deprecated @androidx.versionedparcelable.VersionedParcelize(isCustom=true) public class LibraryResult extends androidx.versionedparcelable.CustomVersionedParcelable { + ctor @Deprecated public LibraryResult(int); + ctor @Deprecated public LibraryResult(int, androidx.media2.common.MediaItem?, androidx.media2.session.MediaLibraryService.LibraryParams?); + ctor @Deprecated public LibraryResult(int, java.util.List<androidx.media2.common.MediaItem!>?, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public long getCompletionTime(); + method @Deprecated public androidx.media2.session.MediaLibraryService.LibraryParams? getLibraryParams(); + method @Deprecated public androidx.media2.common.MediaItem? getMediaItem(); + method @Deprecated public java.util.List<androidx.media2.common.MediaItem!>? getMediaItems(); + method @Deprecated public int getResultCode(); field public static final int RESULT_ERROR_BAD_VALUE = -3; // 0xfffffffd field public static final int RESULT_ERROR_INVALID_STATE = -2; // 0xfffffffe field public static final int RESULT_ERROR_IO = -5; // 0xfffffffb @@ -35,371 +35,371 @@ package androidx.media2.session { field public static final int RESULT_SUCCESS = 0; // 0x0 } - public class MediaBrowser extends androidx.media2.session.MediaController { - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getChildren(String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getItem(String); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getLibraryRoot(androidx.media2.session.MediaLibraryService.LibraryParams?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getSearchResult(String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> search(String, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> subscribe(String, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> unsubscribe(String); - } - - public static class MediaBrowser.BrowserCallback extends androidx.media2.session.MediaController.ControllerCallback { - ctor public MediaBrowser.BrowserCallback(); - method public void onChildrenChanged(androidx.media2.session.MediaBrowser, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public void onSearchResultChanged(androidx.media2.session.MediaBrowser, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - } - - public static final class MediaBrowser.Builder { - ctor public MediaBrowser.Builder(android.content.Context); - method public androidx.media2.session.MediaBrowser build(); - method public androidx.media2.session.MediaBrowser.Builder setConnectionHints(android.os.Bundle); - method public androidx.media2.session.MediaBrowser.Builder setControllerCallback(java.util.concurrent.Executor, androidx.media2.session.MediaBrowser.BrowserCallback); - method public androidx.media2.session.MediaBrowser.Builder setSessionCompatToken(android.support.v4.media.session.MediaSessionCompat.Token); - method public androidx.media2.session.MediaBrowser.Builder setSessionToken(androidx.media2.session.SessionToken); - } - - public class MediaConstants { - field public static final String MEDIA_URI_AUTHORITY = "media2-session"; - field public static final String MEDIA_URI_PATH_PLAY_FROM_MEDIA_ID = "playFromMediaId"; - field public static final String MEDIA_URI_PATH_PLAY_FROM_SEARCH = "playFromSearch"; - field public static final String MEDIA_URI_PATH_PREPARE_FROM_MEDIA_ID = "prepareFromMediaId"; - field public static final String MEDIA_URI_PATH_PREPARE_FROM_SEARCH = "prepareFromSearch"; - field public static final String MEDIA_URI_PATH_SET_MEDIA_URI = "setMediaUri"; - field public static final String MEDIA_URI_QUERY_ID = "id"; - field public static final String MEDIA_URI_QUERY_QUERY = "query"; - field public static final String MEDIA_URI_QUERY_URI = "uri"; - field public static final String MEDIA_URI_SCHEME = "androidx"; - } - - public class MediaController implements java.io.Closeable { - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> addPlaylistItem(@IntRange(from=0) int, String); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> adjustVolume(int, int); - method public void close(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> deselectTrack(androidx.media2.common.SessionPlayer.TrackInfo); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> fastForward(); - method public androidx.media2.session.SessionCommandGroup? getAllowedCommands(); - method public long getBufferedPosition(); - method public int getBufferingState(); - method public androidx.media2.session.SessionToken? getConnectedToken(); - method public androidx.media2.common.MediaItem? getCurrentMediaItem(); - method public int getCurrentMediaItemIndex(); - method public long getCurrentPosition(); - method public long getDuration(); - method public int getNextMediaItemIndex(); - method public androidx.media2.session.MediaController.PlaybackInfo? getPlaybackInfo(); - method public float getPlaybackSpeed(); - method public int getPlayerState(); - method public java.util.List<androidx.media2.common.MediaItem!>? getPlaylist(); - method public androidx.media2.common.MediaMetadata? getPlaylistMetadata(); - method public int getPreviousMediaItemIndex(); - method public int getRepeatMode(); - method public androidx.media2.common.SessionPlayer.TrackInfo? getSelectedTrack(int); - method public android.app.PendingIntent? getSessionActivity(); - method public int getShuffleMode(); - method public java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!> getTracks(); - method public androidx.media2.common.VideoSize getVideoSize(); - method public boolean isConnected(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> movePlaylistItem(@IntRange(from=0) int, @IntRange(from=0) int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> pause(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> play(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> prepare(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> removePlaylistItem(@IntRange(from=0) int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> replacePlaylistItem(@IntRange(from=0) int, String); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> rewind(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> seekTo(long); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> selectTrack(androidx.media2.common.SessionPlayer.TrackInfo); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> sendCustomCommand(androidx.media2.session.SessionCommand, android.os.Bundle?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setMediaItem(String); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setMediaUri(android.net.Uri, android.os.Bundle?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setPlaybackSpeed(float); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setPlaylist(java.util.List<java.lang.String!>, androidx.media2.common.MediaMetadata?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setRating(String, androidx.media2.common.Rating); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setRepeatMode(int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setShuffleMode(int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setSurface(android.view.Surface?); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setVolumeTo(int, int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipBackward(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipForward(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipToNextPlaylistItem(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipToPlaylistItem(@IntRange(from=0) int); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipToPreviousPlaylistItem(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> updatePlaylistMetadata(androidx.media2.common.MediaMetadata?); - } - - public static final class MediaController.Builder { - ctor public MediaController.Builder(android.content.Context); - method public androidx.media2.session.MediaController build(); - method public androidx.media2.session.MediaController.Builder setConnectionHints(android.os.Bundle); - method public androidx.media2.session.MediaController.Builder setControllerCallback(java.util.concurrent.Executor, androidx.media2.session.MediaController.ControllerCallback); - method public androidx.media2.session.MediaController.Builder setSessionCompatToken(android.support.v4.media.session.MediaSessionCompat.Token); - method public androidx.media2.session.MediaController.Builder setSessionToken(androidx.media2.session.SessionToken); - } - - public abstract static class MediaController.ControllerCallback { - ctor public MediaController.ControllerCallback(); - method public void onAllowedCommandsChanged(androidx.media2.session.MediaController, androidx.media2.session.SessionCommandGroup); - method public void onBufferingStateChanged(androidx.media2.session.MediaController, androidx.media2.common.MediaItem, int); - method public void onConnected(androidx.media2.session.MediaController, androidx.media2.session.SessionCommandGroup); - method public void onCurrentMediaItemChanged(androidx.media2.session.MediaController, androidx.media2.common.MediaItem?); - method public androidx.media2.session.SessionResult onCustomCommand(androidx.media2.session.MediaController, androidx.media2.session.SessionCommand, android.os.Bundle?); - method public void onDisconnected(androidx.media2.session.MediaController); - method public void onPlaybackCompleted(androidx.media2.session.MediaController); - method public void onPlaybackInfoChanged(androidx.media2.session.MediaController, androidx.media2.session.MediaController.PlaybackInfo); - method public void onPlaybackSpeedChanged(androidx.media2.session.MediaController, float); - method public void onPlayerStateChanged(androidx.media2.session.MediaController, int); - method public void onPlaylistChanged(androidx.media2.session.MediaController, java.util.List<androidx.media2.common.MediaItem!>?, androidx.media2.common.MediaMetadata?); - method public void onPlaylistMetadataChanged(androidx.media2.session.MediaController, androidx.media2.common.MediaMetadata?); - method public void onRepeatModeChanged(androidx.media2.session.MediaController, int); - method public void onSeekCompleted(androidx.media2.session.MediaController, long); - method public int onSetCustomLayout(androidx.media2.session.MediaController, java.util.List<androidx.media2.session.MediaSession.CommandButton!>); - method public void onShuffleModeChanged(androidx.media2.session.MediaController, int); - method public void onSubtitleData(androidx.media2.session.MediaController, androidx.media2.common.MediaItem, androidx.media2.common.SessionPlayer.TrackInfo, androidx.media2.common.SubtitleData); - method public void onTrackDeselected(androidx.media2.session.MediaController, androidx.media2.common.SessionPlayer.TrackInfo); - method public void onTrackSelected(androidx.media2.session.MediaController, androidx.media2.common.SessionPlayer.TrackInfo); - method public void onTracksChanged(androidx.media2.session.MediaController, java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!>); - method public void onVideoSizeChanged(androidx.media2.session.MediaController, androidx.media2.common.VideoSize); - } - - @androidx.versionedparcelable.VersionedParcelize public static final class MediaController.PlaybackInfo implements androidx.versionedparcelable.VersionedParcelable { - method public androidx.media.AudioAttributesCompat? getAudioAttributes(); - method public int getControlType(); - method public int getCurrentVolume(); - method public int getMaxVolume(); - method public int getPlaybackType(); - field public static final int PLAYBACK_TYPE_LOCAL = 1; // 0x1 - field public static final int PLAYBACK_TYPE_REMOTE = 2; // 0x2 - } - - public abstract class MediaLibraryService extends androidx.media2.session.MediaSessionService { - ctor public MediaLibraryService(); - method public abstract androidx.media2.session.MediaLibraryService.MediaLibrarySession? onGetSession(androidx.media2.session.MediaSession.ControllerInfo); - field public static final String SERVICE_INTERFACE = "androidx.media2.session.MediaLibraryService"; - } - - @androidx.versionedparcelable.VersionedParcelize public static final class MediaLibraryService.LibraryParams implements androidx.versionedparcelable.VersionedParcelable { - method public android.os.Bundle? getExtras(); - method public boolean isOffline(); - method public boolean isRecent(); - method public boolean isSuggested(); - } - - public static final class MediaLibraryService.LibraryParams.Builder { - ctor public MediaLibraryService.LibraryParams.Builder(); - method public androidx.media2.session.MediaLibraryService.LibraryParams build(); - method public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setExtras(android.os.Bundle?); - method public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setOffline(boolean); - method public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setRecent(boolean); - method public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setSuggested(boolean); - } - - public static final class MediaLibraryService.MediaLibrarySession extends androidx.media2.session.MediaSession { - method public void notifyChildrenChanged(androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public void notifyChildrenChanged(String, int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public void notifySearchResultChanged(androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - } - - public static final class MediaLibraryService.MediaLibrarySession.Builder { - ctor public MediaLibraryService.MediaLibrarySession.Builder(androidx.media2.session.MediaLibraryService, androidx.media2.common.SessionPlayer, java.util.concurrent.Executor, androidx.media2.session.MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback); - method public androidx.media2.session.MediaLibraryService.MediaLibrarySession build(); - method public androidx.media2.session.MediaLibraryService.MediaLibrarySession.Builder setExtras(android.os.Bundle); - method public androidx.media2.session.MediaLibraryService.MediaLibrarySession.Builder setId(String); - method public androidx.media2.session.MediaLibraryService.MediaLibrarySession.Builder setSessionActivity(android.app.PendingIntent?); - } - - public static class MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback extends androidx.media2.session.MediaSession.SessionCallback { - ctor public MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback(); - method public androidx.media2.session.LibraryResult onGetChildren(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public androidx.media2.session.LibraryResult onGetItem(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String); - method public androidx.media2.session.LibraryResult onGetLibraryRoot(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public androidx.media2.session.LibraryResult onGetSearchResult(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public int onSearch(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public int onSubscribe(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, androidx.media2.session.MediaLibraryService.LibraryParams?); - method public int onUnsubscribe(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String); - } - - public class MediaSession implements java.io.Closeable { - method public void broadcastCustomCommand(androidx.media2.session.SessionCommand, android.os.Bundle?); - method public void close(); - method public java.util.List<androidx.media2.session.MediaSession.ControllerInfo!> getConnectedControllers(); - method public String getId(); - method public androidx.media2.common.SessionPlayer getPlayer(); - method public android.support.v4.media.session.MediaSessionCompat.Token getSessionCompatToken(); - method public androidx.media2.session.SessionToken getToken(); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> sendCustomCommand(androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommand, android.os.Bundle?); - method public void setAllowedCommands(androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommandGroup); - method public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setCustomLayout(androidx.media2.session.MediaSession.ControllerInfo, java.util.List<androidx.media2.session.MediaSession.CommandButton!>); - method public void updatePlayer(androidx.media2.common.SessionPlayer); - } - - public static final class MediaSession.Builder { - ctor public MediaSession.Builder(android.content.Context, androidx.media2.common.SessionPlayer); - method public androidx.media2.session.MediaSession build(); - method public androidx.media2.session.MediaSession.Builder setExtras(android.os.Bundle); - method public androidx.media2.session.MediaSession.Builder setId(String); - method public androidx.media2.session.MediaSession.Builder setSessionActivity(android.app.PendingIntent?); - method public androidx.media2.session.MediaSession.Builder setSessionCallback(java.util.concurrent.Executor, androidx.media2.session.MediaSession.SessionCallback); - } - - @androidx.versionedparcelable.VersionedParcelize public static final class MediaSession.CommandButton implements androidx.versionedparcelable.VersionedParcelable { - method public androidx.media2.session.SessionCommand? getCommand(); - method public CharSequence? getDisplayName(); - method public android.os.Bundle? getExtras(); - method public int getIconResId(); - method public boolean isEnabled(); - } - - public static final class MediaSession.CommandButton.Builder { - ctor public MediaSession.CommandButton.Builder(); - method public androidx.media2.session.MediaSession.CommandButton build(); - method public androidx.media2.session.MediaSession.CommandButton.Builder setCommand(androidx.media2.session.SessionCommand?); - method public androidx.media2.session.MediaSession.CommandButton.Builder setDisplayName(CharSequence?); - method public androidx.media2.session.MediaSession.CommandButton.Builder setEnabled(boolean); - method public androidx.media2.session.MediaSession.CommandButton.Builder setExtras(android.os.Bundle?); - method public androidx.media2.session.MediaSession.CommandButton.Builder setIconResId(int); - } - - public static final class MediaSession.ControllerInfo { - method public android.os.Bundle getConnectionHints(); - method public String getPackageName(); - method public int getUid(); - } - - public abstract static class MediaSession.SessionCallback { - ctor public MediaSession.SessionCallback(); - method public int onCommandRequest(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommand); - method public androidx.media2.session.SessionCommandGroup? onConnect(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - method public androidx.media2.common.MediaItem? onCreateMediaItem(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, String); - method public androidx.media2.session.SessionResult onCustomCommand(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommand, android.os.Bundle?); - method public void onDisconnected(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - method public int onFastForward(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - method public void onPostConnect(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - method public int onRewind(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - method public int onSetMediaUri(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, android.net.Uri, android.os.Bundle?); - method public int onSetRating(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, String, androidx.media2.common.Rating); - method public int onSkipBackward(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - method public int onSkipForward(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); - } - - public final class MediaSessionManager { - method public static androidx.media2.session.MediaSessionManager getInstance(android.content.Context); - method public java.util.Set<androidx.media2.session.SessionToken!> getSessionServiceTokens(); - } - - public abstract class MediaSessionService extends android.app.Service { - ctor public MediaSessionService(); - method public final void addSession(androidx.media2.session.MediaSession); - method public final java.util.List<androidx.media2.session.MediaSession!> getSessions(); - method @CallSuper public android.os.IBinder? onBind(android.content.Intent); - method public abstract androidx.media2.session.MediaSession? onGetSession(androidx.media2.session.MediaSession.ControllerInfo); - method public androidx.media2.session.MediaSessionService.MediaNotification? onUpdateNotification(androidx.media2.session.MediaSession); - method public final void removeSession(androidx.media2.session.MediaSession); - field public static final String SERVICE_INTERFACE = "androidx.media2.session.MediaSessionService"; - } - - public static class MediaSessionService.MediaNotification { - ctor public MediaSessionService.MediaNotification(int, android.app.Notification); - method public android.app.Notification getNotification(); - method public int getNotificationId(); - } - - @androidx.versionedparcelable.VersionedParcelize public final class PercentageRating implements androidx.media2.common.Rating { - ctor public PercentageRating(); - ctor public PercentageRating(float); - method public float getPercentRating(); - method public boolean isRated(); - } - - public abstract class RemoteSessionPlayer extends androidx.media2.common.SessionPlayer { - ctor public RemoteSessionPlayer(); - method public abstract java.util.concurrent.Future<androidx.media2.common.SessionPlayer.PlayerResult!> adjustVolume(int); - method public abstract int getMaxVolume(); - method public abstract int getVolume(); - method public abstract int getVolumeControlType(); - method public abstract java.util.concurrent.Future<androidx.media2.common.SessionPlayer.PlayerResult!> setVolume(int); - field public static final int VOLUME_CONTROL_ABSOLUTE = 2; // 0x2 - field public static final int VOLUME_CONTROL_FIXED = 0; // 0x0 - field public static final int VOLUME_CONTROL_RELATIVE = 1; // 0x1 - } - - public static class RemoteSessionPlayer.Callback extends androidx.media2.common.SessionPlayer.PlayerCallback { - ctor public RemoteSessionPlayer.Callback(); - method public void onVolumeChanged(androidx.media2.session.RemoteSessionPlayer, int); - } - - @androidx.versionedparcelable.VersionedParcelize public final class SessionCommand implements androidx.versionedparcelable.VersionedParcelable { - ctor public SessionCommand(int); - ctor public SessionCommand(String, android.os.Bundle?); - method public int getCommandCode(); - method public String? getCustomAction(); - method public android.os.Bundle? getCustomExtras(); - field public static final int COMMAND_CODE_CUSTOM = 0; // 0x0 - field public static final int COMMAND_CODE_LIBRARY_GET_CHILDREN = 50003; // 0xc353 - field public static final int COMMAND_CODE_LIBRARY_GET_ITEM = 50004; // 0xc354 - field public static final int COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT = 50000; // 0xc350 - field public static final int COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT = 50006; // 0xc356 - field public static final int COMMAND_CODE_LIBRARY_SEARCH = 50005; // 0xc355 - field public static final int COMMAND_CODE_LIBRARY_SUBSCRIBE = 50001; // 0xc351 - field public static final int COMMAND_CODE_LIBRARY_UNSUBSCRIBE = 50002; // 0xc352 - field public static final int COMMAND_CODE_PLAYER_ADD_PLAYLIST_ITEM = 10013; // 0x271d - field public static final int COMMAND_CODE_PLAYER_DESELECT_TRACK = 11002; // 0x2afa - field public static final int COMMAND_CODE_PLAYER_GET_CURRENT_MEDIA_ITEM = 10016; // 0x2720 - field public static final int COMMAND_CODE_PLAYER_GET_PLAYLIST = 10005; // 0x2715 - field public static final int COMMAND_CODE_PLAYER_GET_PLAYLIST_METADATA = 10012; // 0x271c - field public static final int COMMAND_CODE_PLAYER_MOVE_PLAYLIST_ITEM = 10019; // 0x2723 - field public static final int COMMAND_CODE_PLAYER_PAUSE = 10001; // 0x2711 - field public static final int COMMAND_CODE_PLAYER_PLAY = 10000; // 0x2710 - field public static final int COMMAND_CODE_PLAYER_PREPARE = 10002; // 0x2712 - field public static final int COMMAND_CODE_PLAYER_REMOVE_PLAYLIST_ITEM = 10014; // 0x271e - field public static final int COMMAND_CODE_PLAYER_REPLACE_PLAYLIST_ITEM = 10015; // 0x271f - field public static final int COMMAND_CODE_PLAYER_SEEK_TO = 10003; // 0x2713 - field public static final int COMMAND_CODE_PLAYER_SELECT_TRACK = 11001; // 0x2af9 - field public static final int COMMAND_CODE_PLAYER_SET_MEDIA_ITEM = 10018; // 0x2722 - field public static final int COMMAND_CODE_PLAYER_SET_PLAYLIST = 10006; // 0x2716 - field public static final int COMMAND_CODE_PLAYER_SET_REPEAT_MODE = 10011; // 0x271b - field public static final int COMMAND_CODE_PLAYER_SET_SHUFFLE_MODE = 10010; // 0x271a - field public static final int COMMAND_CODE_PLAYER_SET_SPEED = 10004; // 0x2714 - field public static final int COMMAND_CODE_PLAYER_SET_SURFACE = 11000; // 0x2af8 - field public static final int COMMAND_CODE_PLAYER_SKIP_TO_NEXT_PLAYLIST_ITEM = 10009; // 0x2719 - field public static final int COMMAND_CODE_PLAYER_SKIP_TO_PLAYLIST_ITEM = 10007; // 0x2717 - field public static final int COMMAND_CODE_PLAYER_SKIP_TO_PREVIOUS_PLAYLIST_ITEM = 10008; // 0x2718 - field public static final int COMMAND_CODE_PLAYER_UPDATE_LIST_METADATA = 10017; // 0x2721 - field public static final int COMMAND_CODE_SESSION_FAST_FORWARD = 40000; // 0x9c40 - field public static final int COMMAND_CODE_SESSION_REWIND = 40001; // 0x9c41 - field public static final int COMMAND_CODE_SESSION_SET_MEDIA_URI = 40011; // 0x9c4b - field public static final int COMMAND_CODE_SESSION_SET_RATING = 40010; // 0x9c4a - field public static final int COMMAND_CODE_SESSION_SKIP_BACKWARD = 40003; // 0x9c43 - field public static final int COMMAND_CODE_SESSION_SKIP_FORWARD = 40002; // 0x9c42 - field public static final int COMMAND_CODE_VOLUME_ADJUST_VOLUME = 30001; // 0x7531 - field public static final int COMMAND_CODE_VOLUME_SET_VOLUME = 30000; // 0x7530 - field public static final int COMMAND_VERSION_1 = 1; // 0x1 - field public static final int COMMAND_VERSION_2 = 2; // 0x2 - } - - @androidx.versionedparcelable.VersionedParcelize public final class SessionCommandGroup implements androidx.versionedparcelable.VersionedParcelable { - ctor public SessionCommandGroup(); - ctor public SessionCommandGroup(java.util.Collection<androidx.media2.session.SessionCommand!>?); - method public java.util.Set<androidx.media2.session.SessionCommand!> getCommands(); - method public boolean hasCommand(androidx.media2.session.SessionCommand); - method public boolean hasCommand(int); - } - - public static final class SessionCommandGroup.Builder { - ctor public SessionCommandGroup.Builder(); - ctor public SessionCommandGroup.Builder(androidx.media2.session.SessionCommandGroup); - method public androidx.media2.session.SessionCommandGroup.Builder addAllPredefinedCommands(int); - method public androidx.media2.session.SessionCommandGroup.Builder addCommand(androidx.media2.session.SessionCommand); - method public androidx.media2.session.SessionCommandGroup build(); - method public androidx.media2.session.SessionCommandGroup.Builder removeCommand(androidx.media2.session.SessionCommand); - } - - @androidx.versionedparcelable.VersionedParcelize(isCustom=true) public class SessionResult extends androidx.versionedparcelable.CustomVersionedParcelable { - ctor public SessionResult(int, android.os.Bundle?); - method public long getCompletionTime(); - method public android.os.Bundle? getCustomCommandResult(); - method public androidx.media2.common.MediaItem? getMediaItem(); - method public int getResultCode(); + @Deprecated public class MediaBrowser extends androidx.media2.session.MediaController { + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getChildren(String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getItem(String); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getLibraryRoot(androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> getSearchResult(String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> search(String, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> subscribe(String, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.LibraryResult!> unsubscribe(String); + } + + @Deprecated public static class MediaBrowser.BrowserCallback extends androidx.media2.session.MediaController.ControllerCallback { + ctor @Deprecated public MediaBrowser.BrowserCallback(); + method @Deprecated public void onChildrenChanged(androidx.media2.session.MediaBrowser, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public void onSearchResultChanged(androidx.media2.session.MediaBrowser, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + } + + @Deprecated public static final class MediaBrowser.Builder { + ctor @Deprecated public MediaBrowser.Builder(android.content.Context); + method @Deprecated public androidx.media2.session.MediaBrowser build(); + method @Deprecated public androidx.media2.session.MediaBrowser.Builder setConnectionHints(android.os.Bundle); + method @Deprecated public androidx.media2.session.MediaBrowser.Builder setControllerCallback(java.util.concurrent.Executor, androidx.media2.session.MediaBrowser.BrowserCallback); + method @Deprecated public androidx.media2.session.MediaBrowser.Builder setSessionCompatToken(android.support.v4.media.session.MediaSessionCompat.Token); + method @Deprecated public androidx.media2.session.MediaBrowser.Builder setSessionToken(androidx.media2.session.SessionToken); + } + + @Deprecated public class MediaConstants { + field @Deprecated public static final String MEDIA_URI_AUTHORITY = "media2-session"; + field @Deprecated public static final String MEDIA_URI_PATH_PLAY_FROM_MEDIA_ID = "playFromMediaId"; + field @Deprecated public static final String MEDIA_URI_PATH_PLAY_FROM_SEARCH = "playFromSearch"; + field @Deprecated public static final String MEDIA_URI_PATH_PREPARE_FROM_MEDIA_ID = "prepareFromMediaId"; + field @Deprecated public static final String MEDIA_URI_PATH_PREPARE_FROM_SEARCH = "prepareFromSearch"; + field @Deprecated public static final String MEDIA_URI_PATH_SET_MEDIA_URI = "setMediaUri"; + field @Deprecated public static final String MEDIA_URI_QUERY_ID = "id"; + field @Deprecated public static final String MEDIA_URI_QUERY_QUERY = "query"; + field @Deprecated public static final String MEDIA_URI_QUERY_URI = "uri"; + field @Deprecated public static final String MEDIA_URI_SCHEME = "androidx"; + } + + @Deprecated public class MediaController implements java.io.Closeable { + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> addPlaylistItem(@IntRange(from=0) int, String); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> adjustVolume(int, int); + method @Deprecated public void close(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> deselectTrack(androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> fastForward(); + method @Deprecated public androidx.media2.session.SessionCommandGroup? getAllowedCommands(); + method @Deprecated public long getBufferedPosition(); + method @Deprecated public int getBufferingState(); + method @Deprecated public androidx.media2.session.SessionToken? getConnectedToken(); + method @Deprecated public androidx.media2.common.MediaItem? getCurrentMediaItem(); + method @Deprecated public int getCurrentMediaItemIndex(); + method @Deprecated public long getCurrentPosition(); + method @Deprecated public long getDuration(); + method @Deprecated public int getNextMediaItemIndex(); + method @Deprecated public androidx.media2.session.MediaController.PlaybackInfo? getPlaybackInfo(); + method @Deprecated public float getPlaybackSpeed(); + method @Deprecated public int getPlayerState(); + method @Deprecated public java.util.List<androidx.media2.common.MediaItem!>? getPlaylist(); + method @Deprecated public androidx.media2.common.MediaMetadata? getPlaylistMetadata(); + method @Deprecated public int getPreviousMediaItemIndex(); + method @Deprecated public int getRepeatMode(); + method @Deprecated public androidx.media2.common.SessionPlayer.TrackInfo? getSelectedTrack(int); + method @Deprecated public android.app.PendingIntent? getSessionActivity(); + method @Deprecated public int getShuffleMode(); + method @Deprecated public java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!> getTracks(); + method @Deprecated public androidx.media2.common.VideoSize getVideoSize(); + method @Deprecated public boolean isConnected(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> movePlaylistItem(@IntRange(from=0) int, @IntRange(from=0) int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> pause(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> play(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> prepare(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> removePlaylistItem(@IntRange(from=0) int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> replacePlaylistItem(@IntRange(from=0) int, String); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> rewind(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> seekTo(long); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> selectTrack(androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> sendCustomCommand(androidx.media2.session.SessionCommand, android.os.Bundle?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setMediaItem(String); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setMediaUri(android.net.Uri, android.os.Bundle?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setPlaybackSpeed(float); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setPlaylist(java.util.List<java.lang.String!>, androidx.media2.common.MediaMetadata?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setRating(String, androidx.media2.common.Rating); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setRepeatMode(int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setShuffleMode(int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setSurface(android.view.Surface?); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setVolumeTo(int, int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipBackward(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipForward(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipToNextPlaylistItem(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipToPlaylistItem(@IntRange(from=0) int); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> skipToPreviousPlaylistItem(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> updatePlaylistMetadata(androidx.media2.common.MediaMetadata?); + } + + @Deprecated public static final class MediaController.Builder { + ctor @Deprecated public MediaController.Builder(android.content.Context); + method @Deprecated public androidx.media2.session.MediaController build(); + method @Deprecated public androidx.media2.session.MediaController.Builder setConnectionHints(android.os.Bundle); + method @Deprecated public androidx.media2.session.MediaController.Builder setControllerCallback(java.util.concurrent.Executor, androidx.media2.session.MediaController.ControllerCallback); + method @Deprecated public androidx.media2.session.MediaController.Builder setSessionCompatToken(android.support.v4.media.session.MediaSessionCompat.Token); + method @Deprecated public androidx.media2.session.MediaController.Builder setSessionToken(androidx.media2.session.SessionToken); + } + + @Deprecated public abstract static class MediaController.ControllerCallback { + ctor @Deprecated public MediaController.ControllerCallback(); + method @Deprecated public void onAllowedCommandsChanged(androidx.media2.session.MediaController, androidx.media2.session.SessionCommandGroup); + method @Deprecated public void onBufferingStateChanged(androidx.media2.session.MediaController, androidx.media2.common.MediaItem, int); + method @Deprecated public void onConnected(androidx.media2.session.MediaController, androidx.media2.session.SessionCommandGroup); + method @Deprecated public void onCurrentMediaItemChanged(androidx.media2.session.MediaController, androidx.media2.common.MediaItem?); + method @Deprecated public androidx.media2.session.SessionResult onCustomCommand(androidx.media2.session.MediaController, androidx.media2.session.SessionCommand, android.os.Bundle?); + method @Deprecated public void onDisconnected(androidx.media2.session.MediaController); + method @Deprecated public void onPlaybackCompleted(androidx.media2.session.MediaController); + method @Deprecated public void onPlaybackInfoChanged(androidx.media2.session.MediaController, androidx.media2.session.MediaController.PlaybackInfo); + method @Deprecated public void onPlaybackSpeedChanged(androidx.media2.session.MediaController, float); + method @Deprecated public void onPlayerStateChanged(androidx.media2.session.MediaController, int); + method @Deprecated public void onPlaylistChanged(androidx.media2.session.MediaController, java.util.List<androidx.media2.common.MediaItem!>?, androidx.media2.common.MediaMetadata?); + method @Deprecated public void onPlaylistMetadataChanged(androidx.media2.session.MediaController, androidx.media2.common.MediaMetadata?); + method @Deprecated public void onRepeatModeChanged(androidx.media2.session.MediaController, int); + method @Deprecated public void onSeekCompleted(androidx.media2.session.MediaController, long); + method @Deprecated public int onSetCustomLayout(androidx.media2.session.MediaController, java.util.List<androidx.media2.session.MediaSession.CommandButton!>); + method @Deprecated public void onShuffleModeChanged(androidx.media2.session.MediaController, int); + method @Deprecated public void onSubtitleData(androidx.media2.session.MediaController, androidx.media2.common.MediaItem, androidx.media2.common.SessionPlayer.TrackInfo, androidx.media2.common.SubtitleData); + method @Deprecated public void onTrackDeselected(androidx.media2.session.MediaController, androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public void onTrackSelected(androidx.media2.session.MediaController, androidx.media2.common.SessionPlayer.TrackInfo); + method @Deprecated public void onTracksChanged(androidx.media2.session.MediaController, java.util.List<androidx.media2.common.SessionPlayer.TrackInfo!>); + method @Deprecated public void onVideoSizeChanged(androidx.media2.session.MediaController, androidx.media2.common.VideoSize); + } + + @Deprecated @androidx.versionedparcelable.VersionedParcelize public static final class MediaController.PlaybackInfo implements androidx.versionedparcelable.VersionedParcelable { + method @Deprecated public androidx.media.AudioAttributesCompat? getAudioAttributes(); + method @Deprecated public int getControlType(); + method @Deprecated public int getCurrentVolume(); + method @Deprecated public int getMaxVolume(); + method @Deprecated public int getPlaybackType(); + field @Deprecated public static final int PLAYBACK_TYPE_LOCAL = 1; // 0x1 + field @Deprecated public static final int PLAYBACK_TYPE_REMOTE = 2; // 0x2 + } + + @Deprecated public abstract class MediaLibraryService extends androidx.media2.session.MediaSessionService { + ctor @Deprecated public MediaLibraryService(); + method @Deprecated public abstract androidx.media2.session.MediaLibraryService.MediaLibrarySession? onGetSession(androidx.media2.session.MediaSession.ControllerInfo); + field @Deprecated public static final String SERVICE_INTERFACE = "androidx.media2.session.MediaLibraryService"; + } + + @Deprecated @androidx.versionedparcelable.VersionedParcelize public static final class MediaLibraryService.LibraryParams implements androidx.versionedparcelable.VersionedParcelable { + method @Deprecated public android.os.Bundle? getExtras(); + method @Deprecated public boolean isOffline(); + method @Deprecated public boolean isRecent(); + method @Deprecated public boolean isSuggested(); + } + + @Deprecated public static final class MediaLibraryService.LibraryParams.Builder { + ctor @Deprecated public MediaLibraryService.LibraryParams.Builder(); + method @Deprecated public androidx.media2.session.MediaLibraryService.LibraryParams build(); + method @Deprecated public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setExtras(android.os.Bundle?); + method @Deprecated public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setOffline(boolean); + method @Deprecated public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setRecent(boolean); + method @Deprecated public androidx.media2.session.MediaLibraryService.LibraryParams.Builder setSuggested(boolean); + } + + @Deprecated public static final class MediaLibraryService.MediaLibrarySession extends androidx.media2.session.MediaSession { + method @Deprecated public void notifyChildrenChanged(androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public void notifyChildrenChanged(String, int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public void notifySearchResultChanged(androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + } + + @Deprecated public static final class MediaLibraryService.MediaLibrarySession.Builder { + ctor @Deprecated public MediaLibraryService.MediaLibrarySession.Builder(androidx.media2.session.MediaLibraryService, androidx.media2.common.SessionPlayer, java.util.concurrent.Executor, androidx.media2.session.MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback); + method @Deprecated public androidx.media2.session.MediaLibraryService.MediaLibrarySession build(); + method @Deprecated public androidx.media2.session.MediaLibraryService.MediaLibrarySession.Builder setExtras(android.os.Bundle); + method @Deprecated public androidx.media2.session.MediaLibraryService.MediaLibrarySession.Builder setId(String); + method @Deprecated public androidx.media2.session.MediaLibraryService.MediaLibrarySession.Builder setSessionActivity(android.app.PendingIntent?); + } + + @Deprecated public static class MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback extends androidx.media2.session.MediaSession.SessionCallback { + ctor @Deprecated public MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback(); + method @Deprecated public androidx.media2.session.LibraryResult onGetChildren(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public androidx.media2.session.LibraryResult onGetItem(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String); + method @Deprecated public androidx.media2.session.LibraryResult onGetLibraryRoot(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public androidx.media2.session.LibraryResult onGetSearchResult(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, @IntRange(from=0) int, @IntRange(from=1) int, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public int onSearch(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public int onSubscribe(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String, androidx.media2.session.MediaLibraryService.LibraryParams?); + method @Deprecated public int onUnsubscribe(androidx.media2.session.MediaLibraryService.MediaLibrarySession, androidx.media2.session.MediaSession.ControllerInfo, String); + } + + @Deprecated public class MediaSession implements java.io.Closeable { + method @Deprecated public void broadcastCustomCommand(androidx.media2.session.SessionCommand, android.os.Bundle?); + method @Deprecated public void close(); + method @Deprecated public java.util.List<androidx.media2.session.MediaSession.ControllerInfo!> getConnectedControllers(); + method @Deprecated public String getId(); + method @Deprecated public androidx.media2.common.SessionPlayer getPlayer(); + method @Deprecated public android.support.v4.media.session.MediaSessionCompat.Token getSessionCompatToken(); + method @Deprecated public androidx.media2.session.SessionToken getToken(); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> sendCustomCommand(androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommand, android.os.Bundle?); + method @Deprecated public void setAllowedCommands(androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommandGroup); + method @Deprecated public com.google.common.util.concurrent.ListenableFuture<androidx.media2.session.SessionResult!> setCustomLayout(androidx.media2.session.MediaSession.ControllerInfo, java.util.List<androidx.media2.session.MediaSession.CommandButton!>); + method @Deprecated public void updatePlayer(androidx.media2.common.SessionPlayer); + } + + @Deprecated public static final class MediaSession.Builder { + ctor @Deprecated public MediaSession.Builder(android.content.Context, androidx.media2.common.SessionPlayer); + method @Deprecated public androidx.media2.session.MediaSession build(); + method @Deprecated public androidx.media2.session.MediaSession.Builder setExtras(android.os.Bundle); + method @Deprecated public androidx.media2.session.MediaSession.Builder setId(String); + method @Deprecated public androidx.media2.session.MediaSession.Builder setSessionActivity(android.app.PendingIntent?); + method @Deprecated public androidx.media2.session.MediaSession.Builder setSessionCallback(java.util.concurrent.Executor, androidx.media2.session.MediaSession.SessionCallback); + } + + @Deprecated @androidx.versionedparcelable.VersionedParcelize public static final class MediaSession.CommandButton implements androidx.versionedparcelable.VersionedParcelable { + method @Deprecated public androidx.media2.session.SessionCommand? getCommand(); + method @Deprecated public CharSequence? getDisplayName(); + method @Deprecated public android.os.Bundle? getExtras(); + method @Deprecated public int getIconResId(); + method @Deprecated public boolean isEnabled(); + } + + @Deprecated public static final class MediaSession.CommandButton.Builder { + ctor @Deprecated public MediaSession.CommandButton.Builder(); + method @Deprecated public androidx.media2.session.MediaSession.CommandButton build(); + method @Deprecated public androidx.media2.session.MediaSession.CommandButton.Builder setCommand(androidx.media2.session.SessionCommand?); + method @Deprecated public androidx.media2.session.MediaSession.CommandButton.Builder setDisplayName(CharSequence?); + method @Deprecated public androidx.media2.session.MediaSession.CommandButton.Builder setEnabled(boolean); + method @Deprecated public androidx.media2.session.MediaSession.CommandButton.Builder setExtras(android.os.Bundle?); + method @Deprecated public androidx.media2.session.MediaSession.CommandButton.Builder setIconResId(int); + } + + @Deprecated public static final class MediaSession.ControllerInfo { + method @Deprecated public android.os.Bundle getConnectionHints(); + method @Deprecated public String getPackageName(); + method @Deprecated public int getUid(); + } + + @Deprecated public abstract static class MediaSession.SessionCallback { + ctor @Deprecated public MediaSession.SessionCallback(); + method @Deprecated public int onCommandRequest(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommand); + method @Deprecated public androidx.media2.session.SessionCommandGroup? onConnect(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public androidx.media2.common.MediaItem? onCreateMediaItem(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, String); + method @Deprecated public androidx.media2.session.SessionResult onCustomCommand(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommand, android.os.Bundle?); + method @Deprecated public void onDisconnected(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public int onFastForward(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public void onPostConnect(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public int onRewind(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public int onSetMediaUri(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, android.net.Uri, android.os.Bundle?); + method @Deprecated public int onSetRating(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, String, androidx.media2.common.Rating); + method @Deprecated public int onSkipBackward(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public int onSkipForward(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo); + } + + @Deprecated public final class MediaSessionManager { + method @Deprecated public static androidx.media2.session.MediaSessionManager getInstance(android.content.Context); + method @Deprecated public java.util.Set<androidx.media2.session.SessionToken!> getSessionServiceTokens(); + } + + @Deprecated public abstract class MediaSessionService extends android.app.Service { + ctor @Deprecated public MediaSessionService(); + method @Deprecated public final void addSession(androidx.media2.session.MediaSession); + method @Deprecated public final java.util.List<androidx.media2.session.MediaSession!> getSessions(); + method @Deprecated @CallSuper public android.os.IBinder? onBind(android.content.Intent); + method @Deprecated public abstract androidx.media2.session.MediaSession? onGetSession(androidx.media2.session.MediaSession.ControllerInfo); + method @Deprecated public androidx.media2.session.MediaSessionService.MediaNotification? onUpdateNotification(androidx.media2.session.MediaSession); + method @Deprecated public final void removeSession(androidx.media2.session.MediaSession); + field @Deprecated public static final String SERVICE_INTERFACE = "androidx.media2.session.MediaSessionService"; + } + + @Deprecated public static class MediaSessionService.MediaNotification { + ctor @Deprecated public MediaSessionService.MediaNotification(int, android.app.Notification); + method @Deprecated public android.app.Notification getNotification(); + method @Deprecated public int getNotificationId(); + } + + @Deprecated @androidx.versionedparcelable.VersionedParcelize public final class PercentageRating implements androidx.media2.common.Rating { + ctor @Deprecated public PercentageRating(); + ctor @Deprecated public PercentageRating(float); + method @Deprecated public float getPercentRating(); + method @Deprecated public boolean isRated(); + } + + @Deprecated public abstract class RemoteSessionPlayer extends androidx.media2.common.SessionPlayer { + ctor @Deprecated public RemoteSessionPlayer(); + method @Deprecated public abstract java.util.concurrent.Future<androidx.media2.common.SessionPlayer.PlayerResult!> adjustVolume(int); + method @Deprecated public abstract int getMaxVolume(); + method @Deprecated public abstract int getVolume(); + method @Deprecated public abstract int getVolumeControlType(); + method @Deprecated public abstract java.util.concurrent.Future<androidx.media2.common.SessionPlayer.PlayerResult!> setVolume(int); + field @Deprecated public static final int VOLUME_CONTROL_ABSOLUTE = 2; // 0x2 + field @Deprecated public static final int VOLUME_CONTROL_FIXED = 0; // 0x0 + field @Deprecated public static final int VOLUME_CONTROL_RELATIVE = 1; // 0x1 + } + + @Deprecated public static class RemoteSessionPlayer.Callback extends androidx.media2.common.SessionPlayer.PlayerCallback { + ctor @Deprecated public RemoteSessionPlayer.Callback(); + method @Deprecated public void onVolumeChanged(androidx.media2.session.RemoteSessionPlayer, int); + } + + @Deprecated @androidx.versionedparcelable.VersionedParcelize public final class SessionCommand implements androidx.versionedparcelable.VersionedParcelable { + ctor @Deprecated public SessionCommand(int); + ctor @Deprecated public SessionCommand(String, android.os.Bundle?); + method @Deprecated public int getCommandCode(); + method @Deprecated public String? getCustomAction(); + method @Deprecated public android.os.Bundle? getCustomExtras(); + field @Deprecated public static final int COMMAND_CODE_CUSTOM = 0; // 0x0 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_GET_CHILDREN = 50003; // 0xc353 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_GET_ITEM = 50004; // 0xc354 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT = 50000; // 0xc350 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT = 50006; // 0xc356 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_SEARCH = 50005; // 0xc355 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_SUBSCRIBE = 50001; // 0xc351 + field @Deprecated public static final int COMMAND_CODE_LIBRARY_UNSUBSCRIBE = 50002; // 0xc352 + field @Deprecated public static final int COMMAND_CODE_PLAYER_ADD_PLAYLIST_ITEM = 10013; // 0x271d + field @Deprecated public static final int COMMAND_CODE_PLAYER_DESELECT_TRACK = 11002; // 0x2afa + field @Deprecated public static final int COMMAND_CODE_PLAYER_GET_CURRENT_MEDIA_ITEM = 10016; // 0x2720 + field @Deprecated public static final int COMMAND_CODE_PLAYER_GET_PLAYLIST = 10005; // 0x2715 + field @Deprecated public static final int COMMAND_CODE_PLAYER_GET_PLAYLIST_METADATA = 10012; // 0x271c + field @Deprecated public static final int COMMAND_CODE_PLAYER_MOVE_PLAYLIST_ITEM = 10019; // 0x2723 + field @Deprecated public static final int COMMAND_CODE_PLAYER_PAUSE = 10001; // 0x2711 + field @Deprecated public static final int COMMAND_CODE_PLAYER_PLAY = 10000; // 0x2710 + field @Deprecated public static final int COMMAND_CODE_PLAYER_PREPARE = 10002; // 0x2712 + field @Deprecated public static final int COMMAND_CODE_PLAYER_REMOVE_PLAYLIST_ITEM = 10014; // 0x271e + field @Deprecated public static final int COMMAND_CODE_PLAYER_REPLACE_PLAYLIST_ITEM = 10015; // 0x271f + field @Deprecated public static final int COMMAND_CODE_PLAYER_SEEK_TO = 10003; // 0x2713 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SELECT_TRACK = 11001; // 0x2af9 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SET_MEDIA_ITEM = 10018; // 0x2722 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SET_PLAYLIST = 10006; // 0x2716 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SET_REPEAT_MODE = 10011; // 0x271b + field @Deprecated public static final int COMMAND_CODE_PLAYER_SET_SHUFFLE_MODE = 10010; // 0x271a + field @Deprecated public static final int COMMAND_CODE_PLAYER_SET_SPEED = 10004; // 0x2714 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SET_SURFACE = 11000; // 0x2af8 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SKIP_TO_NEXT_PLAYLIST_ITEM = 10009; // 0x2719 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SKIP_TO_PLAYLIST_ITEM = 10007; // 0x2717 + field @Deprecated public static final int COMMAND_CODE_PLAYER_SKIP_TO_PREVIOUS_PLAYLIST_ITEM = 10008; // 0x2718 + field @Deprecated public static final int COMMAND_CODE_PLAYER_UPDATE_LIST_METADATA = 10017; // 0x2721 + field @Deprecated public static final int COMMAND_CODE_SESSION_FAST_FORWARD = 40000; // 0x9c40 + field @Deprecated public static final int COMMAND_CODE_SESSION_REWIND = 40001; // 0x9c41 + field @Deprecated public static final int COMMAND_CODE_SESSION_SET_MEDIA_URI = 40011; // 0x9c4b + field @Deprecated public static final int COMMAND_CODE_SESSION_SET_RATING = 40010; // 0x9c4a + field @Deprecated public static final int COMMAND_CODE_SESSION_SKIP_BACKWARD = 40003; // 0x9c43 + field @Deprecated public static final int COMMAND_CODE_SESSION_SKIP_FORWARD = 40002; // 0x9c42 + field @Deprecated public static final int COMMAND_CODE_VOLUME_ADJUST_VOLUME = 30001; // 0x7531 + field @Deprecated public static final int COMMAND_CODE_VOLUME_SET_VOLUME = 30000; // 0x7530 + field @Deprecated public static final int COMMAND_VERSION_1 = 1; // 0x1 + field @Deprecated public static final int COMMAND_VERSION_2 = 2; // 0x2 + } + + @Deprecated @androidx.versionedparcelable.VersionedParcelize public final class SessionCommandGroup implements androidx.versionedparcelable.VersionedParcelable { + ctor @Deprecated public SessionCommandGroup(); + ctor @Deprecated public SessionCommandGroup(java.util.Collection<androidx.media2.session.SessionCommand!>?); + method @Deprecated public java.util.Set<androidx.media2.session.SessionCommand!> getCommands(); + method @Deprecated public boolean hasCommand(androidx.media2.session.SessionCommand); + method @Deprecated public boolean hasCommand(int); + } + + @Deprecated public static final class SessionCommandGroup.Builder { + ctor @Deprecated public SessionCommandGroup.Builder(); + ctor @Deprecated public SessionCommandGroup.Builder(androidx.media2.session.SessionCommandGroup); + method @Deprecated public androidx.media2.session.SessionCommandGroup.Builder addAllPredefinedCommands(int); + method @Deprecated public androidx.media2.session.SessionCommandGroup.Builder addCommand(androidx.media2.session.SessionCommand); + method @Deprecated public androidx.media2.session.SessionCommandGroup build(); + method @Deprecated public androidx.media2.session.SessionCommandGroup.Builder removeCommand(androidx.media2.session.SessionCommand); + } + + @Deprecated @androidx.versionedparcelable.VersionedParcelize(isCustom=true) public class SessionResult extends androidx.versionedparcelable.CustomVersionedParcelable { + ctor @Deprecated public SessionResult(int, android.os.Bundle?); + method @Deprecated public long getCompletionTime(); + method @Deprecated public android.os.Bundle? getCustomCommandResult(); + method @Deprecated public androidx.media2.common.MediaItem? getMediaItem(); + method @Deprecated public int getResultCode(); field public static final int RESULT_ERROR_BAD_VALUE = -3; // 0xfffffffd field public static final int RESULT_ERROR_INVALID_STATE = -2; // 0xfffffffe field public static final int RESULT_ERROR_IO = -5; // 0xfffffffb @@ -415,34 +415,34 @@ package androidx.media2.session { field public static final int RESULT_ERROR_SESSION_SKIP_LIMIT_REACHED = -107; // 0xffffff95 field public static final int RESULT_ERROR_UNKNOWN = -1; // 0xffffffff field public static final int RESULT_INFO_SKIPPED = 1; // 0x1 - field public static final int RESULT_SUCCESS = 0; // 0x0 - } - - @androidx.versionedparcelable.VersionedParcelize public final class SessionToken implements androidx.versionedparcelable.VersionedParcelable { - ctor public SessionToken(android.content.Context, android.content.ComponentName); - method public android.os.Bundle getExtras(); - method public String getPackageName(); - method public String? getServiceName(); - method public int getType(); - method public int getUid(); - field public static final int TYPE_LIBRARY_SERVICE = 2; // 0x2 - field public static final int TYPE_SESSION = 0; // 0x0 - field public static final int TYPE_SESSION_SERVICE = 1; // 0x1 - } - - @androidx.versionedparcelable.VersionedParcelize public final class StarRating implements androidx.media2.common.Rating { - ctor public StarRating(@IntRange(from=1) int); - ctor public StarRating(@IntRange(from=1) int, float); - method public int getMaxStars(); - method public float getStarRating(); - method public boolean isRated(); - } - - @androidx.versionedparcelable.VersionedParcelize public final class ThumbRating implements androidx.media2.common.Rating { - ctor public ThumbRating(); - ctor public ThumbRating(boolean); - method public boolean isRated(); - method public boolean isThumbUp(); + field @Deprecated public static final int RESULT_SUCCESS = 0; // 0x0 + } + + @Deprecated @androidx.versionedparcelable.VersionedParcelize public final class SessionToken implements androidx.versionedparcelable.VersionedParcelable { + ctor @Deprecated public SessionToken(android.content.Context, android.content.ComponentName); + method @Deprecated public android.os.Bundle getExtras(); + method @Deprecated public String getPackageName(); + method @Deprecated public String? getServiceName(); + method @Deprecated public int getType(); + method @Deprecated public int getUid(); + field @Deprecated public static final int TYPE_LIBRARY_SERVICE = 2; // 0x2 + field @Deprecated public static final int TYPE_SESSION = 0; // 0x0 + field @Deprecated public static final int TYPE_SESSION_SERVICE = 1; // 0x1 + } + + @Deprecated @androidx.versionedparcelable.VersionedParcelize public final class StarRating implements androidx.media2.common.Rating { + ctor @Deprecated public StarRating(@IntRange(from=1) int); + ctor @Deprecated public StarRating(@IntRange(from=1) int, float); + method @Deprecated public int getMaxStars(); + method @Deprecated public float getStarRating(); + method @Deprecated public boolean isRated(); + } + + @Deprecated @androidx.versionedparcelable.VersionedParcelize public final class ThumbRating implements androidx.media2.common.Rating { + ctor @Deprecated public ThumbRating(); + ctor @Deprecated public ThumbRating(boolean); + method @Deprecated public boolean isRated(); + method @Deprecated public boolean isThumbUp(); } } diff --git a/media2/media2-session/src/main/java/androidx/media2/session/HeartRating.java b/media2/media2-session/src/main/java/androidx/media2/session/HeartRating.java index 68cdeb7bb06..5a785d6ce25 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/HeartRating.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/HeartRating.java @@ -22,9 +22,13 @@ import androidx.versionedparcelable.ParcelField; import androidx.versionedparcelable.VersionedParcelize; /** - * A class for rating with a single degree of rating, "heart" vs "no heart". - * This can be used to indicate the content referred to is a favorite (or not). + * A class for rating with a single degree of rating, "heart" vs "no heart". This can be used to + * indicate the content referred to is a favorite (or not). + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated @VersionedParcelize public final class HeartRating implements Rating { @ParcelField(1) diff --git a/media2/media2-session/src/main/java/androidx/media2/session/LibraryResult.java b/media2/media2-session/src/main/java/androidx/media2/session/LibraryResult.java index 0f09e4c66b7..6fdd26a17e1 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/LibraryResult.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/LibraryResult.java @@ -38,9 +38,13 @@ import java.lang.annotation.RetentionPolicy; import java.util.List; /** - * Result class to be used with {@link ListenableFuture} for asynchronous calls between - * {@link MediaLibraryService.MediaLibrarySession} and {@link MediaBrowser}. + * Result class to be used with {@link ListenableFuture} for asynchronous calls between {@link + * MediaLibraryService.MediaLibrarySession} and {@link MediaBrowser}. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated @VersionedParcelize(isCustom = true) public class LibraryResult extends CustomVersionedParcelable implements RemoteResult { /** diff --git a/media2/media2-session/src/main/java/androidx/media2/session/MediaBrowser.java b/media2/media2-session/src/main/java/androidx/media2/session/MediaBrowser.java index dd0b9a398ee..410b7361f00 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/MediaBrowser.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/MediaBrowser.java @@ -33,14 +33,22 @@ import java.util.concurrent.Executor; /** * Browses media content offered by a {@link MediaLibraryService}. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public class MediaBrowser extends MediaController { static final String TAG = "MediaBrowser"; static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); /** * Callback to listen events from {@link MediaLibraryService}. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static class BrowserCallback extends MediaController.ControllerCallback { /** * Called when there's change in the parent's children after you've subscribed to the parent @@ -294,17 +302,20 @@ public class MediaBrowser extends MediaController { /** * Builder for {@link MediaBrowser}. - * <p> - * To set the token of the session for the controller to connect to, one of the - * {@link #setSessionToken(SessionToken)} or - * {@link #setSessionCompatToken(MediaSessionCompat.Token)} should be called. - * Otherwise, the {@link #build()} will throw an {@link IllegalArgumentException}. - * <p> - * Any incoming event from the {@link MediaSession} will be handled on the callback - * executor. + * + * <p>To set the token of the session for the controller to connect to, one of the {@link + * #setSessionToken(SessionToken)} or {@link #setSessionCompatToken(MediaSessionCompat.Token)} + * should be called. Otherwise, the {@link #build()} will throw an {@link + * IllegalArgumentException}. + * + * <p>Any incoming event from the {@link MediaSession} will be handled on the callback executor. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ - public static final class Builder extends - BuilderBase<MediaBrowser, MediaBrowser.Builder, BrowserCallback> { + @Deprecated + public static final class Builder + extends BuilderBase<MediaBrowser, MediaBrowser.Builder, BrowserCallback> { public Builder(@NonNull Context context) { super(context); } diff --git a/media2/media2-session/src/main/java/androidx/media2/session/MediaConstants.java b/media2/media2-session/src/main/java/androidx/media2/session/MediaConstants.java index 5310734294d..4e1be1517e0 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/MediaConstants.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/MediaConstants.java @@ -20,7 +20,11 @@ import android.net.Uri; /** * Media constants for sharing constants between media provider and consumer apps + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public class MediaConstants { /** * A {@link android.net.Uri} scheme used in a media Uri. diff --git a/media2/media2-session/src/main/java/androidx/media2/session/MediaController.java b/media2/media2-session/src/main/java/androidx/media2/session/MediaController.java index 044e1e0405f..a7eddd09e8a 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/MediaController.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/MediaController.java @@ -74,51 +74,56 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; /** - * Allows an app to interact with an active {@link MediaSession} or a - * {@link MediaSessionService} which would provide {@link MediaSession}. Media buttons and other - * commands can be sent to the session. - * <p> - * MediaController objects are thread-safe. - * <p> - * Topics covered here: + * Allows an app to interact with an active {@link MediaSession} or a {@link MediaSessionService} + * which would provide {@link MediaSession}. Media buttons and other commands can be sent to the + * session. + * + * <p>MediaController objects are thread-safe. + * + * <p>Topics covered here: + * * <ol> - * <li><a href="#ControllerLifeCycle">Controller Lifecycle</a> - * <li><a href="#MediaSessionInTheSameProcess">Controlling the {@link MediaSession} in the same - * process</a> - * <li><a href="#PackageVisibilityFilter">Package Visibility Filter</a> + * <li><a href="#ControllerLifeCycle">Controller Lifecycle</a> + * <li><a href="#MediaSessionInTheSameProcess">Controlling the {@link MediaSession} in the same + * process</a> + * <li><a href="#PackageVisibilityFilter">Package Visibility Filter</a> * </ol> + * * <h3 id="ControllerLifeCycle">Controller Lifecycle</h3> - * <p> - * When a controller is created with the {@link SessionToken} for a {@link MediaSession} (i.e. + * + * <p>When a controller is created with the {@link SessionToken} for a {@link MediaSession} (i.e. * session token type is {@link SessionToken#TYPE_SESSION}), the controller will connect to the * specific session. - * <p> - * When a controller is created with the {@link SessionToken} for a {@link MediaSessionService} - * (i.e. session token type is {@link SessionToken#TYPE_SESSION_SERVICE} or - * {@link SessionToken#TYPE_LIBRARY_SERVICE}), the controller binds to the service for connecting - * to a {@link MediaSession} in it. {@link MediaSessionService} will provide a session to connect. - * <p> - * When a controller connects to a session, - * {@link MediaSession.SessionCallback#onConnect(MediaSession, MediaSession.ControllerInfo)} - * will be called to either accept or reject the connection. Wait - * {@link ControllerCallback#onConnected(MediaController, SessionCommandGroup)} or - * {@link ControllerCallback#onDisconnected(MediaController)} for the result. - * <p> - * When the connected session is closed, the controller will receive - * {@link ControllerCallback#onDisconnected(MediaController)}. - * <p> - * When you're done, use {@link #close()} to clean up resources. This also helps session service + * + * <p>When a controller is created with the {@link SessionToken} for a {@link MediaSessionService} + * (i.e. session token type is {@link SessionToken#TYPE_SESSION_SERVICE} or {@link + * SessionToken#TYPE_LIBRARY_SERVICE}), the controller binds to the service for connecting to a + * {@link MediaSession} in it. {@link MediaSessionService} will provide a session to connect. + * + * <p>When a controller connects to a session, {@link + * MediaSession.SessionCallback#onConnect(MediaSession, MediaSession.ControllerInfo)} will be called + * to either accept or reject the connection. Wait {@link + * ControllerCallback#onConnected(MediaController, SessionCommandGroup)} or {@link + * ControllerCallback#onDisconnected(MediaController)} for the result. + * + * <p>When the connected session is closed, the controller will receive {@link + * ControllerCallback#onDisconnected(MediaController)}. + * + * <p>When you're done, use {@link #close()} to clean up resources. This also helps session service * to be destroyed when there's no controller associated with it. - * <p> - * <a name="MediaSessionInTheSameProcess"></a> + * + * <p><a name="MediaSessionInTheSameProcess"></a> + * * <h3>Controlling the MediaSession in the same process</h3> + * * When you control the {@link MediaSession} and its {@link SessionPlayer}, it's recommended to use - * them directly rather than creating {@link MediaController}. However, if you need to use - * {@link MediaController} in the same process, be careful not to block session callback executor's - * thread. Here's an example code that would never return due to the thread issue. + * them directly rather than creating {@link MediaController}. However, if you need to use {@link + * MediaController} in the same process, be careful not to block session callback executor's thread. + * Here's an example code that would never return due to the thread issue. + * * <p> - * <pre> - * {@code + * + * <pre>{@code * // Code runs on the main thread. * MediaSession session = new MediaSession.Builder(context, player) * .setSessionCallback(sessionCallback, Context.getMainExecutor(context)).build(); @@ -128,25 +133,28 @@ import java.util.concurrent.Executors; * .build(); * * // This will hang and never return. - * controller.play().get();}</pre> + * controller.play().get(); + * }</pre> + * + * When a session gets a command from a controller, the session's {@link + * MediaSession.SessionCallback#onCommandRequest} would be executed on the session's callback + * executor to decide whether to ignore or handle the incoming command. To do so, the session's + * callback executor shouldn't be blocked to handle the incoming calls. However, if you call {@link + * ListenableFuture#get} on the thread for the session callback executor, then your call wouldn't be + * executed and never return. + * + * <p>To avoid such issue, don't block the session callback executor's thread. Creating a dedicated + * thread for the session callback executor would be helpful. See {@link + * Executors#newSingleThreadExecutor} for creating a new thread. * - * When a session gets a command from a controller, the session's - * {@link MediaSession.SessionCallback#onCommandRequest} would be executed on the session's - * callback executor to decide whether to ignore or handle the incoming command. To do so, the - * session's callback executor shouldn't be blocked to handle the incoming calls. However, if you - * call {@link ListenableFuture#get} on the thread for the session callback executor, then your - * call wouldn't be executed and never return. - * <p> - * To avoid such issue, don't block the session callback executor's thread. Creating a dedicated - * thread for the session callback executor would be helpful. See - * {@link Executors#newSingleThreadExecutor} for creating a new thread. * <h3 id="PackageVisibilityFilter">Package Visibility Filter</h3> - * <p> - * The app targeting API level 30 or higher must include a {@code <queries>} element in their + * + * <p>The app targeting API level 30 or higher must include a {@code <queries>} element in their * manifest to connect to a service component of another app like {@link MediaSessionService}, * {@link MediaLibraryService}, or {@link androidx.media.MediaBrowserServiceCompat}). See the * following example and <a href="{@docRoot}training/package-visibility">this guide</a> for more * information. + * * <pre>{@code * <!-- As intent actions --> * <intent> @@ -164,7 +172,10 @@ import java.util.concurrent.Executors; * * @see MediaSession * @see MediaSessionService + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public class MediaController implements Closeable { private static final String TAG = "MediaController"; @@ -1613,20 +1624,22 @@ public class MediaController implements Closeable { MediaBrowserCompat getBrowserCompat(); } - /** * Builder for {@link MediaController}. - * <p> - * To set the token of the session for the controller to connect to, one of the - * {@link #setSessionToken(SessionToken)} or - * {@link #setSessionCompatToken(MediaSessionCompat.Token)} should be called. - * Otherwise, the {@link #build()} will throw an {@link IllegalArgumentException}. - * <p> - * Any incoming event from the {@link MediaSession} will be handled on the callback - * executor. + * + * <p>To set the token of the session for the controller to connect to, one of the {@link + * #setSessionToken(SessionToken)} or {@link #setSessionCompatToken(MediaSessionCompat.Token)} + * should be called. Otherwise, the {@link #build()} will throw an {@link + * IllegalArgumentException}. + * + * <p>Any incoming event from the {@link MediaSession} will be handled on the callback executor. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ - public static final class Builder extends BuilderBase<MediaController, Builder, - ControllerCallback> { + @Deprecated + public static final class Builder + extends BuilderBase<MediaController, Builder, ControllerCallback> { public Builder(@NonNull Context context) { super(context); } @@ -1840,9 +1853,13 @@ public class MediaController implements Closeable { } /** - * Interface for listening to change in activeness of the {@link MediaSession}. It's - * active if and only if it has set a player. + * Interface for listening to change in activeness of the {@link MediaSession}. It's active if + * and only if it has set a player. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public abstract static class ControllerCallback { /** * Called when the controller is successfully connected to the session. The controller @@ -2135,8 +2152,12 @@ public class MediaController implements Closeable { /** * Holds information about the way volume is handled for this session. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ // The same as MediaController.PlaybackInfo + @Deprecated @VersionedParcelize public static final class PlaybackInfo implements VersionedParcelable { @ParcelField(1) diff --git a/media2/media2-session/src/main/java/androidx/media2/session/MediaLibraryService.java b/media2/media2-session/src/main/java/androidx/media2/session/MediaLibraryService.java index 5566fb6a815..b063bcd2d1c 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/MediaLibraryService.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/MediaLibraryService.java @@ -45,26 +45,34 @@ import androidx.versionedparcelable.VersionedParcelize; import java.util.concurrent.Executor; /** - * Base class for media library services, which is the service containing - * {@link MediaLibrarySession}. - * <p> - * Media library services enable applications to browse media content provided by an application - * and ask the application to start playing it. They may also be used to control content that - * is already playing by way of a {@link MediaSession}. - * <p> - * When extending this class, also add the following to your {@code AndroidManifest.xml}. + * Base class for media library services, which is the service containing {@link + * MediaLibrarySession}. + * + * <p>Media library services enable applications to browse media content provided by an application + * and ask the application to start playing it. They may also be used to control content that is + * already playing by way of a {@link MediaSession}. + * + * <p>When extending this class, also add the following to your {@code AndroidManifest.xml}. + * * <pre> * <service android:name="component_name_of_your_implementation" > * <intent-filter> * <action android:name="androidx.media2.session.MediaLibraryService" /> * </intent-filter> * </service></pre> - * <p> - * You may also declare <pre>android.media.browse.MediaBrowserService</pre> for compatibility with - * {@link android.support.v4.media.MediaBrowserCompat}. This service can handle it automatically. + * + * <p>You may also declare + * + * <pre>android.media.browse.MediaBrowserService</pre> + * + * for compatibility with {@link android.support.v4.media.MediaBrowserCompat}. This service can + * handle it automatically. * * @see MediaSessionService + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public abstract class MediaLibraryService extends MediaSessionService { /** * The {@link Intent} that must be declared as handled by the service. @@ -72,13 +80,14 @@ public abstract class MediaLibraryService extends MediaSessionService { public static final String SERVICE_INTERFACE = "androidx.media2.session.MediaLibraryService"; /** - * Session for the {@link MediaLibraryService}. Build this object with - * {@link Builder} and return in {@link MediaSessionService#onGetSession(ControllerInfo)}. + * Session for the {@link MediaLibraryService}. Build this object with {@link Builder} and + * return in {@link MediaSessionService#onGetSession(ControllerInfo)}. * * <h3 id="BackwardCompatibility">Backward compatibility with legacy media browser APIs</h3> - * Media library session supports connection from both {@link MediaBrowser} and - * {@link android.support.v4.media.MediaBrowserCompat}, but {@link ControllerInfo} may not be - * precise. Here are current limitations with details. + * + * Media library session supports connection from both {@link MediaBrowser} and {@link + * android.support.v4.media.MediaBrowserCompat}, but {@link ControllerInfo} may not be precise. + * Here are current limitations with details. * * <table> * <tr><th>SDK version</th> @@ -99,18 +108,25 @@ public abstract class MediaLibraryService extends MediaSessionService { * <td>Actual package name via {@link Context#getPackageName()}</td> * <td>Actual UID</td></tr> * </table> + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static final class MediaLibrarySession extends MediaSession { private final boolean mThrowsWhenInvalidReturn; /** * Callback for the {@link MediaLibrarySession}. - * <p> - * When you return {@link LibraryResult} with media items, - * items must have valid {@link MediaMetadata#METADATA_KEY_MEDIA_ID} and - * specify {@link MediaMetadata#METADATA_KEY_BROWSABLE} and - * {@link MediaMetadata#METADATA_KEY_PLAYABLE}. + * + * <p>When you return {@link LibraryResult} with media items, items must have valid {@link + * MediaMetadata#METADATA_KEY_MEDIA_ID} and specify {@link + * MediaMetadata#METADATA_KEY_BROWSABLE} and {@link MediaMetadata#METADATA_KEY_PLAYABLE}. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a> . */ + @Deprecated public static class MediaLibrarySessionCallback extends MediaSession.SessionCallback { /** * Called to get the root information for browsing by a {@link MediaBrowser}. @@ -289,17 +305,22 @@ public abstract class MediaLibraryService extends MediaSessionService { /** * Builder for {@link MediaLibrarySession}. - * <p> - * Any incoming event from the {@link MediaController} will be handled on the callback + * + * <p>Any incoming event from the {@link MediaController} will be handled on the callback * executor. If it's not set, {@link ContextCompat#getMainExecutor(Context)} will be used by * default. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a> . */ // Override all methods just to show them with the type instead of generics in Javadoc. // This workarounds javadoc issue described in the MediaSession.BuilderBase. // Note: Don't override #setSessionCallback() because the callback can be set by the // constructor. - public static final class Builder extends MediaSession.BuilderBase<MediaLibrarySession, - Builder, MediaLibrarySessionCallback> { + @Deprecated + public static final class Builder + extends MediaSession.BuilderBase< + MediaLibrarySession, Builder, MediaLibrarySessionCallback> { private boolean mThrowsWhenInvalidReturn = true; // Builder requires MediaLibraryService instead of Context just to ensure that the @@ -511,14 +532,18 @@ public abstract class MediaLibraryService extends MediaSessionService { /** * Contains information that the library service needs to send to the client. - * <p> - * When the browser supplies {@link LibraryParams}, it's optional field when getting the media - * item(s). The library session is recommended to do the best effort to provide such result. - * It's not an error even when the library session didn't return such items. - * <p> - * The library params returned in the library session callback must include the information + * + * <p>When the browser supplies {@link LibraryParams}, it's optional field when getting the + * media item(s). The library session is recommended to do the best effort to provide such + * result. It's not an error even when the library session didn't return such items. + * + * <p>The library params returned in the library session callback must include the information * about the returned media item(s). + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated @VersionedParcelize public static final class LibraryParams implements VersionedParcelable { @ParcelField(1) @@ -618,7 +643,11 @@ public abstract class MediaLibraryService extends MediaSessionService { /** * Builds a {@link LibraryParams}. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static final class Builder { private boolean mRecent; private boolean mOffline; diff --git a/media2/media2-session/src/main/java/androidx/media2/session/MediaSession.java b/media2/media2-session/src/main/java/androidx/media2/session/MediaSession.java index d425b403a69..14dbbc06356 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/MediaSession.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/MediaSession.java @@ -69,50 +69,54 @@ import java.util.concurrent.Executor; /** * Allows a media app to expose its transport controls and playback information in a process to * other processes including the Android framework and other apps. Common use cases are as follows. + * * <ul> - * <li>Bluetooth/wired headset key events support</li> - * <li>Android Auto/Wearable support</li> - * <li>Separating UI process and playback process</li> + * <li>Bluetooth/wired headset key events support + * <li>Android Auto/Wearable support + * <li>Separating UI process and playback process * </ul> - * <p> - * A MediaSession should be created when an app wants to publish media playback information or + * + * <p>A MediaSession should be created when an app wants to publish media playback information or * handle media keys. In general an app only needs one session for all playback, though multiple - * sessions can be created to provide finer grain controls of media. See - * <a href="#MultipleSessions">Supporting Multiple Sessions</a> for detail. - * <p> - * If you want to support background playback, {@link MediaSessionService} is preferred - * instead. With it, your playback can be revived even after playback is finished. See - * {@link MediaSessionService} for details. - * <p> - * Topics covered here: - * <ol> - * <li><a href="#SessionLifecycle">Session Lifecycle</a> - * <li><a href="#Thread">Thread</a> - * <li><a href="#KeyEvents">Media key events mapping</a> - * <li><a href="#MultipleSessions">Supporting Multiple Sessions</a> - * <li><a href="#CompatibilitySession">Backward compatibility with legacy session APIs</a> - * <li><a href="#CompatibilityController">Backward compatibility with legacy controller APIs</a> + * sessions can be created to provide finer grain controls of media. See <a + * href="#MultipleSessions">Supporting Multiple Sessions</a> for detail. + * + * <p>If you want to support background playback, {@link MediaSessionService} is preferred instead. + * With it, your playback can be revived even after playback is finished. See {@link + * MediaSessionService} for details. + * + * <p>Topics covered here: * + * <ol> + * <li><a href="#SessionLifecycle">Session Lifecycle</a> + * <li><a href="#Thread">Thread</a> + * <li><a href="#KeyEvents">Media key events mapping</a> + * <li><a href="#MultipleSessions">Supporting Multiple Sessions</a> + * <li><a href="#CompatibilitySession">Backward compatibility with legacy session APIs</a> + * <li><a href="#CompatibilityController">Backward compatibility with legacy controller APIs</a> * </ol> + * * <h3 id="SessionLifecycle">Session Lifecycle</h3> - * <p> - * A session can be obtained by {@link Builder}. The owner of the session may pass its session token - * to other processes to allow them to create a {@link MediaController} to interact with the + * + * <p>A session can be obtained by {@link Builder}. The owner of the session may pass its session + * token to other processes to allow them to create a {@link MediaController} to interact with the * session. - * <p> - * When a session receive transport control commands, the session sends the commands directly to + * + * <p>When a session receive transport control commands, the session sends the commands directly to * the underlying media player set by {@link Builder} or {@link #updatePlayer}. - * <p> - * When an app is finished performing playback it must call {@link #close()} to clean up the session - * and notify any controllers. The app is responsible for closing the underlying player after - * closing the session. - * is closed. + * + * <p>When an app is finished performing playback it must call {@link #close()} to clean up the + * session and notify any controllers. The app is responsible for closing the underlying player + * after closing the session. is closed. + * * <h3 id="Thread">Thread</h3> - * <p> - * {@link MediaSession} objects are thread safe, but should be used on the thread on the looper. + * + * <p>{@link MediaSession} objects are thread safe, but should be used on the thread on the looper. + * * <h3 id="KeyEvents">Media key events mapping</h3> - * <p> - * Here's the table of per key event. + * + * <p>Here's the table of per key event. + * * <table> * <tr><th>Key code</th><th>{@link MediaSession} API</th></tr> * <tr><td>{@link KeyEvent#KEYCODE_MEDIA_PLAY}</td> @@ -139,34 +143,43 @@ import java.util.concurrent.Executor; * <li>For a double tap, {@link SessionPlayer#skipToNextPlaylistItem()}</li></ul></td> * </tr> * </table> + * * <h3 id="MultipleSessions">Supporting Multiple Sessions</h3> + * * Generally speaking, multiple sessions aren't necessary for most media apps. One exception is if * your app can play multiple media content at the same time, but only for the playback of - * video-only media or remote playback, since - * <a href="{@docRoot}guide/topics/media-apps/audio-focus.html">audio focus policy</a> recommends - * not playing multiple audio content at the same time. Also keep in mind that multiple media - * sessions would make Android Auto and Bluetooth device with display to show your apps multiple - * times, because they list up media sessions, not media apps. + * video-only media or remote playback, since <a + * href="{@docRoot}guide/topics/media-apps/audio-focus.html">audio focus policy</a> recommends not + * playing multiple audio content at the same time. Also keep in mind that multiple media sessions + * would make Android Auto and Bluetooth device with display to show your apps multiple times, + * because they list up media sessions, not media apps. + * * <h3 id="CompatibilitySession">Backward compatibility with legacy session APIs</h3> + * * An active {@link MediaSessionCompat} is internally created with the MediaSession for the backward - * compatibility. It's used to handle incoming connection and command from - * {@link MediaControllerCompat}. And helps to utilize existing APIs that are built with legacy - * media session APIs. Use {@link #getSessionCompatToken} for getting the token for the underlying + * compatibility. It's used to handle incoming connection and command from {@link + * MediaControllerCompat}. And helps to utilize existing APIs that are built with legacy media + * session APIs. Use {@link #getSessionCompatToken} for getting the token for the underlying * MediaSessionCompat. + * * <h3 id="CompatibilityController">Backward compatibility with legacy controller APIs</h3> + * * In addition to the {@link MediaController media2 controller} API, session also supports - * connection from the legacy controller API - - * {@link android.media.session.MediaController framework controller} and - * {@link MediaControllerCompat AndroidX controller compat}. - * However, {@link ControllerInfo} may not be precise for legacy controller. - * See {@link ControllerInfo} for the details. - * <p> - * Unknown package name nor UID doesn't mean that you should disallow connection nor commands. For - * SDK levels where such issue happen, session tokens could only be obtained by trusted apps (e.g. - * Bluetooth, Auto, ...), so it may be better for you to allow them as you did with legacy session. + * connection from the legacy controller API - {@link android.media.session.MediaController + * framework controller} and {@link MediaControllerCompat AndroidX controller compat}. However, + * {@link ControllerInfo} may not be precise for legacy controller. See {@link ControllerInfo} for + * the details. + * + * <p>Unknown package name nor UID doesn't mean that you should disallow connection nor commands. + * For SDK levels where such issue happen, session tokens could only be obtained by trusted apps + * (e.g. Bluetooth, Auto, ...), so it may be better for you to allow them as you did with legacy + * session. * * @see MediaSessionService + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public class MediaSession implements Closeable { // It's better to have private static lock instead of using MediaSession.class because the @@ -467,10 +480,14 @@ public class MediaSession implements Closeable { /** * Callback to be called for all incoming commands from {@link MediaController}s. - * <p> - * If it's not set, the session will accept all controllers and all incoming commands by + * + * <p>If it's not set, the session will accept all controllers and all incoming commands by * default. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public abstract static class SessionCallback { ForegroundServiceEventCallback mForegroundServiceEventCallback; @@ -808,10 +825,15 @@ public class MediaSession implements Closeable { /** * Builder for {@link MediaSession}. - * <p> - * Any incoming event from the {@link MediaController} will be handled on the callback executor. - * If it's not set, {@link ContextCompat#getMainExecutor(Context)} will be used by default. + * + * <p>Any incoming event from the {@link MediaController} will be handled on the callback + * executor. If it's not set, {@link ContextCompat#getMainExecutor(Context)} will be used by + * default. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static final class Builder extends BuilderBase<MediaSession, Builder, SessionCallback> { public Builder(@NonNull Context context, @NonNull SessionPlayer player) { super(context, player); @@ -858,7 +880,11 @@ public class MediaSession implements Closeable { /** * Information of a controller. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static final class ControllerInfo { @SuppressWarnings("UnusedVariable") private final int mControllerVersion; @@ -1003,9 +1029,13 @@ public class MediaSession implements Closeable { /** * Button for a {@link SessionCommand} that will be shown by the controller. - * <p> - * It's up to the controller's decision to respect or ignore this customization request. + * + * <p>It's up to the controller's decision to respect or ignore this customization request. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated @VersionedParcelize public static final class CommandButton implements VersionedParcelable { @ParcelField(1) @@ -1090,7 +1120,11 @@ public class MediaSession implements Closeable { /** * Builder for {@link CommandButton}. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a> . */ + @Deprecated public static final class Builder { private SessionCommand mCommand; private int mIconResId; diff --git a/media2/media2-session/src/main/java/androidx/media2/session/MediaSessionManager.java b/media2/media2-session/src/main/java/androidx/media2/session/MediaSessionManager.java index d628d7b06a5..0310d67851b 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/MediaSessionManager.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/MediaSessionManager.java @@ -36,8 +36,8 @@ import java.util.List; import java.util.Set; /** - * Provides support for interacting with media sessions that applications have published - * in order to express their ongoing media playback state. + * Provides support for interacting with media sessions that applications have published in order to + * express their ongoing media playback state. * * @see MediaSessionCompat * @see MediaSession @@ -46,7 +46,10 @@ import java.util.Set; * @see MediaControllerCompat * @see MediaController * @see MediaBrowser + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public final class MediaSessionManager { static final String TAG = "MediaSessionManager"; static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); diff --git a/media2/media2-session/src/main/java/androidx/media2/session/MediaSessionService.java b/media2/media2-session/src/main/java/androidx/media2/session/MediaSessionService.java index d8a459e7826..1984eaefd7e 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/MediaSessionService.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/MediaSessionService.java @@ -32,88 +32,102 @@ import java.util.List; /** * Base class for media session services, which is the service containing {@link MediaSession}. - * <p> - * It's highly recommended for an app to use this if it wants to keep media playback in the + * + * <p>It's highly recommended for an app to use this if it wants to keep media playback in the * background. - * <p> - * Here are the benefits of using {@link MediaSessionService}. + * + * <p>Here are the benefits of using {@link MediaSessionService}. + * * <ul> - * <li>Another app can know that your app supports {@link MediaSession} even when your app - * isn't running. - * <li>Another app can start playback of your app even when your app isn't running. + * <li>Another app can know that your app supports {@link MediaSession} even when your app isn't + * running. + * <li>Another app can start playback of your app even when your app isn't running. * </ul> + * * For example, user's voice command can start playback of your app even when it's not running. - * <p> - * To extend this class, adding followings directly to your {@code AndroidManifest.xml}. + * + * <p>To extend this class, adding followings directly to your {@code AndroidManifest.xml}. + * * <pre> * <service android:name="component_name_of_your_implementation" > * <intent-filter> * <action android:name="androidx.media2.session.MediaSessionService" /> * </intent-filter> * </service></pre> - * <p> - * You may also declare <pre>android.media.browse.MediaBrowserService</pre> for compatibility with - * {@link android.support.v4.media.MediaBrowserCompat}. This service can handle it automatically. - * <p> - * It's recommended for an app to have a single {@link MediaSessionService} declared in the + * + * <p>You may also declare + * + * <pre>android.media.browse.MediaBrowserService</pre> + * + * for compatibility with {@link android.support.v4.media.MediaBrowserCompat}. This service can + * handle it automatically. + * + * <p>It's recommended for an app to have a single {@link MediaSessionService} declared in the * manifest. Otherwise, your app might be shown twice in the list of the Auto/Wearable, or another - * app fails to pick the right session service when it wants to start the playback of this app. - * If you want to provide multiple sessions here, take a look at - * <a href="#MultipleSessions">Supporting Multiple Sessions</a>. - * <p> - * Topics covered here: + * app fails to pick the right session service when it wants to start the playback of this app. If + * you want to provide multiple sessions here, take a look at <a href="#MultipleSessions">Supporting + * Multiple Sessions</a>. + * + * <p>Topics covered here: + * * <ol> - * <li><a href="#ServiceLifecycle">Service Lifecycle</a> - * <li><a href="#Permissions">Permissions</a> - * <li><a href="#MultipleSessions">Supporting Multiple Sessions</a> + * <li><a href="#ServiceLifecycle">Service Lifecycle</a> + * <li><a href="#Permissions">Permissions</a> + * <li><a href="#MultipleSessions">Supporting Multiple Sessions</a> * </ol> + * * <div> + * * <h3 id="ServiceLifecycle">Service Lifecycle</h3> - * <p> - * Session service is a bound service. When a {@link MediaController} is created for the - * session service, the controller binds to the session service. - * {@link #onGetSession(ControllerInfo)} would be called inside of the {@link #onBind(Intent)}. - * <p> - * After the binding, session's - * {@link MediaSession.SessionCallback#onConnect(MediaSession, MediaSession.ControllerInfo)} - * will be called to accept or reject connection request from a controller. If the connection is - * rejected, the controller will unbind. If it's accepted, the controller will be available to use - * and keep binding. - * <p> - * When playback is started for this session service, {@link #onUpdateNotification(MediaSession)} + * + * <p>Session service is a bound service. When a {@link MediaController} is created for the session + * service, the controller binds to the session service. {@link #onGetSession(ControllerInfo)} would + * be called inside of the {@link #onBind(Intent)}. + * + * <p>After the binding, session's {@link MediaSession.SessionCallback#onConnect(MediaSession, + * MediaSession.ControllerInfo)} will be called to accept or reject connection request from a + * controller. If the connection is rejected, the controller will unbind. If it's accepted, the + * controller will be available to use and keep binding. + * + * <p>When playback is started for this session service, {@link #onUpdateNotification(MediaSession)} * is called for the playback's session and service would become a foreground service. It's needed * to keep playback after the controller is destroyed. The session service becomes background - * service when all playbacks are stopped. Apps targeting API - * {@link android.os.Build.VERSION_CODES#P} or later must request the permission - * {@link android.Manifest.permission#FOREGROUND_SERVICE} in order to make the service foreground. - * <p> - * The service is destroyed when the all sessions are closed, or no media controller is binding to - * the session while the service is not running as a foreground service. + * service when all playbacks are stopped. Apps targeting API {@link + * android.os.Build.VERSION_CODES#P} or later must request the permission {@link + * android.Manifest.permission#FOREGROUND_SERVICE} in order to make the service foreground. + * + * <p>The service is destroyed when the all sessions are closed, or no media controller is binding + * to the session while the service is not running as a foreground service. + * * <h3 id="Permissions">Permissions</h3> - * <p> - * Any app can bind to the session service with controller, but the controller can be used only if - * the session service accepted the connection request through - * {@link MediaSession.SessionCallback#onConnect(MediaSession, MediaSession.ControllerInfo)}. + * + * <p>Any app can bind to the session service with controller, but the controller can be used only + * if the session service accepted the connection request through {@link + * MediaSession.SessionCallback#onConnect(MediaSession, MediaSession.ControllerInfo)}. + * * <h3 id="MultipleSessions">Supporting Multiple Sessions</h3> + * * Generally speaking, multiple sessions aren't necessary for most media apps. One exception is if * your app can play multiple media content at the same time, but only for the playback of - * video-only media or remote playback, since - * <a href="{@docRoot}guide/topics/media-apps/audio-focus.html">audio focus policy</a> recommends - * not playing multiple audio content at the same time. Also keep in mind that multiple media - * sessions would make Android Auto and Bluetooth device with display to show your apps multiple - * times, because they list up media sessions, not media apps. - * <p> - * However, if you're capable of handling multiple playback and want to keep their sessions while - * the app is in the background, create multiple sessions and add to this service with - * {@link #addSession(MediaSession)}. - * <p> - * Note that {@link MediaController} can be created with {@link SessionToken} for - * connecting any session in this service. In that case, {@link #onGetSession(ControllerInfo)} will - * be called to know which session to handle incoming connection request. Pick the best session - * among added sessions, or create new one and return from the - * {@link #onGetSession(ControllerInfo)}. - * </div> + * video-only media or remote playback, since <a + * href="{@docRoot}guide/topics/media-apps/audio-focus.html">audio focus policy</a> recommends not + * playing multiple audio content at the same time. Also keep in mind that multiple media sessions + * would make Android Auto and Bluetooth device with display to show your apps multiple times, + * because they list up media sessions, not media apps. + * + * <p>However, if you're capable of handling multiple playback and want to keep their sessions while + * the app is in the background, create multiple sessions and add to this service with {@link + * #addSession(MediaSession)}. + * + * <p>Note that {@link MediaController} can be created with {@link SessionToken} for connecting any + * session in this service. In that case, {@link #onGetSession(ControllerInfo)} will be called to + * know which session to handle incoming connection request. Pick the best session among added + * sessions, or create new one and return from the {@link #onGetSession(ControllerInfo)}. </div> + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public abstract class MediaSessionService extends Service { /** * The {@link Intent} that must be declared as handled by the service. @@ -291,10 +305,14 @@ public abstract class MediaSessionService extends Service { } /** - * Returned by {@link #onUpdateNotification(MediaSession)} for making session service - * foreground service to keep playback running in the background. It's highly recommended to - * show media style notification here. + * Returned by {@link #onUpdateNotification(MediaSession)} for making session service foreground + * service to keep playback running in the background. It's highly recommended to show media + * style notification here. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static class MediaNotification { private final int mNotificationId; private final Notification mNotification; diff --git a/media2/media2-session/src/main/java/androidx/media2/session/PercentageRating.java b/media2/media2-session/src/main/java/androidx/media2/session/PercentageRating.java index 33c2655c4ae..6a3fb9090d8 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/PercentageRating.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/PercentageRating.java @@ -23,7 +23,11 @@ import androidx.versionedparcelable.VersionedParcelize; /** * A class for rating expressed as a percentage. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated @VersionedParcelize public final class PercentageRating implements Rating { private static final float RATING_NOT_RATED = -1.0f; diff --git a/media2/media2-session/src/main/java/androidx/media2/session/RemoteResult.java b/media2/media2-session/src/main/java/androidx/media2/session/RemoteResult.java index bf836e6cdc0..9d8f72c4e78 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/RemoteResult.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/RemoteResult.java @@ -19,9 +19,13 @@ package androidx.media2.session; import androidx.media2.common.BaseResult; /** - * Base interface for result classes in {@link MediaSession} and {@link MediaController} that may - * be sent across the processes. + * Base interface for result classes in {@link MediaSession} and {@link MediaController} that may be + * sent across the processes. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated interface RemoteResult extends BaseResult { /** * Result code representing that the session and controller were disconnected. diff --git a/media2/media2-session/src/main/java/androidx/media2/session/RemoteSessionPlayer.java b/media2/media2-session/src/main/java/androidx/media2/session/RemoteSessionPlayer.java index cf2a8ca739c..9542545fe27 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/RemoteSessionPlayer.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/RemoteSessionPlayer.java @@ -31,10 +31,14 @@ import java.util.concurrent.Future; /** * Base interface for all remote media players that want media session and playback happens on the * remote device through MediaRouter. - * <p> - * If you use this to the {@link MediaSession}, session would dispatch incoming volume change event - * to the player instead of changing device stream volume. + * + * <p>If you use this to the {@link MediaSession}, session would dispatch incoming volume change + * event to the player instead of changing device stream volume. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public abstract class RemoteSessionPlayer extends SessionPlayer { /** */ @@ -123,12 +127,16 @@ public abstract class RemoteSessionPlayer extends SessionPlayer { public abstract int getVolumeControlType(); /** - * A callback class to receive notifications for events on the remote session player. See - * {@link #registerPlayerCallback(Executor, PlayerCallback)} to register this callback. - * <p> - * This is registered by {@link MediaSession} to notify volume changes to the - * {@link MediaController}. + * A callback class to receive notifications for events on the remote session player. See {@link + * #registerPlayerCallback(Executor, PlayerCallback)} to register this callback. + * + * <p>This is registered by {@link MediaSession} to notify volume changes to the {@link + * MediaController}. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static class Callback extends SessionPlayer.PlayerCallback { /** * Called to indicate that the volume has changed. diff --git a/media2/media2-session/src/main/java/androidx/media2/session/SessionCommand.java b/media2/media2-session/src/main/java/androidx/media2/session/SessionCommand.java index 9f00bc8aab4..b3e85f8f4e0 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/SessionCommand.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/SessionCommand.java @@ -46,11 +46,15 @@ import java.util.List; /** * Defines a command that a {@link MediaController} can send to a {@link MediaSession}. - * <p> - * If {@link #getCommandCode()} isn't {@link #COMMAND_CODE_CUSTOM}), it's predefined command. - * If {@link #getCommandCode()} is {@link #COMMAND_CODE_CUSTOM}), it's custom command and - * {@link #getCustomAction()} shouldn't be {@code null}. + * + * <p>If {@link #getCommandCode()} isn't {@link #COMMAND_CODE_CUSTOM}), it's predefined command. If + * {@link #getCommandCode()} is {@link #COMMAND_CODE_CUSTOM}), it's custom command and {@link + * #getCustomAction()} shouldn't be {@code null}. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated @VersionedParcelize public final class SessionCommand implements VersionedParcelable { /** diff --git a/media2/media2-session/src/main/java/androidx/media2/session/SessionCommandGroup.java b/media2/media2-session/src/main/java/androidx/media2/session/SessionCommandGroup.java index 104370ccf3c..5a124c26e6a 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/SessionCommandGroup.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/SessionCommandGroup.java @@ -38,7 +38,11 @@ import java.util.Set; /** * A set of {@link SessionCommand} which represents a command group. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated @VersionedParcelize public final class SessionCommandGroup implements VersionedParcelable { private static final String TAG = "SessionCommandGroup"; @@ -121,7 +125,11 @@ public final class SessionCommandGroup implements VersionedParcelable { /** * Builds a {@link SessionCommandGroup} object. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public static final class Builder { private Set<SessionCommand> mCommands; diff --git a/media2/media2-session/src/main/java/androidx/media2/session/SessionResult.java b/media2/media2-session/src/main/java/androidx/media2/session/SessionResult.java index 76256125cd7..151b32198cf 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/SessionResult.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/SessionResult.java @@ -40,9 +40,13 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** - * Result class to be used with {@link ListenableFuture} for asynchronous calls between - * {@link MediaSession} and {@link MediaController}. + * Result class to be used with {@link ListenableFuture} for asynchronous calls between {@link + * MediaSession} and {@link MediaController}. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated @VersionedParcelize(isCustom = true) public class SessionResult extends CustomVersionedParcelable implements RemoteResult { /** diff --git a/media2/media2-session/src/main/java/androidx/media2/session/SessionToken.java b/media2/media2-session/src/main/java/androidx/media2/session/SessionToken.java index 5bf59bf0859..b6c7f268863 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/SessionToken.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/SessionToken.java @@ -48,13 +48,16 @@ import java.lang.annotation.RetentionPolicy; import java.util.List; /** - * Represents an ongoing {@link MediaSession} or a {@link MediaSessionService}. - * If it's representing a session service, it may not be ongoing. - * <p> - * This may be passed to apps by the session owner to allow them to create a - * {@link MediaController} to communicate with the session. - * <p> - * It can be also obtained by {@link MediaSessionManager}. + * Represents an ongoing {@link MediaSession} or a {@link MediaSessionService}. If it's representing + * a session service, it may not be ongoing. + * + * <p>This may be passed to apps by the session owner to allow them to create a {@link + * MediaController} to communicate with the session. + * + * <p>It can be also obtained by {@link MediaSessionManager}. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ // New version of MediaSession.Token for following reasons // - Stop implementing Parcelable for updatable support @@ -63,6 +66,7 @@ import java.util.List; // This helps controller apps to keep target of dispatching media key events in uniform way. // For details about the reason, see following. (Android O+) // android.media.session.MediaSessionManager.Callback#onAddressedPlayerChanged +@Deprecated @VersionedParcelize public final class SessionToken implements VersionedParcelable { private static final String TAG = "SessionToken"; diff --git a/media2/media2-session/src/main/java/androidx/media2/session/StarRating.java b/media2/media2-session/src/main/java/androidx/media2/session/StarRating.java index 168a87d3fa1..f2dcef8bd87 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/StarRating.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/StarRating.java @@ -24,7 +24,11 @@ import androidx.versionedparcelable.VersionedParcelize; /** * A class for rating expressed as the number of stars. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated @VersionedParcelize public final class StarRating implements Rating { private static final float RATING_NOT_RATED = -1.0f; diff --git a/media2/media2-session/src/main/java/androidx/media2/session/ThumbRating.java b/media2/media2-session/src/main/java/androidx/media2/session/ThumbRating.java index 40f309928ca..2d5989de07f 100644 --- a/media2/media2-session/src/main/java/androidx/media2/session/ThumbRating.java +++ b/media2/media2-session/src/main/java/androidx/media2/session/ThumbRating.java @@ -23,7 +23,11 @@ import androidx.versionedparcelable.VersionedParcelize; /** * A class for rating with a single degree of rating, "thumb up" vs "thumb down". + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated @VersionedParcelize public final class ThumbRating implements Rating { @ParcelField(1) diff --git a/media2/media2-widget/api/current.txt b/media2/media2-widget/api/current.txt index c21654a3130..501d5c5bd43 100644 --- a/media2/media2-widget/api/current.txt +++ b/media2/media2-widget/api/current.txt @@ -1,37 +1,37 @@ // Signature format: 4.0 package androidx.media2.widget { - public class MediaControlView extends android.view.ViewGroup { - ctor public MediaControlView(android.content.Context); - ctor public MediaControlView(android.content.Context, android.util.AttributeSet?); - ctor public MediaControlView(android.content.Context, android.util.AttributeSet?, int); - method public void requestPlayButtonFocus(); - method public void setMediaController(androidx.media2.session.MediaController); - method public void setOnFullScreenListener(androidx.media2.widget.MediaControlView.OnFullScreenListener?); - method public void setPlayer(androidx.media2.common.SessionPlayer); + @Deprecated public class MediaControlView extends android.view.ViewGroup { + ctor @Deprecated public MediaControlView(android.content.Context); + ctor @Deprecated public MediaControlView(android.content.Context, android.util.AttributeSet?); + ctor @Deprecated public MediaControlView(android.content.Context, android.util.AttributeSet?, int); + method @Deprecated public void requestPlayButtonFocus(); + method @Deprecated public void setMediaController(androidx.media2.session.MediaController); + method @Deprecated public void setOnFullScreenListener(androidx.media2.widget.MediaControlView.OnFullScreenListener?); + method @Deprecated public void setPlayer(androidx.media2.common.SessionPlayer); } - public static interface MediaControlView.OnFullScreenListener { - method public void onFullScreen(android.view.View, boolean); + @Deprecated public static interface MediaControlView.OnFullScreenListener { + method @Deprecated public void onFullScreen(android.view.View, boolean); } - public class VideoView extends android.view.ViewGroup { - ctor public VideoView(android.content.Context); - ctor public VideoView(android.content.Context, android.util.AttributeSet?); - ctor public VideoView(android.content.Context, android.util.AttributeSet?, int); - method public androidx.media2.widget.MediaControlView? getMediaControlView(); - method public int getViewType(); - method public void setMediaControlView(androidx.media2.widget.MediaControlView, long); - method public void setMediaController(androidx.media2.session.MediaController); - method public void setOnViewTypeChangedListener(androidx.media2.widget.VideoView.OnViewTypeChangedListener?); - method public void setPlayer(androidx.media2.common.SessionPlayer); - method public void setViewType(int); - field public static final int VIEW_TYPE_SURFACEVIEW = 0; // 0x0 - field public static final int VIEW_TYPE_TEXTUREVIEW = 1; // 0x1 + @Deprecated public class VideoView extends android.view.ViewGroup { + ctor @Deprecated public VideoView(android.content.Context); + ctor @Deprecated public VideoView(android.content.Context, android.util.AttributeSet?); + ctor @Deprecated public VideoView(android.content.Context, android.util.AttributeSet?, int); + method @Deprecated public androidx.media2.widget.MediaControlView? getMediaControlView(); + method @Deprecated public int getViewType(); + method @Deprecated public void setMediaControlView(androidx.media2.widget.MediaControlView, long); + method @Deprecated public void setMediaController(androidx.media2.session.MediaController); + method @Deprecated public void setOnViewTypeChangedListener(androidx.media2.widget.VideoView.OnViewTypeChangedListener?); + method @Deprecated public void setPlayer(androidx.media2.common.SessionPlayer); + method @Deprecated public void setViewType(int); + field @Deprecated public static final int VIEW_TYPE_SURFACEVIEW = 0; // 0x0 + field @Deprecated public static final int VIEW_TYPE_TEXTUREVIEW = 1; // 0x1 } - public static interface VideoView.OnViewTypeChangedListener { - method public void onViewTypeChanged(android.view.View, int); + @Deprecated public static interface VideoView.OnViewTypeChangedListener { + method @Deprecated public void onViewTypeChanged(android.view.View, int); } } diff --git a/media2/media2-widget/api/restricted_current.txt b/media2/media2-widget/api/restricted_current.txt index c21654a3130..501d5c5bd43 100644 --- a/media2/media2-widget/api/restricted_current.txt +++ b/media2/media2-widget/api/restricted_current.txt @@ -1,37 +1,37 @@ // Signature format: 4.0 package androidx.media2.widget { - public class MediaControlView extends android.view.ViewGroup { - ctor public MediaControlView(android.content.Context); - ctor public MediaControlView(android.content.Context, android.util.AttributeSet?); - ctor public MediaControlView(android.content.Context, android.util.AttributeSet?, int); - method public void requestPlayButtonFocus(); - method public void setMediaController(androidx.media2.session.MediaController); - method public void setOnFullScreenListener(androidx.media2.widget.MediaControlView.OnFullScreenListener?); - method public void setPlayer(androidx.media2.common.SessionPlayer); + @Deprecated public class MediaControlView extends android.view.ViewGroup { + ctor @Deprecated public MediaControlView(android.content.Context); + ctor @Deprecated public MediaControlView(android.content.Context, android.util.AttributeSet?); + ctor @Deprecated public MediaControlView(android.content.Context, android.util.AttributeSet?, int); + method @Deprecated public void requestPlayButtonFocus(); + method @Deprecated public void setMediaController(androidx.media2.session.MediaController); + method @Deprecated public void setOnFullScreenListener(androidx.media2.widget.MediaControlView.OnFullScreenListener?); + method @Deprecated public void setPlayer(androidx.media2.common.SessionPlayer); } - public static interface MediaControlView.OnFullScreenListener { - method public void onFullScreen(android.view.View, boolean); + @Deprecated public static interface MediaControlView.OnFullScreenListener { + method @Deprecated public void onFullScreen(android.view.View, boolean); } - public class VideoView extends android.view.ViewGroup { - ctor public VideoView(android.content.Context); - ctor public VideoView(android.content.Context, android.util.AttributeSet?); - ctor public VideoView(android.content.Context, android.util.AttributeSet?, int); - method public androidx.media2.widget.MediaControlView? getMediaControlView(); - method public int getViewType(); - method public void setMediaControlView(androidx.media2.widget.MediaControlView, long); - method public void setMediaController(androidx.media2.session.MediaController); - method public void setOnViewTypeChangedListener(androidx.media2.widget.VideoView.OnViewTypeChangedListener?); - method public void setPlayer(androidx.media2.common.SessionPlayer); - method public void setViewType(int); - field public static final int VIEW_TYPE_SURFACEVIEW = 0; // 0x0 - field public static final int VIEW_TYPE_TEXTUREVIEW = 1; // 0x1 + @Deprecated public class VideoView extends android.view.ViewGroup { + ctor @Deprecated public VideoView(android.content.Context); + ctor @Deprecated public VideoView(android.content.Context, android.util.AttributeSet?); + ctor @Deprecated public VideoView(android.content.Context, android.util.AttributeSet?, int); + method @Deprecated public androidx.media2.widget.MediaControlView? getMediaControlView(); + method @Deprecated public int getViewType(); + method @Deprecated public void setMediaControlView(androidx.media2.widget.MediaControlView, long); + method @Deprecated public void setMediaController(androidx.media2.session.MediaController); + method @Deprecated public void setOnViewTypeChangedListener(androidx.media2.widget.VideoView.OnViewTypeChangedListener?); + method @Deprecated public void setPlayer(androidx.media2.common.SessionPlayer); + method @Deprecated public void setViewType(int); + field @Deprecated public static final int VIEW_TYPE_SURFACEVIEW = 0; // 0x0 + field @Deprecated public static final int VIEW_TYPE_TEXTUREVIEW = 1; // 0x1 } - public static interface VideoView.OnViewTypeChangedListener { - method public void onViewTypeChanged(android.view.View, int); + @Deprecated public static interface VideoView.OnViewTypeChangedListener { + method @Deprecated public void onViewTypeChanged(android.view.View, int); } } diff --git a/media2/media2-widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithPlayerTest.java b/media2/media2-widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithPlayerTest.java index 75dc06742d5..62a867fe57b 100644 --- a/media2/media2-widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithPlayerTest.java +++ b/media2/media2-widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithPlayerTest.java @@ -40,11 +40,6 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.media2.common.MediaItem; -import androidx.media2.common.MediaMetadata; -import androidx.media2.common.SessionPlayer; -import androidx.media2.common.SessionPlayer.TrackInfo; -import androidx.media2.session.MediaController; import androidx.test.filters.FlakyTest; import androidx.test.filters.LargeTest; @@ -61,8 +56,10 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; /** - * Test {@link MediaControlView} with a {@link SessionPlayer} or a {@link MediaController}. + * Test {@link MediaControlView} with a {@link androidx.media2.common.SessionPlayer} or a {@link + * androidx.media2.session.MediaController}. */ +@SuppressWarnings("deprecation") @RunWith(Parameterized.class) @LargeTest public class MediaControlView_WithPlayerTest extends MediaWidgetTestBase { @@ -77,7 +74,7 @@ public class MediaControlView_WithPlayerTest extends MediaWidgetTestBase { private String mPlayerType; private MediaControlViewTestActivity mActivity; private MediaControlView mMediaControlView; - private MediaItem mFileSchemeMediaItem; + private androidx.media2.common.MediaItem mFileSchemeMediaItem; @SuppressWarnings("deprecation") @Rule @@ -120,16 +117,25 @@ public class MediaControlView_WithPlayerTest extends MediaWidgetTestBase { public void setPlayerOrController_PausedState() throws Throwable { final CountDownLatch latchForPausedState = new CountDownLatch(1); final CountDownLatch latchForPlayingState = new CountDownLatch(1); - final PlayerWrapper playerWrapper = createPlayerWrapper(new PlayerWrapper.PlayerCallback() { - @Override - public void onPlayerStateChanged(@NonNull PlayerWrapper player, int state) { - if (state == SessionPlayer.PLAYER_STATE_PAUSED) { - latchForPausedState.countDown(); - } else if (state == SessionPlayer.PLAYER_STATE_PLAYING) { - latchForPlayingState.countDown(); - } - } - }, mFileSchemeMediaItem, null); + final PlayerWrapper playerWrapper = + createPlayerWrapper( + new PlayerWrapper.PlayerCallback() { + @Override + public void onPlayerStateChanged( + @NonNull PlayerWrapper player, int state) { + if (state + == androidx.media2.common.SessionPlayer + .PLAYER_STATE_PAUSED) { + latchForPausedState.countDown(); + } else if (state + == androidx.media2.common.SessionPlayer + .PLAYER_STATE_PLAYING) { + latchForPlayingState.countDown(); + } + } + }, + mFileSchemeMediaItem, + null); setPlayerWrapper(playerWrapper); assertTrue(latchForPausedState.await(WAIT_TIME_MS, TimeUnit.MILLISECONDS)); onView(allOf(withId(R.id.pause), isCompletelyDisplayed())) @@ -148,25 +154,39 @@ public class MediaControlView_WithPlayerTest extends MediaWidgetTestBase { final CountDownLatch latchForPreparedState = new CountDownLatch(1); final CountDownLatch latchForPausedState = new CountDownLatch(1); final CountDownLatch latchForPlayingState = new CountDownLatch(1); - final PlayerWrapper playerWrapper = createPlayerWrapper(new PlayerWrapper.PlayerCallback() { - private int mState = SessionPlayer.PLAYER_STATE_IDLE; - - @Override - public void onPlayerStateChanged(@NonNull PlayerWrapper player, int state) { - if (mState == SessionPlayer.PLAYER_STATE_IDLE - && state == SessionPlayer.PLAYER_STATE_PAUSED) { - latchForPreparedState.countDown(); - } - if (state == SessionPlayer.PLAYER_STATE_PLAYING) { - latchForPlayingState.countDown(); - } - if (mState == SessionPlayer.PLAYER_STATE_PLAYING - && state == SessionPlayer.PLAYER_STATE_PAUSED) { - latchForPausedState.countDown(); - } - mState = state; - } - }, mFileSchemeMediaItem, null); + final PlayerWrapper playerWrapper = + createPlayerWrapper( + new PlayerWrapper.PlayerCallback() { + private int mState = + androidx.media2.common.SessionPlayer.PLAYER_STATE_IDLE; + + @Override + public void onPlayerStateChanged( + @NonNull PlayerWrapper player, int state) { + if (mState == androidx.media2.common.SessionPlayer.PLAYER_STATE_IDLE + && state + == androidx.media2.common.SessionPlayer + .PLAYER_STATE_PAUSED) { + latchForPreparedState.countDown(); + } + if (state + == androidx.media2.common.SessionPlayer + .PLAYER_STATE_PLAYING) { + latchForPlayingState.countDown(); + } + if (mState + == androidx.media2.common.SessionPlayer + .PLAYER_STATE_PLAYING + && state + == androidx.media2.common.SessionPlayer + .PLAYER_STATE_PAUSED) { + latchForPausedState.countDown(); + } + mState = state; + } + }, + mFileSchemeMediaItem, + null); assertTrue(latchForPreparedState.await(WAIT_TIME_MS, TimeUnit.MILLISECONDS)); playerWrapper.play(); assertTrue(latchForPlayingState.await(WAIT_TIME_MS, TimeUnit.MILLISECONDS)); @@ -234,21 +254,29 @@ public class MediaControlView_WithPlayerTest extends MediaWidgetTestBase { public void ffwdButtonClick() throws Throwable { final CountDownLatch latchForPausedState = new CountDownLatch(1); final CountDownLatch latchForFfwd = new CountDownLatch(1); - final PlayerWrapper playerWrapper = createPlayerWrapper(new PlayerWrapper.PlayerCallback() { - @Override - public void onSeekCompleted(@NonNull PlayerWrapper player, long position) { - if (position >= FFWD_MS) { - latchForFfwd.countDown(); - } - } - - @Override - public void onPlayerStateChanged(@NonNull PlayerWrapper player, int state) { - if (state == SessionPlayer.PLAYER_STATE_PAUSED) { - latchForPausedState.countDown(); - } - } - }, mFileSchemeMediaItem, null); + final PlayerWrapper playerWrapper = + createPlayerWrapper( + new PlayerWrapper.PlayerCallback() { + @Override + public void onSeekCompleted( + @NonNull PlayerWrapper player, long position) { + if (position >= FFWD_MS) { + latchForFfwd.countDown(); + } + } + + @Override + public void onPlayerStateChanged( + @NonNull PlayerWrapper player, int state) { + if (state + == androidx.media2.common.SessionPlayer + .PLAYER_STATE_PAUSED) { + latchForPausedState.countDown(); + } + } + }, + mFileSchemeMediaItem, + null); setPlayerWrapper(playerWrapper); assertTrue(latchForPausedState.await(WAIT_TIME_MS, TimeUnit.MILLISECONDS)); onView(allOf(withId(R.id.ffwd), isCompletelyDisplayed())).perform(click()); @@ -259,37 +287,47 @@ public class MediaControlView_WithPlayerTest extends MediaWidgetTestBase { public void rewButtonClick() throws Throwable { final CountDownLatch latchForFfwd = new CountDownLatch(1); final CountDownLatch latchForRew = new CountDownLatch(1); - final PlayerWrapper playerWrapper = createPlayerWrapper(new PlayerWrapper.PlayerCallback() { - long mExpectedPosition = FFWD_MS; - final long mDelta = 1000L; - - @Override - public void onPlayerStateChanged(@NonNull PlayerWrapper player, int state) { - if (state == SessionPlayer.PLAYER_STATE_PAUSED) { - mExpectedPosition = FFWD_MS; - player.seekTo(mExpectedPosition); - } - } - - @Override - public void onSeekCompleted(@NonNull PlayerWrapper player, long position) { - // Ignore the initial seek. Internal MediaPlayer behavior can be changed. - if (position == 0 && mExpectedPosition == FFWD_MS) { - return; - } - assertTrue(equalsSeekPosition(mExpectedPosition, position, mDelta)); - if (mExpectedPosition == FFWD_MS) { - mExpectedPosition = position - REW_MS; - latchForFfwd.countDown(); - } else { - latchForRew.countDown(); - } - } - - private boolean equalsSeekPosition(long expected, long actual, long delta) { - return (actual < expected + delta) && (actual > expected - delta); - } - }, mFileSchemeMediaItem, null); + final PlayerWrapper playerWrapper = + createPlayerWrapper( + new PlayerWrapper.PlayerCallback() { + long mExpectedPosition = FFWD_MS; + final long mDelta = 1000L; + + @Override + public void onPlayerStateChanged( + @NonNull PlayerWrapper player, int state) { + if (state + == androidx.media2.common.SessionPlayer + .PLAYER_STATE_PAUSED) { + mExpectedPosition = FFWD_MS; + player.seekTo(mExpectedPosition); + } + } + + @Override + public void onSeekCompleted( + @NonNull PlayerWrapper player, long position) { + // Ignore the initial seek. Internal MediaPlayer behavior can be + // changed. + if (position == 0 && mExpectedPosition == FFWD_MS) { + return; + } + assertTrue(equalsSeekPosition(mExpectedPosition, position, mDelta)); + if (mExpectedPosition == FFWD_MS) { + mExpectedPosition = position - REW_MS; + latchForFfwd.countDown(); + } else { + latchForRew.countDown(); + } + } + + private boolean equalsSeekPosition( + long expected, long actual, long delta) { + return (actual < expected + delta) && (actual > expected - delta); + } + }, + mFileSchemeMediaItem, + null); setPlayerWrapper(playerWrapper); assertTrue(latchForFfwd.await(WAIT_TIME_MS, TimeUnit.MILLISECONDS)); onView(allOf(withId(R.id.rew), isCompletelyDisplayed())).perform(click()); @@ -299,7 +337,7 @@ public class MediaControlView_WithPlayerTest extends MediaWidgetTestBase { @Test public void prevNextButtonClick() throws Throwable { DefaultPlayerCallback callback = new DefaultPlayerCallback(); - final List<MediaItem> playlist = createTestPlaylist(); + final List<androidx.media2.common.MediaItem> playlist = createTestPlaylist(); final PlayerWrapper playerWrapper = createPlayerWrapper(callback, null, playlist); setPlayerWrapper(playerWrapper); @@ -338,26 +376,37 @@ public class MediaControlView_WithPlayerTest extends MediaWidgetTestBase { final String title = "BigBuckBunny"; final CountDownLatch latch = new CountDownLatch(1); - MediaMetadata existingMetadata = mFileSchemeMediaItem.getMetadata(); - MediaMetadata.Builder metadataBuilder = existingMetadata == null - ? new MediaMetadata.Builder() - : new MediaMetadata.Builder(existingMetadata); - MediaMetadata metadata = metadataBuilder - .putString(MediaMetadata.METADATA_KEY_TITLE, title) - .build(); + androidx.media2.common.MediaMetadata existingMetadata = mFileSchemeMediaItem.getMetadata(); + androidx.media2.common.MediaMetadata.Builder metadataBuilder = + existingMetadata == null + ? new androidx.media2.common.MediaMetadata.Builder() + : new androidx.media2.common.MediaMetadata.Builder(existingMetadata); + androidx.media2.common.MediaMetadata metadata = + metadataBuilder + .putString(androidx.media2.common.MediaMetadata.METADATA_KEY_TITLE, title) + .build(); mFileSchemeMediaItem.setMetadata(metadata); - final PlayerWrapper playerWrapper = createPlayerWrapper(new PlayerWrapper.PlayerCallback() { - @Override - public void onCurrentMediaItemChanged(@NonNull PlayerWrapper player, - @Nullable MediaItem item) { - if (item != null) { - assertNotNull(item.getMetadata()); - assertEquals(title, metadata.getString(MediaMetadata.METADATA_KEY_TITLE)); - latch.countDown(); - } - } - }, mFileSchemeMediaItem, null); + final PlayerWrapper playerWrapper = + createPlayerWrapper( + new PlayerWrapper.PlayerCallback() { + @Override + public void onCurrentMediaItemChanged( + @NonNull PlayerWrapper player, + @Nullable androidx.media2.common.MediaItem item) { + if (item != null) { + assertNotNull(item.getMetadata()); + assertEquals( + title, + metadata.getString( + androidx.media2.common.MediaMetadata + .METADATA_KEY_TITLE)); + latch.countDown(); + } + } + }, + mFileSchemeMediaItem, + null); setPlayerWrapper(playerWrapper); assertTrue(latch.await(WAIT_TIME_MS, TimeUnit.MILLISECONDS)); onView(withId(R.id.title_text)).check(matches(withText(title))); @@ -366,20 +415,29 @@ public class MediaControlView_WithPlayerTest extends MediaWidgetTestBase { @Test public void subtitleButtonVisibilityForMusicFile() throws Throwable { Uri uri = getResourceUri(androidx.media2.widget.test.R.raw.test_music); - final MediaItem uriMediaItem = createTestMediaItem(uri); + final androidx.media2.common.MediaItem uriMediaItem = createTestMediaItem(uri); final CountDownLatch latch = new CountDownLatch(1); - final PlayerWrapper playerWrapper = createPlayerWrapper(new PlayerWrapper.PlayerCallback() { - @Override - void onTracksChanged(@NonNull PlayerWrapper player, @NonNull List<TrackInfo> tracks) { - assertNotNull(tracks); - if (tracks.isEmpty()) { - // This callback can be called before tracks are available after setMediaItem - return; - } - latch.countDown(); - } - }, uriMediaItem, null); + final PlayerWrapper playerWrapper = + createPlayerWrapper( + new PlayerWrapper.PlayerCallback() { + @Override + void onTracksChanged( + @NonNull PlayerWrapper player, + @NonNull + List<androidx.media2.common.SessionPlayer.TrackInfo> + tracks) { + assertNotNull(tracks); + if (tracks.isEmpty()) { + // This callback can be called before tracks are available after + // setandroidx.media2.common.MediaItem + return; + } + latch.countDown(); + } + }, + uriMediaItem, + null); setPlayerWrapper(playerWrapper); assertTrue(latch.await(WAIT_TIME_MS, TimeUnit.MILLISECONDS)); onView(withId(R.id.subtitle)).check(matches(not(isDisplayed()))); @@ -395,52 +453,73 @@ public class MediaControlView_WithPlayerTest extends MediaWidgetTestBase { final String subtitleTrack1Text = mContext.getResources().getString( R.string.MediaControlView_subtitle_track_number_text, 1); - final MediaItem mediaItem = createTestMediaItem(uri); + final androidx.media2.common.MediaItem mediaItem = createTestMediaItem(uri); final CountDownLatch latchForReady = new CountDownLatch(1); final CountDownLatch latchForTrackUpdate = new CountDownLatch(1); final CountDownLatch latchForSubtitleSelect = new CountDownLatch(1); final CountDownLatch latchForSubtitleDeselect = new CountDownLatch(1); - final PlayerWrapper playerWrapper = createPlayerWrapper(new PlayerWrapper.PlayerCallback() { - private TrackInfo mFirstSubtitleTrack; - - @Override - public void onPlayerStateChanged(@NonNull PlayerWrapper player, int state) { - if (state == SessionPlayer.PLAYER_STATE_PAUSED) { - latchForReady.countDown(); - } - } - - @Override - void onTracksChanged(@NonNull PlayerWrapper player, @NonNull List<TrackInfo> tracks) { - if (mFirstSubtitleTrack != null) { - return; - } - assertNotNull(tracks); - for (int i = 0; i < tracks.size(); i++) { - TrackInfo trackInfo = tracks.get(i); - if (trackInfo.getTrackType() == TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE) { - mFirstSubtitleTrack = trackInfo; - latchForTrackUpdate.countDown(); - break; - } - } - } - - @Override - public void onTrackSelected(@NonNull PlayerWrapper player, - @NonNull TrackInfo trackInfo) { - assertEquals(mFirstSubtitleTrack, trackInfo); - latchForSubtitleSelect.countDown(); - } - - @Override - public void onTrackDeselected(@NonNull PlayerWrapper player, - @NonNull TrackInfo trackInfo) { - assertEquals(mFirstSubtitleTrack, trackInfo); - latchForSubtitleDeselect.countDown(); - } - }, mediaItem, null); + final PlayerWrapper playerWrapper = + createPlayerWrapper( + new PlayerWrapper.PlayerCallback() { + private androidx.media2.common.SessionPlayer.TrackInfo + mFirstSubtitleTrack; + + @Override + public void onPlayerStateChanged( + @NonNull PlayerWrapper player, int state) { + if (state + == androidx.media2.common.SessionPlayer + .PLAYER_STATE_PAUSED) { + latchForReady.countDown(); + } + } + + @Override + void onTracksChanged( + @NonNull PlayerWrapper player, + @NonNull + List<androidx.media2.common.SessionPlayer.TrackInfo> + tracks) { + if (mFirstSubtitleTrack != null) { + return; + } + assertNotNull(tracks); + for (int i = 0; i < tracks.size(); i++) { + androidx.media2.common.SessionPlayer.TrackInfo trackInfo = + tracks.get(i); + if (trackInfo.getTrackType() + == androidx.media2.common.SessionPlayer.TrackInfo + .MEDIA_TRACK_TYPE_SUBTITLE) { + mFirstSubtitleTrack = trackInfo; + latchForTrackUpdate.countDown(); + break; + } + } + } + + @Override + public void onTrackSelected( + @NonNull PlayerWrapper player, + @NonNull + androidx.media2.common.SessionPlayer.TrackInfo + trackInfo) { + assertEquals(mFirstSubtitleTrack, trackInfo); + latchForSubtitleSelect.countDown(); + } + + @Override + public void onTrackDeselected( + @NonNull PlayerWrapper player, + @NonNull + androidx.media2.common.SessionPlayer.TrackInfo + trackInfo) { + assertEquals(mFirstSubtitleTrack, trackInfo); + latchForSubtitleDeselect.countDown(); + } + }, + mediaItem, + null); setPlayerWrapper(playerWrapper); assertTrue(latchForReady.await(WAIT_TIME_MS, TimeUnit.MILLISECONDS)); // MediaPlayer needs a surface to be set in order to produce subtitle tracks @@ -466,16 +545,25 @@ public class MediaControlView_WithPlayerTest extends MediaWidgetTestBase { public void attachViewAndPlayAfterSetPlayerOrController() throws Throwable { final CountDownLatch latchForPausedState = new CountDownLatch(1); final CountDownLatch latchForPlayingState = new CountDownLatch(1); - final PlayerWrapper playerWrapper = createPlayerWrapper(new PlayerWrapper.PlayerCallback() { - @Override - public void onPlayerStateChanged(@NonNull PlayerWrapper player, int state) { - if (state == SessionPlayer.PLAYER_STATE_PAUSED) { - latchForPausedState.countDown(); - } else if (state == SessionPlayer.PLAYER_STATE_PLAYING) { - latchForPlayingState.countDown(); - } - } - }, mFileSchemeMediaItem, null); + final PlayerWrapper playerWrapper = + createPlayerWrapper( + new PlayerWrapper.PlayerCallback() { + @Override + public void onPlayerStateChanged( + @NonNull PlayerWrapper player, int state) { + if (state + == androidx.media2.common.SessionPlayer + .PLAYER_STATE_PAUSED) { + latchForPausedState.countDown(); + } else if (state + == androidx.media2.common.SessionPlayer + .PLAYER_STATE_PLAYING) { + latchForPlayingState.countDown(); + } + } + }, + mFileSchemeMediaItem, + null); mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { @@ -514,8 +602,10 @@ public class MediaControlView_WithPlayerTest extends MediaWidgetTestBase { }); } - private PlayerWrapper createPlayerWrapper(@NonNull PlayerWrapper.PlayerCallback callback, - @Nullable MediaItem item, @Nullable List<MediaItem> playlist) { + private PlayerWrapper createPlayerWrapper( + @NonNull PlayerWrapper.PlayerCallback callback, + @Nullable androidx.media2.common.MediaItem item, + @Nullable List<androidx.media2.common.MediaItem> playlist) { return createPlayerWrapperOfType(callback, item, playlist, mPlayerType); } } diff --git a/media2/media2-widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithoutPlayerTest.java b/media2/media2-widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithoutPlayerTest.java index d90a643f554..2db77e9fc38 100644 --- a/media2/media2-widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithoutPlayerTest.java +++ b/media2/media2-widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithoutPlayerTest.java @@ -43,9 +43,10 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; /** - * Test {@link MediaControlView} without any {@link androidx.media2.common.SessionPlayer} or - * {@link androidx.media2.session.MediaController}. + * Test {@link MediaControlView} without any {@link androidx.media2.common.SessionPlayer} or {@link + * androidx.media2.session.MediaController}. */ +@SuppressWarnings("deprecation") @RunWith(AndroidJUnit4.class) @LargeTest public class MediaControlView_WithoutPlayerTest extends MediaWidgetTestBase { diff --git a/media2/media2-widget/src/androidTest/java/androidx/media2/widget/MediaWidgetTestBase.java b/media2/media2-widget/src/androidTest/java/androidx/media2/widget/MediaWidgetTestBase.java index 232b8e1ed84..fcf4b407e8b 100644 --- a/media2/media2-widget/src/androidTest/java/androidx/media2/widget/MediaWidgetTestBase.java +++ b/media2/media2-widget/src/androidTest/java/androidx/media2/widget/MediaWidgetTestBase.java @@ -29,13 +29,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import androidx.core.view.ViewCompat; -import androidx.media2.common.MediaItem; -import androidx.media2.common.MediaMetadata; -import androidx.media2.common.SessionPlayer; -import androidx.media2.common.UriMediaItem; -import androidx.media2.player.MediaPlayer; -import androidx.media2.session.MediaController; -import androidx.media2.session.MediaSession; import androidx.media2.widget.test.R; import androidx.test.core.app.ApplicationProvider; @@ -49,21 +42,25 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +@SuppressWarnings("deprecation") public class MediaWidgetTestBase extends MediaTestBase { - static final String PLAYER_TYPE_MEDIA_CONTROLLER = "MediaController"; - static final String PLAYER_TYPE_MEDIA_PLAYER = "MediaPlayer"; + static final String PLAYER_TYPE_MEDIA_CONTROLLER = "androidx.media2.session.MediaController"; + static final String PLAYER_TYPE_MEDIA_PLAYER = "androidx.media2.player.MediaPlayer"; // Expected success time // Increased timeout to pass on old devices (ex. Nexus4 API 17) static final int WAIT_TIME_MS = 2000; private final Object mLock = new Object(); + @GuardedBy("mLock") - private List<SessionPlayer> mPlayers = new ArrayList<>(); + private List<androidx.media2.common.SessionPlayer> mPlayers = new ArrayList<>(); + @GuardedBy("mLock") - private List<MediaSession> mSessions = new ArrayList<>(); + private List<androidx.media2.session.MediaSession> mSessions = new ArrayList<>(); + @GuardedBy("mLock") - private List<MediaController> mControllers = new ArrayList<>(); + private List<androidx.media2.session.MediaController> mControllers = new ArrayList<>(); Context mContext; Executor mMainHandlerExecutor; @@ -93,26 +90,26 @@ public class MediaWidgetTestBase extends MediaTestBase { } } - MediaItem createTestMediaItem() { + androidx.media2.common.MediaItem createTestMediaItem() { Uri testVideoUri = getResourceUri(R.raw.testvideo_with_2_subtitle_tracks); return createTestMediaItem(testVideoUri); } - MediaItem createTestMediaItem(Uri uri) { + androidx.media2.common.MediaItem createTestMediaItem(Uri uri) { return createTestMediaItem(uri, "defaultMediaId"); } - MediaItem createTestMediaItem(Uri uri, String mediaId) { - MediaMetadata metadata = new MediaMetadata.Builder() - .putText(MediaMetadata.METADATA_KEY_MEDIA_ID, mediaId) - .build(); - return new UriMediaItem.Builder(uri) - .setMetadata(metadata) - .build(); + androidx.media2.common.MediaItem createTestMediaItem(Uri uri, String mediaId) { + androidx.media2.common.MediaMetadata metadata = + new androidx.media2.common.MediaMetadata.Builder() + .putText( + androidx.media2.common.MediaMetadata.METADATA_KEY_MEDIA_ID, mediaId) + .build(); + return new androidx.media2.common.UriMediaItem.Builder(uri).setMetadata(metadata).build(); } - List<MediaItem> createTestPlaylist() { - List<MediaItem> list = new ArrayList<>(); + List<androidx.media2.common.MediaItem> createTestPlaylist() { + List<androidx.media2.common.MediaItem> list = new ArrayList<>(); list.add(createTestMediaItem(getResourceUri(R.raw.test_file_scheme_video), "id_1")); list.add(createTestMediaItem(getResourceUri(R.raw.test_music), "id_2")); list.add(createTestMediaItem(getResourceUri(R.raw.testvideo_with_2_subtitle_tracks), @@ -125,16 +122,23 @@ public class MediaWidgetTestBase extends MediaTestBase { } @SuppressWarnings("FutureReturnValueIgnored") - PlayerWrapper createPlayerWrapperOfController(@NonNull PlayerWrapper.PlayerCallback callback, - @Nullable MediaItem item, @Nullable List<MediaItem> playlist) { - SessionPlayer player = new MediaPlayer(mContext); - MediaSession session = new MediaSession.Builder(mContext, player) - .setId(UUID.randomUUID().toString()) - .setSessionCallback(mSessionCallbackExecutor, new MediaSession.SessionCallback() {}) - .build(); - MediaController controller = new MediaController.Builder(mContext) - .setSessionToken(session.getToken()) - .build(); + PlayerWrapper createPlayerWrapperOfController( + @NonNull PlayerWrapper.PlayerCallback callback, + @Nullable androidx.media2.common.MediaItem item, + @Nullable List<androidx.media2.common.MediaItem> playlist) { + androidx.media2.common.SessionPlayer player = + new androidx.media2.player.MediaPlayer(mContext); + androidx.media2.session.MediaSession session = + new androidx.media2.session.MediaSession.Builder(mContext, player) + .setId(UUID.randomUUID().toString()) + .setSessionCallback( + mSessionCallbackExecutor, + new androidx.media2.session.MediaSession.SessionCallback() {}) + .build(); + androidx.media2.session.MediaController controller = + new androidx.media2.session.MediaController.Builder(mContext) + .setSessionToken(session.getToken()) + .build(); synchronized (mLock) { mPlayers.add(player); mSessions.add(session); @@ -153,9 +157,12 @@ public class MediaWidgetTestBase extends MediaTestBase { } @SuppressWarnings("FutureReturnValueIgnored") - PlayerWrapper createPlayerWrapperOfPlayer(@NonNull PlayerWrapper.PlayerCallback callback, - @Nullable MediaItem item, @Nullable List<MediaItem> playlist) { - SessionPlayer player = new MediaPlayer(mContext); + PlayerWrapper createPlayerWrapperOfPlayer( + @NonNull PlayerWrapper.PlayerCallback callback, + @Nullable androidx.media2.common.MediaItem item, + @Nullable List<androidx.media2.common.MediaItem> playlist) { + androidx.media2.common.SessionPlayer player = + new androidx.media2.player.MediaPlayer(mContext); synchronized (mLock) { mPlayers.add(player); } @@ -171,8 +178,10 @@ public class MediaWidgetTestBase extends MediaTestBase { return wrapper; } - PlayerWrapper createPlayerWrapperOfType(@NonNull PlayerWrapper.PlayerCallback callback, - @Nullable MediaItem item, @Nullable List<MediaItem> playlist, + PlayerWrapper createPlayerWrapperOfType( + @NonNull PlayerWrapper.PlayerCallback callback, + @Nullable androidx.media2.common.MediaItem item, + @Nullable List<androidx.media2.common.MediaItem> playlist, @NonNull String playerType) { if (PLAYER_TYPE_MEDIA_CONTROLLER.equals(playerType)) { return createPlayerWrapperOfController(callback, item, playlist); @@ -185,13 +194,13 @@ public class MediaWidgetTestBase extends MediaTestBase { void closeAll() { synchronized (mLock) { - for (MediaController controller : mControllers) { + for (androidx.media2.session.MediaController controller : mControllers) { controller.close(); } - for (MediaSession session : mSessions) { + for (androidx.media2.session.MediaSession session : mSessions) { session.close(); } - for (SessionPlayer player : mPlayers) { + for (androidx.media2.common.SessionPlayer player : mPlayers) { try { player.close(); } catch (Exception ex) { @@ -211,8 +220,8 @@ public class MediaWidgetTestBase extends MediaTestBase { String mPrevId = "placeholderId"; @Override - void onCurrentMediaItemChanged(@NonNull PlayerWrapper player, - @Nullable MediaItem item) { + void onCurrentMediaItemChanged( + @NonNull PlayerWrapper player, @Nullable androidx.media2.common.MediaItem item) { if (item != null && !TextUtils.equals(mPrevId, item.getMediaId())) { mPrevId = item.getMediaId(); mItemLatch.countDown(); @@ -221,9 +230,9 @@ public class MediaWidgetTestBase extends MediaTestBase { @Override void onPlayerStateChanged(@NonNull PlayerWrapper player, int state) { - if (state == SessionPlayer.PLAYER_STATE_PAUSED) { + if (state == androidx.media2.common.SessionPlayer.PLAYER_STATE_PAUSED) { mPausedLatch.countDown(); - } else if (state == SessionPlayer.PLAYER_STATE_PLAYING) { + } else if (state == androidx.media2.common.SessionPlayer.PLAYER_STATE_PLAYING) { mPlayingLatch.countDown(); } } diff --git a/media2/media2-widget/src/androidTest/java/androidx/media2/widget/VideoView_WithPlayerTest.java b/media2/media2-widget/src/androidTest/java/androidx/media2/widget/VideoView_WithPlayerTest.java index a94604b6b6f..b4df7e51949 100644 --- a/media2/media2-widget/src/androidTest/java/androidx/media2/widget/VideoView_WithPlayerTest.java +++ b/media2/media2-widget/src/androidTest/java/androidx/media2/widget/VideoView_WithPlayerTest.java @@ -45,11 +45,6 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.UiThread; -import androidx.media2.common.FileMediaItem; -import androidx.media2.common.MediaItem; -import androidx.media2.common.SessionPlayer; -import androidx.media2.common.VideoSize; -import androidx.media2.session.MediaController; import androidx.media2.widget.test.R; import androidx.test.filters.LargeTest; @@ -66,8 +61,10 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; /** - * Test {@link VideoView} with a {@link SessionPlayer} or a {@link MediaController}. + * Test {@link VideoView} with a {@link androidx.media2.common.SessionPlayer} or a {@link + * androidx.media2.session.MediaController}. */ +@SuppressWarnings("deprecation") @RunWith(Parameterized.class) @LargeTest public class VideoView_WithPlayerTest extends MediaWidgetTestBase { @@ -79,7 +76,7 @@ public class VideoView_WithPlayerTest extends MediaWidgetTestBase { private String mPlayerType; private Activity mActivity; private VideoView mVideoView; - private MediaItem mMediaItem; + private androidx.media2.common.MediaItem mMediaItem; private SynchronousPixelCopy mPixelCopyHelper; @SuppressWarnings("deprecation") @@ -126,7 +123,9 @@ public class VideoView_WithPlayerTest extends MediaWidgetTestBase { assertTrue(callback.mItemLatch.await(WAIT_TIME_MS, TimeUnit.MILLISECONDS)); assertTrue(callback.mPausedLatch.await(WAIT_TIME_MS, TimeUnit.MILLISECONDS)); assertEquals(1, callback.mPlayingLatch.getCount()); - assertEquals(SessionPlayer.PLAYER_STATE_PAUSED, playerWrapper.getPlayerState()); + assertEquals( + androidx.media2.common.SessionPlayer.PLAYER_STATE_PAUSED, + playerWrapper.getPlayerState()); playerWrapper.play(); assertTrue(callback.mPlayingLatch.await(WAIT_TIME_MS, TimeUnit.MILLISECONDS)); @@ -137,11 +136,12 @@ public class VideoView_WithPlayerTest extends MediaWidgetTestBase { public void playVideoWithMediaItemFromFileDescriptor() throws Throwable { AssetFileDescriptor afd = mContext.getResources() .openRawResourceFd(R.raw.testvideo_with_2_subtitle_tracks); - final MediaItem item = new FileMediaItem.Builder( - ParcelFileDescriptor.dup(afd.getFileDescriptor())) - .setFileDescriptorOffset(afd.getStartOffset()) - .setFileDescriptorLength(afd.getLength()) - .build(); + final androidx.media2.common.MediaItem item = + new androidx.media2.common.FileMediaItem.Builder( + ParcelFileDescriptor.dup(afd.getFileDescriptor())) + .setFileDescriptorOffset(afd.getStartOffset()) + .setFileDescriptorLength(afd.getLength()) + .build(); afd.close(); DefaultPlayerCallback callback = new DefaultPlayerCallback(); @@ -342,8 +342,10 @@ public class VideoView_WithPlayerTest extends MediaWidgetTestBase { @Test public void aspectRatioOfSurfaceView() throws Throwable { - MediaItem testMediaItem = createTestMediaItem(getResourceUri(R.raw.test_file_scheme_video)); - VideoSize testVideoSize = new VideoSize(352, 288); + androidx.media2.common.MediaItem testMediaItem = + createTestMediaItem(getResourceUri(R.raw.test_file_scheme_video)); + androidx.media2.common.VideoSize testVideoSize = + new androidx.media2.common.VideoSize(352, 288); CountDownLatch latch = new CountDownLatch(1); mActivityRule.runOnUiThread(() -> { @@ -375,7 +377,8 @@ public class VideoView_WithPlayerTest extends MediaWidgetTestBase { withAspectRatio(testVideoSize.getWidth(), testVideoSize.getHeight()))); // Unable to test the case for multiple media items with different aspect ratio due to the - // flakiness of onVideoSizeChanged of MediaPlayer (b/144876689, b/144972397) + // flakiness of onandroidx.media2.common.VideoSizeChanged of MediaPlayer (b/144876689, + // b/144972397) } private void setPlayerWrapper(final PlayerWrapper playerWrapper) throws Throwable { @@ -391,8 +394,10 @@ public class VideoView_WithPlayerTest extends MediaWidgetTestBase { }); } - private PlayerWrapper createPlayerWrapper(@NonNull PlayerWrapper.PlayerCallback callback, - @Nullable MediaItem item, @Nullable List<MediaItem> playlist) { + private PlayerWrapper createPlayerWrapper( + @NonNull PlayerWrapper.PlayerCallback callback, + @Nullable androidx.media2.common.MediaItem item, + @Nullable List<androidx.media2.common.MediaItem> playlist) { return createPlayerWrapperOfType(callback, item, playlist, mPlayerType); } diff --git a/media2/media2-widget/src/androidTest/java/androidx/media2/widget/VideoView_WithoutPlayerTest.java b/media2/media2-widget/src/androidTest/java/androidx/media2/widget/VideoView_WithoutPlayerTest.java index 33abeb925b3..691a1f72094 100644 --- a/media2/media2-widget/src/androidTest/java/androidx/media2/widget/VideoView_WithoutPlayerTest.java +++ b/media2/media2-widget/src/androidTest/java/androidx/media2/widget/VideoView_WithoutPlayerTest.java @@ -31,9 +31,10 @@ import org.junit.Test; import org.junit.runner.RunWith; /** - * Test {@link VideoView} without any {@link androidx.media2.common.SessionPlayer} or - * {@link androidx.media2.session.MediaController}. + * Test {@link VideoView} without any {@link androidx.media2.common.SessionPlayer} or {@link + * androidx.media2.session.MediaController}. */ +@SuppressWarnings("deprecation") @RunWith(AndroidJUnit4.class) @LargeTest public class VideoView_WithoutPlayerTest extends MediaWidgetTestBase { diff --git a/media2/media2-widget/src/main/java/androidx/media2/widget/MediaControlView.java b/media2/media2-widget/src/main/java/androidx/media2/widget/MediaControlView.java index 9e7b110031c..6ef9ac9077a 100644 --- a/media2/media2-widget/src/main/java/androidx/media2/widget/MediaControlView.java +++ b/media2/media2-widget/src/main/java/androidx/media2/widget/MediaControlView.java @@ -52,16 +52,6 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.core.content.ContextCompat; import androidx.core.view.ViewCompat; -import androidx.media2.common.MediaItem; -import androidx.media2.common.MediaMetadata; -import androidx.media2.common.SessionPlayer; -import androidx.media2.common.SessionPlayer.TrackInfo; -import androidx.media2.common.UriMediaItem; -import androidx.media2.common.VideoSize; -import androidx.media2.session.MediaController; -import androidx.media2.session.MediaSession; -import androidx.media2.session.SessionCommand; -import androidx.media2.session.SessionCommandGroup; import java.util.ArrayList; import java.util.Arrays; @@ -70,91 +60,112 @@ import java.util.List; import java.util.Locale; /** - * A View that contains the controls for {@link MediaController} or {@link SessionPlayer}. - * It provides a wide range of buttons that serve the following functions: play/pause, - * rewind/fast-forward, skip to next/previous, select subtitle track, enter/exit full screen mode, - * select audio track, and adjust playback speed. - * <p> - * For simple use cases not requiring communication with {@link MediaSession}, apps need to create - * a {@link SessionPlayer} (e.g. {@link androidx.media2.player.MediaPlayer}) and set it to this view - * by calling {@link #setPlayer}. - * For more advanced use cases that require {@link MediaSession} (e.g. handling media key events, - * integrating with other MediaSession apps as Assistant), apps need to create - * a {@link MediaController} attached to the {@link MediaSession} and set it to this view - * by calling {@link #setMediaController}. - * <p> - * The easiest way to use a MediaControlView is by creating a {@link VideoView}, which - * internally creates a MediaControlView instance and handles all the commands from buttons inside - * MediaControlView. It is also possible to create a MediaControlView programmatically and add it - * to a custom video view. For more information, refer to {@link VideoView}. - * <p> - * By default, each button in the MediaControlView is visible only when its corresponding - * {@link SessionCommand} is included in the active {@link SessionCommandGroup}. - * For more details, refer to {@link MediaSession#setAllowedCommands}. + * A View that contains the controls for {@link androidx.media2.session.MediaController} or {@link + * androidx.media2.common.SessionPlayer}. It provides a wide range of buttons that serve the + * following functions: play/pause, rewind/fast-forward, skip to next/previous, select subtitle + * track, enter/exit full screen mode, select audio track, and adjust playback speed. + * + * <p>For simple use cases not requiring communication with {@link + * androidx.media2.session.MediaSession}, apps need to create a {@link + * androidx.media2.common.SessionPlayer} (e.g. {@link androidx.media2.player.MediaPlayer}) and set + * it to this view by calling {@link #setPlayer}. For more advanced use cases that require {@link + * androidx.media2.session.MediaSession} (e.g. handling media key events, integrating with other + * androidx.media2.session.MediaSession apps as Assistant), apps need to create a {@link + * androidx.media2.session.MediaController} attached to the {@link + * androidx.media2.session.MediaSession} and set it to this view by calling {@link + * #setMediaController}. + * + * <p>The easiest way to use a MediaControlView is by creating a {@link VideoView}, which internally + * creates a MediaControlView instance and handles all the commands from buttons inside + * MediaControlView. It is also possible to create a MediaControlView programmatically and add it to + * a custom video view. For more information, refer to {@link VideoView}. + * + * <p>By default, each button in the MediaControlView is visible only when its corresponding {@link + * androidx.media2.session.SessionCommand} is included in the active {@link + * androidx.media2.session.SessionCommandGroup}. For more details, refer to {@link + * androidx.media2.session.MediaSession#setAllowedCommands}. + * * <p> + * * <h3>UI transitions</h3> + * * The UI of an app can be in one of three modes: + * * <ul> - * <li>In <b>full</b> mode all the views, such as progress bar, title, transport controls, - * and other icons are visible. - * <li>In <b>progress-bar only</b> mode the progress bar is the only visible element. - * The title, transport controls, and other icons are hidden. - * <li>In <b>None</b> mode all the views are hidden. + * <li>In <b>full</b> mode all the views, such as progress bar, title, transport controls, and + * other icons are visible. + * <li>In <b>progress-bar only</b> mode the progress bar is the only visible element. The title, + * transport controls, and other icons are hidden. + * <li>In <b>None</b> mode all the views are hidden. * </ul> - * When the UI mode changes, MediaControlView animates the transition. The animation does not - * start immediately, there is a default delay interval of 2000ms before the animation begins. You - * can change this interval by calling - * {@link VideoView#setMediaControlView(MediaControlView, long)}. - * <p> - * User actions can change the scheduled transition during the delay interval according to - * the following logic: + * + * When the UI mode changes, MediaControlView animates the transition. The animation does not start + * immediately, there is a default delay interval of 2000ms before the animation begins. You can + * change this interval by calling {@link VideoView#setMediaControlView(MediaControlView, long)}. + * + * <p>User actions can change the scheduled transition during the delay interval according to the + * following logic: + * * <ol> - * <li> In Full mode - * <ul> - * <li>If a touch/trackball event is received during the interval, the UI changes to None - * mode. - * <li>If no touch/trackball event is received during the interval, the UI changes to - * progress-bar only mode. - * </ul> - * <li> In Progress-bar only mode - * <ul> - * <li>If a touch/trackball event is received, the UI changes to Full mode. - * <li>If no touch/trackball event is received, the UI changes to None mode. - * </ul> - * <li> In None mode, if a touch/trackball event is received, the UI changes to Full mode. + * <li>In Full mode + * <ul> + * <li>If a touch/trackball event is received during the interval, the UI changes to None + * mode. + * <li>If no touch/trackball event is received during the interval, the UI changes to + * progress-bar only mode. + * </ul> + * <li>In Progress-bar only mode + * <ul> + * <li>If a touch/trackball event is received, the UI changes to Full mode. + * <li>If no touch/trackball event is received, the UI changes to None mode. + * </ul> + * <li>In None mode, if a touch/trackball event is received, the UI changes to Full mode. * </ol> + * * All touch/trackballs events are ignored while the system is animating the change between modes. + * * <p> + * * <h3>Customization</h3> + * * The following customizations are supported: + * * <ul> * <li>Set focus to the play/pause button by calling {@link #requestPlayButtonFocus()}. * <li>Set full screen behavior by calling {@link #setOnFullScreenListener(OnFullScreenListener)}. - * Calling this method will also show the full screen button. + * Calling this method will also show the full screen button. * </ul> + * * <p> + * * <h3>Displaying metadata</h3> - * MediaControlView supports displaying metadata by calling - * {@link MediaItem#setMetadata(MediaMetadata)}. - * Metadata display is different for two different media types: video (with or without sound) - * and audio(sound only, no video) - * <p> - * The following table shows the metadata displayed on VideoView and the default - * values assigned if the keys are not set: + * + * MediaControlView supports displaying metadata by calling {@link + * androidx.media2.common.MediaItem#setMetadata(androidx.media2.common.MediaMetadata)}. Metadata + * display is different for two different media types: video (with or without sound) and audio(sound + * only, no video) + * + * <p>The following table shows the metadata displayed on VideoView and the default values assigned + * if the keys are not set: + * * <table> * <tr><th>Key</th><th>Default</th></tr> - * <tr><td>{@link MediaMetadata#METADATA_KEY_TITLE}</td> + * <tr><td>{@link androidx.media2.common.MediaMetadata#METADATA_KEY_TITLE}</td> * <td>{@link androidx.media2.widget.R.string#mcv2_music_title_unknown_text}</td></tr> - * <tr><td>{@link MediaMetadata#METADATA_KEY_ARTIST}</td> + * <tr><td>{@link androidx.media2.common.MediaMetadata#METADATA_KEY_ARTIST}</td> * <td>{@link androidx.media2.widget.R.string#mcv2_music_artist_unknown_text}</td></tr> - * <tr><td>{@link MediaMetadata#METADATA_KEY_ALBUM_ART}</td> + * <tr><td>{@link androidx.media2.common.MediaMetadata#METADATA_KEY_ALBUM_ART}</td> * <td>{@link androidx.media2.widget.R.drawable#media2_widget_ic_default_album_image}</td></tr> * </table> - * <p> - * For video media, {@link MediaMetadata#METADATA_KEY_TITLE} metadata is supported. - * If the value is not set, the following default value will be shown: - * {@link androidx.media2.widget.R.string#mcv2_non_music_title_unknown_text} + * + * <p>For video media, {@link androidx.media2.common.MediaMetadata#METADATA_KEY_TITLE} metadata is + * supported. If the value is not set, the following default value will be shown: {@link + * androidx.media2.widget.R.string#mcv2_non_music_title_unknown_text} + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public class MediaControlView extends MediaViewGroup { private static final String TAG = "MediaControlView"; static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); @@ -279,8 +290,8 @@ public class MediaControlView extends MediaViewGroup { private List<Integer> mSettingsIconIdsList; List<String> mSubtitleDescriptionsList; int mVideoTrackCount; - List<TrackInfo> mAudioTracks = new ArrayList<>(); - List<TrackInfo> mSubtitleTracks = new ArrayList<>(); + List<androidx.media2.common.SessionPlayer.TrackInfo> mAudioTracks = new ArrayList<>(); + List<androidx.media2.common.SessionPlayer.TrackInfo> mSubtitleTracks = new ArrayList<>(); List<String> mAudioTrackDescriptionList; List<String> mPlaybackSpeedTextList; List<Integer> mPlaybackSpeedMultBy100List; @@ -315,22 +326,24 @@ public class MediaControlView extends MediaViewGroup { } /** - * Sets {@link MediaController} to control playback with this view. - * Setting a MediaController will unset any MediaController or SessionPlayer - * that was previously set. - * <p> - * It will throw {@link IllegalStateException} if this MediaControlView belongs to - * a {@link VideoView} by {@link androidx.media2.widget.R.attr#enableControlView} or - * by {@link VideoView#setMediaControlView}. Use {@link VideoView#setMediaController} instead. - * <p> - * Note that MediaControlView allows controlling playback through its UI components, but calling - * the corresponding methods (e.g. {@link MediaController#play()}, - * {@link MediaController#pause()}) will work as well. + * Sets {@link androidx.media2.session.MediaController} to control playback with this view. + * Setting a androidx.media2.session.MediaController will unset any + * androidx.media2.session.MediaController or androidx.media2.common.SessionPlayer that was + * previously set. + * + * <p>It will throw {@link IllegalStateException} if this MediaControlView belongs to a {@link + * VideoView} by {@link androidx.media2.widget.R.attr#enableControlView} or by {@link + * VideoView#setMediaControlView}. Use {@link VideoView#setMediaController} instead. + * + * <p>Note that MediaControlView allows controlling playback through its UI components, but + * calling the corresponding methods (e.g. {@link + * androidx.media2.session.MediaController#play()}, {@link + * androidx.media2.session.MediaController#pause()}) will work as well. * * @param controller the controller * @see #setPlayer */ - public void setMediaController(@NonNull MediaController controller) { + public void setMediaController(@NonNull androidx.media2.session.MediaController controller) { if (controller == null) { throw new NullPointerException("controller must not be null"); } @@ -340,7 +353,7 @@ public class MediaControlView extends MediaViewGroup { setMediaControllerInternal(controller); } - void setMediaControllerInternal(@NonNull MediaController controller) { + void setMediaControllerInternal(@NonNull androidx.media2.session.MediaController controller) { if (mPlayer != null) { mPlayer.detachCallback(); } @@ -352,22 +365,22 @@ public class MediaControlView extends MediaViewGroup { } /** - * Sets {@link SessionPlayer} to control playback with this view. - * Setting a SessionPlayer will unset any MediaController or SessionPlayer - * that was previously set. - * <p> - * It will throw {@link IllegalStateException} if this MediaControlView belongs to - * a {@link VideoView} by {@link androidx.media2.widget.R.attr#enableControlView} or - * by {@link VideoView#setMediaControlView}. Use {@link VideoView#setPlayer} instead. - * <p> - * Note that MediaControlView allows controlling playback through its UI components, but calling - * the corresponding methods (e.g. {@link SessionPlayer#play()}, {@link SessionPlayer#pause()}) - * will work as well. + * Sets {@link androidx.media2.common.SessionPlayer} to control playback with this view. Setting + * a androidx.media2.common.SessionPlayer will unset any androidx.media2.session.MediaController + * or androidx.media2.common.SessionPlayer that was previously set. + * + * <p>It will throw {@link IllegalStateException} if this MediaControlView belongs to a {@link + * VideoView} by {@link androidx.media2.widget.R.attr#enableControlView} or by {@link + * VideoView#setMediaControlView}. Use {@link VideoView#setPlayer} instead. + * + * <p>Note that MediaControlView allows controlling playback through its UI components, but + * calling the corresponding methods (e.g. {@link androidx.media2.common.SessionPlayer#play()}, + * {@link androidx.media2.common.SessionPlayer#pause()}) will work as well. * * @param player the player * @see #setMediaController */ - public void setPlayer(@NonNull SessionPlayer player) { + public void setPlayer(@NonNull androidx.media2.common.SessionPlayer player) { if (player == null) { throw new NullPointerException("player must not be null"); } @@ -377,7 +390,7 @@ public class MediaControlView extends MediaViewGroup { setPlayerInternal(player); } - void setPlayerInternal(@NonNull SessionPlayer player) { + void setPlayerInternal(@NonNull androidx.media2.common.SessionPlayer player) { if (mPlayer != null) { mPlayer.detachCallback(); } @@ -418,7 +431,11 @@ public class MediaControlView extends MediaViewGroup { /** * Interface definition of a callback to be invoked to inform the fullscreen mode is changed. * Application should handle the fullscreen mode accordingly. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public interface OnFullScreenListener { /** * Called to indicate a fullscreen mode change. @@ -1392,7 +1409,7 @@ public class MediaControlView extends MediaViewGroup { } }; - void updateTimeViews(MediaItem item) { + void updateTimeViews(androidx.media2.common.MediaItem item) { if (item == null) { mProgress.setProgress(0); mCurrentTime.setText(mResources.getString(R.string.MediaControlView_time_placeholder)); @@ -1409,7 +1426,7 @@ public class MediaControlView extends MediaViewGroup { } } - void updateTitleView(MediaItem item) { + void updateTitleView(androidx.media2.common.MediaItem item) { if (item == null) { mTitleView.setText(null); return; @@ -1578,13 +1595,13 @@ public class MediaControlView extends MediaViewGroup { boolean isCurrentMediaItemFromNetwork() { ensurePlayerIsNotNull(); - MediaItem currentMediaItem = mPlayer.getCurrentMediaItem(); + androidx.media2.common.MediaItem currentMediaItem = mPlayer.getCurrentMediaItem(); - if (!(currentMediaItem instanceof UriMediaItem)) { + if (!(currentMediaItem instanceof androidx.media2.common.UriMediaItem)) { return false; } - Uri uri = ((UriMediaItem) currentMediaItem).getUri(); + Uri uri = ((androidx.media2.common.UriMediaItem) currentMediaItem).getUri(); return UriUtil.isFromNetwork(uri); } @@ -1716,7 +1733,7 @@ public class MediaControlView extends MediaViewGroup { int sizeType = mTransportControlsMap.keyAt(i); View prevButton = findControlButton(sizeType, R.id.prev); if (prevButton != null) { - if (prevIndex > SessionPlayer.INVALID_ITEM_INDEX) { + if (prevIndex > androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) { prevButton.setAlpha(1.0f); prevButton.setEnabled(true); } else { @@ -1726,7 +1743,7 @@ public class MediaControlView extends MediaViewGroup { } View nextButton = findControlButton(sizeType, R.id.next); if (nextButton != null) { - if (nextIndex > SessionPlayer.INVALID_ITEM_INDEX) { + if (nextIndex > androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX) { nextButton.setAlpha(1.0f); nextButton.setEnabled(true); } else { @@ -1740,8 +1757,10 @@ public class MediaControlView extends MediaViewGroup { boolean shouldNotHideBars() { return (isCurrentItemMusic() && mSizeType == SIZE_TYPE_FULL) || mAccessibilityManager.isTouchExplorationEnabled() - || mPlayer.getPlayerState() == SessionPlayer.PLAYER_STATE_ERROR - || mPlayer.getPlayerState() == SessionPlayer.PLAYER_STATE_IDLE; + || mPlayer.getPlayerState() + == androidx.media2.common.SessionPlayer.PLAYER_STATE_ERROR + || mPlayer.getPlayerState() + == androidx.media2.common.SessionPlayer.PLAYER_STATE_IDLE; } void seekTo(long newPosition, boolean shouldSeekNow) { @@ -1850,7 +1869,8 @@ public class MediaControlView extends MediaViewGroup { } } - void updateTracks(PlayerWrapper player, List<TrackInfo> trackInfos) { + void updateTracks( + PlayerWrapper player, List<androidx.media2.common.SessionPlayer.TrackInfo> trackInfos) { // Update video track count, audio & subtitle track lists. mVideoTrackCount = 0; mAudioTracks = new ArrayList<>(); @@ -1858,18 +1878,25 @@ public class MediaControlView extends MediaViewGroup { mSelectedAudioTrackIndex = 0; // Default is -1 since subtitle selection always includes "Off" item mSelectedSubtitleTrackIndex = -1; - TrackInfo audioTrack = player.getSelectedTrack(TrackInfo.MEDIA_TRACK_TYPE_AUDIO); - TrackInfo subtitleTrack = player.getSelectedTrack(TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE); + androidx.media2.common.SessionPlayer.TrackInfo audioTrack = + player.getSelectedTrack( + androidx.media2.common.SessionPlayer.TrackInfo.MEDIA_TRACK_TYPE_AUDIO); + androidx.media2.common.SessionPlayer.TrackInfo subtitleTrack = + player.getSelectedTrack( + androidx.media2.common.SessionPlayer.TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE); for (int i = 0; i < trackInfos.size(); i++) { int trackType = trackInfos.get(i).getTrackType(); - if (trackType == TrackInfo.MEDIA_TRACK_TYPE_VIDEO) { + if (trackType + == androidx.media2.common.SessionPlayer.TrackInfo.MEDIA_TRACK_TYPE_VIDEO) { mVideoTrackCount++; - } else if (trackType == TrackInfo.MEDIA_TRACK_TYPE_AUDIO) { + } else if (trackType + == androidx.media2.common.SessionPlayer.TrackInfo.MEDIA_TRACK_TYPE_AUDIO) { if (trackInfos.get(i).equals(audioTrack)) { mSelectedAudioTrackIndex = mAudioTracks.size(); } mAudioTracks.add(trackInfos.get(i)); - } else if (trackType == TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE) { + } else if (trackType + == androidx.media2.common.SessionPlayer.TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE) { if (trackInfos.get(i).equals(subtitleTrack)) { mSelectedSubtitleTrackIndex = mSubtitleTracks.size(); } @@ -1919,7 +1946,7 @@ public class MediaControlView extends MediaViewGroup { if (mVideoTrackCount > 0) { return true; } - VideoSize videoSize = mPlayer.getVideoSize(); + androidx.media2.common.VideoSize videoSize = mPlayer.getVideoSize(); if (videoSize.getHeight() > 0 && videoSize.getWidth() > 0) { Log.w(TAG, "video track count is zero, but it renders video. size: " + videoSize); return true; @@ -2070,20 +2097,20 @@ public class MediaControlView extends MediaViewGroup { // activity is resumed. // 2) Need to handle case where the media file reaches end of duration. switch (state) { - case SessionPlayer.PLAYER_STATE_PLAYING: + case androidx.media2.common.SessionPlayer.PLAYER_STATE_PLAYING: removeCallbacks(mUpdateProgress); post(mUpdateProgress); resetHideCallbacks(); updateReplayButton(false); break; - case SessionPlayer.PLAYER_STATE_PAUSED: + case androidx.media2.common.SessionPlayer.PLAYER_STATE_PAUSED: updatePlayButton(PLAY_BUTTON_PLAY); removeCallbacks(mUpdateProgress); removeCallbacks(mHideMainBars); removeCallbacks(mHideProgressBar); post(mShowAllBars); break; - case SessionPlayer.PLAYER_STATE_ERROR: + case androidx.media2.common.SessionPlayer.PLAYER_STATE_ERROR: updatePlayButton(PLAY_BUTTON_PLAY); removeCallbacks(mUpdateProgress); if (getWindowToken() != null) { @@ -2139,8 +2166,9 @@ public class MediaControlView extends MediaViewGroup { } @Override - public void onCurrentMediaItemChanged(@NonNull PlayerWrapper player, - @Nullable MediaItem mediaItem) { + public void onCurrentMediaItemChanged( + @NonNull PlayerWrapper player, + @Nullable androidx.media2.common.MediaItem mediaItem) { if (player != mPlayer) return; if (DEBUG) { @@ -2153,8 +2181,10 @@ public class MediaControlView extends MediaViewGroup { } @Override - void onPlaylistChanged(@NonNull PlayerWrapper player, @Nullable List<MediaItem> list, - @Nullable MediaMetadata metadata) { + void onPlaylistChanged( + @NonNull PlayerWrapper player, + @Nullable List<androidx.media2.common.MediaItem> list, + @Nullable androidx.media2.common.MediaMetadata metadata) { if (player != mPlayer) return; if (DEBUG) { @@ -2178,8 +2208,9 @@ public class MediaControlView extends MediaViewGroup { } @Override - public void onAllowedCommandsChanged(@NonNull PlayerWrapper player, - @NonNull SessionCommandGroup commands) { + public void onAllowedCommandsChanged( + @NonNull PlayerWrapper player, + @NonNull androidx.media2.session.SessionCommandGroup commands) { if (player != mPlayer) return; updateAllowedCommands(); @@ -2231,11 +2262,13 @@ public class MediaControlView extends MediaViewGroup { } @Override - void onTracksChanged(@NonNull PlayerWrapper player, @NonNull List<TrackInfo> tracks) { + void onTracksChanged( + @NonNull PlayerWrapper player, + @NonNull List<androidx.media2.common.SessionPlayer.TrackInfo> tracks) { if (player != mPlayer) return; if (DEBUG) { - Log.d(TAG, "onTrackInfoChanged(): " + tracks); + Log.d(TAG, "onandroidx.media2.common.SessionPlayer.TrackInfoChanged(): " + tracks); } updateTracks(player, tracks); @@ -2244,13 +2277,16 @@ public class MediaControlView extends MediaViewGroup { } @Override - void onTrackSelected(@NonNull PlayerWrapper player, @NonNull TrackInfo trackInfo) { + void onTrackSelected( + @NonNull PlayerWrapper player, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo trackInfo) { if (player != mPlayer) return; if (DEBUG) { Log.d(TAG, "onTrackSelected(): " + trackInfo); } - if (trackInfo.getTrackType() == TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE) { + if (trackInfo.getTrackType() + == androidx.media2.common.SessionPlayer.TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE) { for (int i = 0; i < mSubtitleTracks.size(); i++) { if (mSubtitleTracks.get(i).equals(trackInfo)) { mSelectedSubtitleTrackIndex = i; @@ -2265,7 +2301,8 @@ public class MediaControlView extends MediaViewGroup { break; } } - } else if (trackInfo.getTrackType() == TrackInfo.MEDIA_TRACK_TYPE_AUDIO) { + } else if (trackInfo.getTrackType() + == androidx.media2.common.SessionPlayer.TrackInfo.MEDIA_TRACK_TYPE_AUDIO) { for (int i = 0; i < mAudioTracks.size(); i++) { if (mAudioTracks.get(i).equals(trackInfo)) { mSelectedAudioTrackIndex = i; @@ -2279,13 +2316,16 @@ public class MediaControlView extends MediaViewGroup { } @Override - void onTrackDeselected(@NonNull PlayerWrapper player, @NonNull TrackInfo trackInfo) { + void onTrackDeselected( + @NonNull PlayerWrapper player, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo trackInfo) { if (player != mPlayer) return; if (DEBUG) { Log.d(TAG, "onTrackDeselected(): " + trackInfo); } - if (trackInfo.getTrackType() == TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE) { + if (trackInfo.getTrackType() + == androidx.media2.common.SessionPlayer.TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE) { for (int i = 0; i < mSubtitleTracks.size(); i++) { if (mSubtitleTracks.get(i).equals(trackInfo)) { mSelectedSubtitleTrackIndex = -1; @@ -2304,14 +2344,16 @@ public class MediaControlView extends MediaViewGroup { } @Override - void onVideoSizeChanged(@NonNull PlayerWrapper player, @NonNull VideoSize videoSize) { + void onVideoSizeChanged( + @NonNull PlayerWrapper player, + @NonNull androidx.media2.common.VideoSize videoSize) { if (player != mPlayer) return; if (DEBUG) { Log.d(TAG, "onVideoSizeChanged(): " + videoSize); } if (mVideoTrackCount == 0 && videoSize.getHeight() > 0 && videoSize.getWidth() > 0) { - List<TrackInfo> tracks = player.getTracks(); + List<androidx.media2.common.SessionPlayer.TrackInfo> tracks = player.getTracks(); if (tracks != null) { updateTracks(player, tracks); } diff --git a/media2/media2-widget/src/main/java/androidx/media2/widget/PlayerWrapper.java b/media2/media2-widget/src/main/java/androidx/media2/widget/PlayerWrapper.java index fdbbcedb65f..575f96fcfe5 100644 --- a/media2/media2-widget/src/main/java/androidx/media2/widget/PlayerWrapper.java +++ b/media2/media2-widget/src/main/java/androidx/media2/widget/PlayerWrapper.java @@ -21,16 +21,6 @@ import android.view.Surface; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.util.ObjectsCompat; -import androidx.media2.common.BaseResult; -import androidx.media2.common.MediaItem; -import androidx.media2.common.MediaMetadata; -import androidx.media2.common.SessionPlayer; -import androidx.media2.common.SessionPlayer.TrackInfo; -import androidx.media2.common.SubtitleData; -import androidx.media2.common.VideoSize; -import androidx.media2.session.MediaController; -import androidx.media2.session.SessionCommand; -import androidx.media2.session.SessionCommandGroup; import com.google.common.util.concurrent.ListenableFuture; @@ -38,12 +28,11 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.Executor; -/** - * Wrapper for MediaController and SessionPlayer - */ +/** Wrapper for androidx.media2.session.MediaController and androidx.media2.common.SessionPlayer */ +@SuppressWarnings("deprecation") class PlayerWrapper { - final MediaController mController; - final SessionPlayer mPlayer; + final androidx.media2.session.MediaController mController; + final androidx.media2.common.SessionPlayer mPlayer; private final Executor mCallbackExecutor; @@ -56,15 +45,19 @@ class PlayerWrapper { // cached states @SuppressWarnings("WeakerAccess") /* synthetic access */ - int mSavedPlayerState = SessionPlayer.PLAYER_STATE_IDLE; + int mSavedPlayerState = androidx.media2.common.SessionPlayer.PLAYER_STATE_IDLE; + @SuppressWarnings("WeakerAccess") /* synthetic access */ - SessionCommandGroup mAllowedCommands; + androidx.media2.session.SessionCommandGroup mAllowedCommands; + @SuppressWarnings("WeakerAccess") /* synthetic access */ - MediaMetadata mMediaMetadata; + androidx.media2.common.MediaMetadata mMediaMetadata; - private final SessionCommandGroup mAllCommands; + private final androidx.media2.session.SessionCommandGroup mAllCommands; - PlayerWrapper(@NonNull MediaController controller, @NonNull Executor executor, + PlayerWrapper( + @NonNull androidx.media2.session.MediaController controller, + @NonNull Executor executor, @NonNull PlayerCallback callback) { if (controller == null) throw new NullPointerException("controller must not be null"); if (executor == null) throw new NullPointerException("executor must not be null"); @@ -80,7 +73,9 @@ class PlayerWrapper { mAllCommands = null; } - PlayerWrapper(@NonNull SessionPlayer player, @NonNull Executor executor, + PlayerWrapper( + @NonNull androidx.media2.common.SessionPlayer player, + @NonNull Executor executor, @NonNull PlayerCallback callback) { if (player == null) throw new NullPointerException("player must not be null"); if (executor == null) throw new NullPointerException("executor must not be null"); @@ -93,9 +88,11 @@ class PlayerWrapper { mController = null; mControllerCallback = null; - mAllCommands = new SessionCommandGroup.Builder() - .addAllPredefinedCommands(SessionCommand.COMMAND_VERSION_1) - .build(); + mAllCommands = + new androidx.media2.session.SessionCommandGroup.Builder() + .addAllPredefinedCommands( + androidx.media2.session.SessionCommand.COMMAND_VERSION_1) + .build(); } boolean hasDisconnectedController() { @@ -124,11 +121,11 @@ class PlayerWrapper { } boolean isPlaying() { - return mSavedPlayerState == SessionPlayer.PLAYER_STATE_PLAYING; + return mSavedPlayerState == androidx.media2.common.SessionPlayer.PLAYER_STATE_PLAYING; } long getCurrentPosition() { - if (mSavedPlayerState == SessionPlayer.PLAYER_STATE_IDLE) { + if (mSavedPlayerState == androidx.media2.common.SessionPlayer.PLAYER_STATE_IDLE) { return 0; } long position = 0; @@ -141,7 +138,7 @@ class PlayerWrapper { } long getBufferPercentage() { - if (mSavedPlayerState == SessionPlayer.PLAYER_STATE_IDLE) { + if (mSavedPlayerState == androidx.media2.common.SessionPlayer.PLAYER_STATE_IDLE) { return 0; } long duration = getDurationMs(); @@ -161,43 +158,53 @@ class PlayerWrapper { } else if (mPlayer != null) { return mPlayer.getPlayerState(); } - return SessionPlayer.PLAYER_STATE_IDLE; + return androidx.media2.common.SessionPlayer.PLAYER_STATE_IDLE; } boolean canPause() { - return mAllowedCommands != null && mAllowedCommands.hasCommand( - SessionCommand.COMMAND_CODE_PLAYER_PAUSE); + return mAllowedCommands != null + && mAllowedCommands.hasCommand( + androidx.media2.session.SessionCommand.COMMAND_CODE_PLAYER_PAUSE); } boolean canSeekBackward() { - return mAllowedCommands != null && mAllowedCommands.hasCommand( - SessionCommand.COMMAND_CODE_SESSION_REWIND); + return mAllowedCommands != null + && mAllowedCommands.hasCommand( + androidx.media2.session.SessionCommand.COMMAND_CODE_SESSION_REWIND); } boolean canSeekForward() { - return mAllowedCommands != null && mAllowedCommands.hasCommand( - SessionCommand.COMMAND_CODE_SESSION_FAST_FORWARD); + return mAllowedCommands != null + && mAllowedCommands.hasCommand( + androidx.media2.session.SessionCommand.COMMAND_CODE_SESSION_FAST_FORWARD); } boolean canSkipToNext() { - return mAllowedCommands != null && mAllowedCommands.hasCommand( - SessionCommand.COMMAND_CODE_PLAYER_SKIP_TO_NEXT_PLAYLIST_ITEM); + return mAllowedCommands != null + && mAllowedCommands.hasCommand( + androidx.media2.session.SessionCommand + .COMMAND_CODE_PLAYER_SKIP_TO_NEXT_PLAYLIST_ITEM); } boolean canSkipToPrevious() { - return mAllowedCommands != null && mAllowedCommands.hasCommand( - SessionCommand.COMMAND_CODE_PLAYER_SKIP_TO_PREVIOUS_PLAYLIST_ITEM); + return mAllowedCommands != null + && mAllowedCommands.hasCommand( + androidx.media2.session.SessionCommand + .COMMAND_CODE_PLAYER_SKIP_TO_PREVIOUS_PLAYLIST_ITEM); } boolean canSeekTo() { - return mAllowedCommands != null && mAllowedCommands.hasCommand( - SessionCommand.COMMAND_CODE_PLAYER_SEEK_TO); + return mAllowedCommands != null + && mAllowedCommands.hasCommand( + androidx.media2.session.SessionCommand.COMMAND_CODE_PLAYER_SEEK_TO); } boolean canSelectDeselectTrack() { return mAllowedCommands != null - && mAllowedCommands.hasCommand(SessionCommand.COMMAND_CODE_PLAYER_SELECT_TRACK) - && mAllowedCommands.hasCommand(SessionCommand.COMMAND_CODE_PLAYER_DESELECT_TRACK); + && mAllowedCommands.hasCommand( + androidx.media2.session.SessionCommand.COMMAND_CODE_PLAYER_SELECT_TRACK) + && mAllowedCommands.hasCommand( + androidx.media2.session.SessionCommand.COMMAND_CODE_PLAYER_DESELECT_TRACK); } @SuppressWarnings("FutureReturnValueIgnored") @@ -264,7 +271,7 @@ class PlayerWrapper { } @SuppressWarnings("FutureReturnValueIgnored") - void selectTrack(TrackInfo trackInfo) { + void selectTrack(androidx.media2.common.SessionPlayer.TrackInfo trackInfo) { if (mController != null) { mController.selectTrack(trackInfo); } else if (mPlayer != null) { @@ -273,7 +280,7 @@ class PlayerWrapper { } @SuppressWarnings("FutureReturnValueIgnored") - void deselectTrack(TrackInfo trackInfo) { + void deselectTrack(androidx.media2.common.SessionPlayer.TrackInfo trackInfo) { if (mController != null) { mController.deselectTrack(trackInfo); } else if (mPlayer != null) { @@ -282,7 +289,7 @@ class PlayerWrapper { } long getDurationMs() { - if (mSavedPlayerState == SessionPlayer.PLAYER_STATE_IDLE) { + if (mSavedPlayerState == androidx.media2.common.SessionPlayer.PLAYER_STATE_IDLE) { return 0; } long duration = 0; @@ -296,8 +303,10 @@ class PlayerWrapper { CharSequence getTitle() { if (mMediaMetadata != null) { - if (mMediaMetadata.containsKey(MediaMetadata.METADATA_KEY_TITLE)) { - return mMediaMetadata.getText(MediaMetadata.METADATA_KEY_TITLE); + if (mMediaMetadata.containsKey( + androidx.media2.common.MediaMetadata.METADATA_KEY_TITLE)) { + return mMediaMetadata.getText( + androidx.media2.common.MediaMetadata.METADATA_KEY_TITLE); } } return null; @@ -305,15 +314,17 @@ class PlayerWrapper { CharSequence getArtistText() { if (mMediaMetadata != null) { - if (mMediaMetadata.containsKey(MediaMetadata.METADATA_KEY_ARTIST)) { - return mMediaMetadata.getText(MediaMetadata.METADATA_KEY_ARTIST); + if (mMediaMetadata.containsKey( + androidx.media2.common.MediaMetadata.METADATA_KEY_ARTIST)) { + return mMediaMetadata.getText( + androidx.media2.common.MediaMetadata.METADATA_KEY_ARTIST); } } return null; } @Nullable - MediaItem getCurrentMediaItem() { + androidx.media2.common.MediaItem getCurrentMediaItem() { if (mController != null) { return mController.getCurrentMediaItem(); } else if (mPlayer != null) { @@ -323,7 +334,7 @@ class PlayerWrapper { } @Nullable - private SessionCommandGroup getAllowedCommands() { + private androidx.media2.session.SessionCommandGroup getAllowedCommands() { if (mController != null) { return mController.getAllowedCommands(); } else if (mPlayer != null) { @@ -343,13 +354,13 @@ class PlayerWrapper { } boolean allowedCommandsChanged = false; - SessionCommandGroup allowedCommands = getAllowedCommands(); + androidx.media2.session.SessionCommandGroup allowedCommands = getAllowedCommands(); if (!ObjectsCompat.equals(mAllowedCommands, allowedCommands)) { mAllowedCommands = allowedCommands; allowedCommandsChanged = true; } - MediaItem item = getCurrentMediaItem(); + androidx.media2.common.MediaItem item = getCurrentMediaItem(); mMediaMetadata = item == null ? null : item.getMetadata(); if (playerStateChanged) { @@ -363,17 +374,17 @@ class PlayerWrapper { } @NonNull - VideoSize getVideoSize() { + androidx.media2.common.VideoSize getVideoSize() { if (mController != null) { return mController.getVideoSize(); } else if (mPlayer != null) { return mPlayer.getVideoSize(); } - return new VideoSize(0, 0); + return new androidx.media2.common.VideoSize(0, 0); } @NonNull - List<TrackInfo> getTracks() { + List<androidx.media2.common.SessionPlayer.TrackInfo> getTracks() { if (mController != null) { return mController.getTracks(); } else if (mPlayer != null) { @@ -383,7 +394,7 @@ class PlayerWrapper { } @Nullable - TrackInfo getSelectedTrack(int trackType) { + androidx.media2.common.SessionPlayer.TrackInfo getSelectedTrack(int trackType) { if (mController != null) { return mController.getSelectedTrack(trackType); } else if (mPlayer != null) { @@ -392,7 +403,7 @@ class PlayerWrapper { return null; } - ListenableFuture<? extends BaseResult> setSurface(Surface surface) { + ListenableFuture<? extends androidx.media2.common.BaseResult> setSurface(Surface surface) { if (mController != null) { return mController.setSurface(surface); } else if (mPlayer != null) { @@ -407,7 +418,7 @@ class PlayerWrapper { } else if (mPlayer != null) { return mPlayer.getCurrentMediaItemIndex(); } - return SessionPlayer.INVALID_ITEM_INDEX; + return androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX; } int getPreviousMediaItemIndex() { @@ -416,7 +427,7 @@ class PlayerWrapper { } else if (mPlayer != null) { return mPlayer.getPreviousMediaItemIndex(); } - return SessionPlayer.INVALID_ITEM_INDEX; + return androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX; } int getNextMediaItemIndex() { @@ -425,90 +436,107 @@ class PlayerWrapper { } else if (mPlayer != null) { return mPlayer.getNextMediaItemIndex(); } - return SessionPlayer.INVALID_ITEM_INDEX; + return androidx.media2.common.SessionPlayer.INVALID_ITEM_INDEX; } - private class MediaControllerCallback extends MediaController.ControllerCallback { + private class MediaControllerCallback + extends androidx.media2.session.MediaController.ControllerCallback { MediaControllerCallback() { } @Override - public void onConnected(@NonNull MediaController controller, - @NonNull SessionCommandGroup allowedCommands) { + public void onConnected( + @NonNull androidx.media2.session.MediaController controller, + @NonNull androidx.media2.session.SessionCommandGroup allowedCommands) { mWrapperCallback.onConnected(PlayerWrapper.this); updateAndNotifyCachedStates(); } @Override - public void onAllowedCommandsChanged(@NonNull MediaController controller, - @NonNull SessionCommandGroup commands) { + public void onAllowedCommandsChanged( + @NonNull androidx.media2.session.MediaController controller, + @NonNull androidx.media2.session.SessionCommandGroup commands) { if (ObjectsCompat.equals(mAllowedCommands, commands)) return; mAllowedCommands = commands; mWrapperCallback.onAllowedCommandsChanged(PlayerWrapper.this, commands); } @Override - public void onPlayerStateChanged(@NonNull MediaController controller, int state) { + public void onPlayerStateChanged( + @NonNull androidx.media2.session.MediaController controller, int state) { if (mSavedPlayerState == state) return; mSavedPlayerState = state; mWrapperCallback.onPlayerStateChanged(PlayerWrapper.this, state); } @Override - public void onPlaybackSpeedChanged(@NonNull MediaController controller, float speed) { + public void onPlaybackSpeedChanged( + @NonNull androidx.media2.session.MediaController controller, float speed) { mWrapperCallback.onPlaybackSpeedChanged(PlayerWrapper.this, speed); } @Override - public void onSeekCompleted(@NonNull MediaController controller, long position) { + public void onSeekCompleted( + @NonNull androidx.media2.session.MediaController controller, long position) { mWrapperCallback.onSeekCompleted(PlayerWrapper.this, position); } @Override - public void onCurrentMediaItemChanged(@NonNull MediaController controller, - @Nullable MediaItem item) { + public void onCurrentMediaItemChanged( + @NonNull androidx.media2.session.MediaController controller, + @Nullable androidx.media2.common.MediaItem item) { mMediaMetadata = item == null ? null : item.getMetadata(); mWrapperCallback.onCurrentMediaItemChanged(PlayerWrapper.this, item); } @Override - public void onPlaylistChanged(@NonNull MediaController controller, - @Nullable List<MediaItem> list, @Nullable MediaMetadata metadata) { + public void onPlaylistChanged( + @NonNull androidx.media2.session.MediaController controller, + @Nullable List<androidx.media2.common.MediaItem> list, + @Nullable androidx.media2.common.MediaMetadata metadata) { mWrapperCallback.onPlaylistChanged(PlayerWrapper.this, list, metadata); } @Override - public void onPlaybackCompleted(@NonNull MediaController controller) { + public void onPlaybackCompleted( + @NonNull androidx.media2.session.MediaController controller) { mWrapperCallback.onPlaybackCompleted(PlayerWrapper.this); } @Override - public void onVideoSizeChanged(@NonNull MediaController controller, - @NonNull VideoSize videoSize) { + public void onVideoSizeChanged( + @NonNull androidx.media2.session.MediaController controller, + @NonNull androidx.media2.common.VideoSize videoSize) { mWrapperCallback.onVideoSizeChanged(PlayerWrapper.this, videoSize); } @Override - public void onSubtitleData(@NonNull MediaController controller, @NonNull MediaItem item, - @NonNull TrackInfo track, @NonNull SubtitleData data) { + public void onSubtitleData( + @NonNull androidx.media2.session.MediaController controller, + @NonNull androidx.media2.common.MediaItem item, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo track, + @NonNull androidx.media2.common.SubtitleData data) { mWrapperCallback.onSubtitleData(PlayerWrapper.this, item, track, data); } @Override - public void onTracksChanged(@NonNull MediaController controller, - @NonNull List<TrackInfo> tracks) { + public void onTracksChanged( + @NonNull androidx.media2.session.MediaController controller, + @NonNull List<androidx.media2.common.SessionPlayer.TrackInfo> tracks) { mWrapperCallback.onTracksChanged(PlayerWrapper.this, tracks); } @Override - public void onTrackSelected(@NonNull MediaController controller, - @NonNull TrackInfo trackInfo) { + public void onTrackSelected( + @NonNull androidx.media2.session.MediaController controller, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo trackInfo) { mWrapperCallback.onTrackSelected(PlayerWrapper.this, trackInfo); } @Override - public void onTrackDeselected(@NonNull MediaController controller, - @NonNull TrackInfo trackInfo) { + public void onTrackDeselected( + @NonNull androidx.media2.session.MediaController controller, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo trackInfo) { mWrapperCallback.onTrackDeselected(PlayerWrapper.this, trackInfo); } } @@ -516,79 +544,96 @@ class PlayerWrapper { private void notifyNonCachedStates() { mWrapperCallback.onPlaybackSpeedChanged(this, getPlaybackSpeed()); - List<TrackInfo> trackInfos = getTracks(); + List<androidx.media2.common.SessionPlayer.TrackInfo> trackInfos = getTracks(); if (trackInfos != null) { mWrapperCallback.onTracksChanged(PlayerWrapper.this, trackInfos); } - MediaItem item = getCurrentMediaItem(); + androidx.media2.common.MediaItem item = getCurrentMediaItem(); if (item != null) { mWrapperCallback.onVideoSizeChanged(PlayerWrapper.this, getVideoSize()); } } - private class SessionPlayerCallback extends SessionPlayer.PlayerCallback { + private class SessionPlayerCallback + extends androidx.media2.common.SessionPlayer.PlayerCallback { SessionPlayerCallback() { } @Override - public void onPlayerStateChanged(@NonNull SessionPlayer player, int playerState) { + public void onPlayerStateChanged( + @NonNull androidx.media2.common.SessionPlayer player, int playerState) { if (mSavedPlayerState == playerState) return; mSavedPlayerState = playerState; mWrapperCallback.onPlayerStateChanged(PlayerWrapper.this, playerState); } @Override - public void onPlaybackSpeedChanged(@NonNull SessionPlayer player, float playbackSpeed) { + public void onPlaybackSpeedChanged( + @NonNull androidx.media2.common.SessionPlayer player, float playbackSpeed) { mWrapperCallback.onPlaybackSpeedChanged(PlayerWrapper.this, playbackSpeed); } @Override - public void onSeekCompleted(@NonNull SessionPlayer player, long position) { + public void onSeekCompleted( + @NonNull androidx.media2.common.SessionPlayer player, long position) { mWrapperCallback.onSeekCompleted(PlayerWrapper.this, position); } @Override - public void onCurrentMediaItemChanged(@NonNull SessionPlayer player, - @NonNull MediaItem item) { + public void onCurrentMediaItemChanged( + @NonNull androidx.media2.common.SessionPlayer player, + @NonNull androidx.media2.common.MediaItem item) { mMediaMetadata = item == null ? null : item.getMetadata(); mWrapperCallback.onCurrentMediaItemChanged(PlayerWrapper.this, item); } @Override - public void onPlaylistChanged(@NonNull SessionPlayer player, @Nullable List<MediaItem> list, - @Nullable MediaMetadata metadata) { + public void onPlaylistChanged( + @NonNull androidx.media2.common.SessionPlayer player, + @Nullable List<androidx.media2.common.MediaItem> list, + @Nullable androidx.media2.common.MediaMetadata metadata) { mWrapperCallback.onPlaylistChanged(PlayerWrapper.this, list, metadata); } @Override - public void onPlaybackCompleted(@NonNull SessionPlayer player) { + public void onPlaybackCompleted(@NonNull androidx.media2.common.SessionPlayer player) { mWrapperCallback.onPlaybackCompleted(PlayerWrapper.this); } @Override - public void onVideoSizeChanged(@NonNull SessionPlayer player, @NonNull VideoSize size) { + public void onVideoSizeChanged( + @NonNull androidx.media2.common.SessionPlayer player, + @NonNull androidx.media2.common.VideoSize size) { mWrapperCallback.onVideoSizeChanged(PlayerWrapper.this, size); } @Override - public void onSubtitleData(@NonNull SessionPlayer player, @NonNull MediaItem item, - @NonNull TrackInfo track, @NonNull SubtitleData data) { + public void onSubtitleData( + @NonNull androidx.media2.common.SessionPlayer player, + @NonNull androidx.media2.common.MediaItem item, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo track, + @NonNull androidx.media2.common.SubtitleData data) { mWrapperCallback.onSubtitleData(PlayerWrapper.this, item, track, data); } @Override - public void onTracksChanged(@NonNull SessionPlayer player, - @NonNull List<TrackInfo> tracks) { + public void onTracksChanged( + @NonNull androidx.media2.common.SessionPlayer player, + @NonNull List<androidx.media2.common.SessionPlayer.TrackInfo> tracks) { mWrapperCallback.onTracksChanged(PlayerWrapper.this, tracks); } @Override - public void onTrackSelected(@NonNull SessionPlayer player, @NonNull TrackInfo trackInfo) { + public void onTrackSelected( + @NonNull androidx.media2.common.SessionPlayer player, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo trackInfo) { mWrapperCallback.onTrackSelected(PlayerWrapper.this, trackInfo); } @Override - public void onTrackDeselected(@NonNull SessionPlayer player, @NonNull TrackInfo trackInfo) { + public void onTrackDeselected( + @NonNull androidx.media2.common.SessionPlayer player, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo trackInfo) { mWrapperCallback.onTrackDeselected(PlayerWrapper.this, trackInfo); } } @@ -596,14 +641,19 @@ class PlayerWrapper { abstract static class PlayerCallback { void onConnected(@NonNull PlayerWrapper player) { } - void onAllowedCommandsChanged(@NonNull PlayerWrapper player, - @NonNull SessionCommandGroup commands) { - } - void onCurrentMediaItemChanged(@NonNull PlayerWrapper player, @Nullable MediaItem item) { - } - void onPlaylistChanged(@NonNull PlayerWrapper player, @Nullable List<MediaItem> list, - @Nullable MediaMetadata metadata) { - } + + void onAllowedCommandsChanged( + @NonNull PlayerWrapper player, + @NonNull androidx.media2.session.SessionCommandGroup commands) {} + + void onCurrentMediaItemChanged( + @NonNull PlayerWrapper player, @Nullable androidx.media2.common.MediaItem item) {} + + void onPlaylistChanged( + @NonNull PlayerWrapper player, + @Nullable List<androidx.media2.common.MediaItem> list, + @Nullable androidx.media2.common.MediaMetadata metadata) {} + void onPlayerStateChanged(@NonNull PlayerWrapper player, int state) { } void onPlaybackSpeedChanged(@NonNull PlayerWrapper player, float speed) { @@ -612,16 +662,27 @@ class PlayerWrapper { } void onPlaybackCompleted(@NonNull PlayerWrapper player) { } - void onVideoSizeChanged(@NonNull PlayerWrapper player, @NonNull VideoSize videoSize) { - } - void onTracksChanged(@NonNull PlayerWrapper player, @NonNull List<TrackInfo> tracks) { - } - void onTrackSelected(@NonNull PlayerWrapper player, @NonNull TrackInfo trackInfo) { - } - void onTrackDeselected(@NonNull PlayerWrapper player, @NonNull TrackInfo trackInfo) { - } - void onSubtitleData(@NonNull PlayerWrapper player, @NonNull MediaItem item, - @NonNull TrackInfo track, @NonNull SubtitleData data) { - } + + void onVideoSizeChanged( + @NonNull PlayerWrapper player, + @NonNull androidx.media2.common.VideoSize videoSize) {} + + void onTracksChanged( + @NonNull PlayerWrapper player, + @NonNull List<androidx.media2.common.SessionPlayer.TrackInfo> tracks) {} + + void onTrackSelected( + @NonNull PlayerWrapper player, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo trackInfo) {} + + void onTrackDeselected( + @NonNull PlayerWrapper player, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo trackInfo) {} + + void onSubtitleData( + @NonNull PlayerWrapper player, + @NonNull androidx.media2.common.MediaItem item, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo track, + @NonNull androidx.media2.common.SubtitleData data) {} } } diff --git a/media2/media2-widget/src/main/java/androidx/media2/widget/SubtitleTrack.java b/media2/media2-widget/src/main/java/androidx/media2/widget/SubtitleTrack.java index c7cc04b2633..377e700387b 100644 --- a/media2/media2-widget/src/main/java/androidx/media2/widget/SubtitleTrack.java +++ b/media2/media2-widget/src/main/java/androidx/media2/widget/SubtitleTrack.java @@ -26,7 +26,6 @@ import android.util.Pair; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.media2.common.SubtitleData; import java.util.ArrayList; import java.util.Iterator; @@ -36,9 +35,10 @@ import java.util.TreeMap; // Note: This is forked from android.media.SubtitleTrack since P /** - * A subtitle track abstract base class that is responsible for parsing and displaying - * an instance of a particular type of subtitle. + * A subtitle track abstract base class that is responsible for parsing and displaying an instance + * of a particular type of subtitle. */ +@SuppressWarnings("deprecation") abstract class SubtitleTrack implements MediaTimeProvider.OnMediaTimeListener { private static final String TAG = "SubtitleTrack"; private long mLastUpdateTimeMs; @@ -75,10 +75,8 @@ abstract class SubtitleTrack implements MediaTimeProvider.OnMediaTimeListener { private long mNextScheduledTimeMs = -1; - /** - * Called when there is input data for the subtitle track. - */ - public void onData(SubtitleData data) { + /** Called when there is input data for the subtitle track. */ + public void onData(androidx.media2.common.SubtitleData data) { long runID = data.getStartTimeUs() + 1; onData(data.getData(), true /* eos */, runID); setRunDiscardTimeMs( diff --git a/media2/media2-widget/src/main/java/androidx/media2/widget/VideoSurfaceView.java b/media2/media2-widget/src/main/java/androidx/media2/widget/VideoSurfaceView.java index f3175504f00..ecc08de2454 100644 --- a/media2/media2-widget/src/main/java/androidx/media2/widget/VideoSurfaceView.java +++ b/media2/media2-widget/src/main/java/androidx/media2/widget/VideoSurfaceView.java @@ -16,8 +16,6 @@ package androidx.media2.widget; -import static androidx.media2.widget.VideoView.VIEW_TYPE_SURFACEVIEW; - import android.content.Context; import android.graphics.Rect; import android.view.Surface; @@ -26,8 +24,8 @@ import android.view.SurfaceView; import androidx.core.content.ContextCompat; -class VideoSurfaceView extends SurfaceView - implements VideoViewInterface, SurfaceHolder.Callback { +@SuppressWarnings("deprecation") +class VideoSurfaceView extends SurfaceView implements VideoViewInterface, SurfaceHolder.Callback { private Surface mSurface = null; SurfaceListener mSurfaceListener = null; private PlayerWrapper mPlayer; @@ -67,7 +65,7 @@ class VideoSurfaceView extends SurfaceView @Override public int getViewType() { - return VIEW_TYPE_SURFACEVIEW; + return androidx.media2.widget.VideoView.VIEW_TYPE_SURFACEVIEW; } @Override diff --git a/media2/media2-widget/src/main/java/androidx/media2/widget/VideoTextureView.java b/media2/media2-widget/src/main/java/androidx/media2/widget/VideoTextureView.java index 46e93b755de..da63d3fdf01 100644 --- a/media2/media2-widget/src/main/java/androidx/media2/widget/VideoTextureView.java +++ b/media2/media2-widget/src/main/java/androidx/media2/widget/VideoTextureView.java @@ -16,8 +16,6 @@ package androidx.media2.widget; -import static androidx.media2.widget.VideoView.VIEW_TYPE_TEXTUREVIEW; - import android.content.Context; import android.graphics.SurfaceTexture; import android.view.Surface; @@ -25,6 +23,7 @@ import android.view.TextureView; import androidx.core.content.ContextCompat; +@SuppressWarnings("deprecation") class VideoTextureView extends TextureView implements VideoViewInterface, TextureView.SurfaceTextureListener { private Surface mSurface; @@ -68,7 +67,7 @@ class VideoTextureView extends TextureView @Override public int getViewType() { - return VIEW_TYPE_TEXTUREVIEW; + return androidx.media2.widget.VideoView.VIEW_TYPE_TEXTUREVIEW; } @Override diff --git a/media2/media2-widget/src/main/java/androidx/media2/widget/VideoView.java b/media2/media2-widget/src/main/java/androidx/media2/widget/VideoView.java index 1edd4894663..20d400811a6 100644 --- a/media2/media2-widget/src/main/java/androidx/media2/widget/VideoView.java +++ b/media2/media2-widget/src/main/java/androidx/media2/widget/VideoView.java @@ -31,15 +31,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import androidx.core.view.ViewCompat; -import androidx.media2.common.BaseResult; -import androidx.media2.common.MediaItem; -import androidx.media2.common.MediaMetadata; -import androidx.media2.common.SessionPlayer; -import androidx.media2.common.SessionPlayer.TrackInfo; -import androidx.media2.common.SubtitleData; -import androidx.media2.common.VideoSize; -import androidx.media2.session.MediaController; -import androidx.media2.session.MediaSession; import androidx.palette.graphics.Palette; import com.google.common.util.concurrent.ListenableFuture; @@ -54,109 +45,129 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; /** - * A high level view for media playback that can be integrated with either a {@link SessionPlayer} - * or a {@link MediaController}. Developers can easily implement a video rendering application - * using this class. By default, a {@link MediaControlView} is attached so the playback - * control buttons are displayed on top of VideoView. - * <p> - * Contents: + * A high level view for media playback that can be integrated with either a {@link + * androidx.media2.common.SessionPlayer} or a {@link androidx.media2.session.MediaController}. + * Developers can easily implement a video rendering application using this class. By default, a + * {@link MediaControlView} is attached so the playback control buttons are displayed on top of + * VideoView. + * + * <p>Contents: + * * <ol> - * <li><a href="UseCases">Using VideoView with SessionPlayer or MediaController</a> - * <li><a href="UseWithMCV">Using VideoView with MediaControlView</a> - * <li><a href="ViewType">Choosing a view type</a> - * <li><a href="LegacyVideoView">Comparison with android.widget.VideoView</a> - * <li><a href="DisplayMetadata">Displaying Metadata</a> + * <li><a href="UseCases">Using VideoView with androidx.media2.common.SessionPlayer or + * androidx.media2.session.MediaController</a> + * <li><a href="UseWithMCV">Using VideoView with MediaControlView</a> + * <li><a href="ViewType">Choosing a view type</a> + * <li><a href="LegacyVideoView">Comparison with android.widget.VideoView</a> + * <li><a href="DisplayMetadata">Displaying Metadata</a> * </ol> * - * <h3 id="UseCases">Using VideoView with SessionPlayer or MediaController</h3> + * <h3 id="UseCases">Using VideoView with androidx.media2.common.SessionPlayer or + * androidx.media2.session.MediaController</h3> + * * <ul> - * <li> For simple use cases that do not require communication with a {@link MediaSession}, - * apps need to create a player instance that extends {@link SessionPlayer} (e.g. - * {@link androidx.media2.player.MediaPlayer}) and link it to this view by calling - * {@link #setPlayer}. - * <li> For more advanced use cases that require a {@link MediaSession} (e.g. handling media - * key events, integrating with other MediaSession apps as Assistant), apps need to create - * a {@link MediaController} that's attached to the {@link MediaSession} and link it to this - * view by calling {@link #setMediaController}. + * <li>For simple use cases that do not require communication with a {@link + * androidx.media2.session.MediaSession}, apps need to create a player instance that extends + * {@link androidx.media2.common.SessionPlayer} (e.g. {@link + * androidx.media2.player.MediaPlayer}) and link it to this view by calling {@link + * #setPlayer}. + * <li>For more advanced use cases that require a {@link androidx.media2.session.MediaSession} + * (e.g. handling media key events, integrating with other + * androidx.media2.session.MediaSession apps as Assistant), apps need to create a {@link + * androidx.media2.session.MediaController} that's attached to the {@link + * androidx.media2.session.MediaSession} and link it to this view by calling {@link + * #setMediaController}. * </ul> * * <h3 id="UseWithMCV">Using VideoView with MediaControlView</h3> - * {@link VideoView} is working with {@link MediaControlView} and a MediaControlView - * instance is attached to VideoView by default. - * <p> - * If you want to attach a custom {@link MediaControlView}, assign the custom media - * control widget using {@link #setMediaControlView}. - * <p> - * If you don't want to use {@link MediaControlView}, set - * the VideoView attribute {@link androidx.media2.widget.R.attr#enableControlView} to false. + * + * {@link VideoView} is working with {@link MediaControlView} and a MediaControlView instance is + * attached to VideoView by default. + * + * <p>If you want to attach a custom {@link MediaControlView}, assign the custom media control + * widget using {@link #setMediaControlView}. + * + * <p>If you don't want to use {@link MediaControlView}, set the VideoView attribute {@link + * androidx.media2.widget.R.attr#enableControlView} to false. * * <h3 id="ViewType">Choosing a view type</h3> - * VideoView can render videos on a TextureView or SurfaceView. The - * default is SurfaceView which can be changed by using the {@link #setViewType(int)} method or - * by setting the {@link androidx.media2.widget.R.attr#viewType} attribute in the layout file. - * <p> SurfaceView is recommended in most cases for saving battery life. - * TextureView might be preferred for supporting various UIs such as animation and translucency. + * + * VideoView can render videos on a TextureView or SurfaceView. The default is SurfaceView which can + * be changed by using the {@link #setViewType(int)} method or by setting the {@link + * androidx.media2.widget.R.attr#viewType} attribute in the layout file. + * + * <p>SurfaceView is recommended in most cases for saving battery life. TextureView might be + * preferred for supporting various UIs such as animation and translucency. * * <h3 id="LegacyVideoView">Comparison with android.widget.VideoView</h3> + * * These are the main differences between the media2 VideoView widget and the older android widget: + * * <ul> - * <li> - * {@link android.widget.VideoView android.widget.VideoView} creates a - * {@link android.media.MediaPlayer} instance internally and wraps playback APIs around it. - * <p> - * {@link VideoView androidx.media2.widget.VideoView} does not create a player instance - * internally. Instead, either a {@link SessionPlayer} or a {@link MediaController} instance - * should be created externally and link to {@link VideoView} using - * {@link #setPlayer(SessionPlayer)} or {@link #setMediaController(MediaController)}, - * respectively. - * <li> - * {@link android.widget.VideoView android.widget.VideoView} inherits from the SurfaceView - * class. - * <p> - * {@link VideoView androidx.media2.widget.VideoView} inherits from ViewGroup and can render - * videos using SurfaceView or TextureView, depending on your choice. - * <li> - * A {@link VideoView} can respond to media key events if you call {@link #setMediaController} - * to link it to a {@link MediaController} that's connected to an active {@link MediaSession}. + * <li>{@link android.widget.VideoView android.widget.VideoView} creates a {@link + * android.media.MediaPlayer} instance internally and wraps playback APIs around it. + * <p>{@link VideoView androidx.media2.widget.VideoView} does not create a player instance + * internally. Instead, either a {@link androidx.media2.common.SessionPlayer} or a {@link + * androidx.media2.session.MediaController} instance should be created externally and link to + * {@link VideoView} using {@link #setPlayer(androidx.media2.common.SessionPlayer)} or {@link + * #setMediaController(androidx.media2.session.MediaController)}, respectively. + * <li>{@link android.widget.VideoView android.widget.VideoView} inherits from the SurfaceView + * class. + * <p>{@link VideoView androidx.media2.widget.VideoView} inherits from ViewGroup and can + * render videos using SurfaceView or TextureView, depending on your choice. + * <li>A {@link VideoView} can respond to media key events if you call {@link #setMediaController} + * to link it to a {@link androidx.media2.session.MediaController} that's connected to an + * active {@link androidx.media2.session.MediaSession}. * </ul> * * <h3 id="DisplayMetadata">Displaying Metadata</h3> + * * When you play music only (sound with no video), VideoView can display album art and other - * metadata by calling {@link MediaItem#setMetadata(MediaMetadata)}. - * The following table shows the metadata displayed by the VideoView, and the default values - * assigned if the keys are not set: + * metadata by calling {@link + * androidx.media2.common.MediaItem#setMetadata(androidx.media2.common.MediaMetadata)}. The + * following table shows the metadata displayed by the VideoView, and the default values assigned if + * the keys are not set: + * * <table> * <tr><th>Key</th><th>Default</th></tr> - * <tr><td>{@link MediaMetadata#METADATA_KEY_TITLE}</td> + * <tr><td>{@link androidx.media2.common.MediaMetadata#METADATA_KEY_TITLE}</td> * <td>{@link androidx.media2.widget.R.string#mcv2_music_title_unknown_text}</td></tr> - * <tr><td>{@link MediaMetadata#METADATA_KEY_ARTIST}</td> + * <tr><td>{@link androidx.media2.common.MediaMetadata#METADATA_KEY_ARTIST}</td> * <td>{@link androidx.media2.widget.R.string#mcv2_music_artist_unknown_text}</td></tr> - * <tr><td>{@link MediaMetadata#METADATA_KEY_ALBUM_ART}</td> + * <tr><td>{@link androidx.media2.common.MediaMetadata#METADATA_KEY_ALBUM_ART}</td> * <td>{@link androidx.media2.widget.R.drawable#media2_widget_ic_default_album_image}</td></tr> * </table> - * <p> - * Note: VideoView does not retain its full state when going into the background. In particular, it - * does not save, and does not restore the current play state, play position, selected tracks. - * Applications should save and restore these on their own in - * {@link android.app.Activity#onSaveInstanceState} and - * {@link android.app.Activity#onRestoreInstanceState}. - * <p> Attributes : + * + * <p>Note: VideoView does not retain its full state when going into the background. In particular, + * it does not save, and does not restore the current play state, play position, selected tracks. + * Applications should save and restore these on their own in {@link + * android.app.Activity#onSaveInstanceState} and {@link + * android.app.Activity#onRestoreInstanceState}. + * + * <p>Attributes : + * * <ul> - * <li> {@link androidx.media2.widget.R.attr#enableControlView} - * <li> {@link androidx.media2.widget.R.attr#viewType} + * <li>{@link androidx.media2.widget.R.attr#enableControlView} + * <li>{@link androidx.media2.widget.R.attr#viewType} * </ul> - * <p> Example of attributes for a VideoView with TextureView and no attached control view: - * <pre> {@code - * <androidx.media2.widget.VideoView - * android:id="@+id/video_view" - * widget:enableControlView="false" - * widget:viewType="textureView" - * />}</pre> + * + * <p>Example of attributes for a VideoView with TextureView and no attached control view: + * + * <pre>{@code + * <androidx.media2.widget.VideoView + * android:id="@+id/video_view" + * widget:enableControlView="false" + * widget:viewType="textureView" + * /> + * }</pre> * * @see MediaControlView - * @see SessionPlayer - * @see MediaController + * @see androidx.media2.common.SessionPlayer + * @see androidx.media2.session.MediaController + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ +@Deprecated public class VideoView extends SelectiveLayout { @IntDef({ VIEW_TYPE_TEXTUREVIEW, @@ -198,11 +209,11 @@ public class VideoView extends SelectiveLayout { int mVideoTrackCount; int mAudioTrackCount; - Map<TrackInfo, SubtitleTrack> mSubtitleTracks; + Map<androidx.media2.common.SessionPlayer.TrackInfo, SubtitleTrack> mSubtitleTracks; SubtitleController mSubtitleController; // selected subtitle track info as MediaPlayer returns - TrackInfo mSelectedSubtitleTrackInfo; + androidx.media2.common.SessionPlayer.TrackInfo mSelectedSubtitleTrackInfo; SubtitleAnchorView mSubtitleAnchorView; @@ -289,30 +300,34 @@ public class VideoView extends SelectiveLayout { mSubtitleAnchorView.setBackgroundColor(0); addView(mSubtitleAnchorView, mSelectiveLayoutParams); - SubtitleController.Listener listener = new SubtitleController.Listener() { - @Override - public void onSubtitleTrackSelected(SubtitleTrack track) { - // Track deselected - if (track == null) { - mSelectedSubtitleTrackInfo = null; - mSubtitleAnchorView.setVisibility(View.GONE); - return; - } + SubtitleController.Listener listener = + new SubtitleController.Listener() { + @Override + public void onSubtitleTrackSelected(SubtitleTrack track) { + // Track deselected + if (track == null) { + mSelectedSubtitleTrackInfo = null; + mSubtitleAnchorView.setVisibility(View.GONE); + return; + } - // Track selected - TrackInfo info = null; - for (Map.Entry<TrackInfo, SubtitleTrack> pair : mSubtitleTracks.entrySet()) { - if (pair.getValue() == track) { - info = pair.getKey(); - break; + // Track selected + androidx.media2.common.SessionPlayer.TrackInfo info = null; + for (Map.Entry< + androidx.media2.common.SessionPlayer.TrackInfo, + SubtitleTrack> + pair : mSubtitleTracks.entrySet()) { + if (pair.getValue() == track) { + info = pair.getKey(); + break; + } + } + if (info != null) { + mSelectedSubtitleTrackInfo = info; + mSubtitleAnchorView.setVisibility(View.VISIBLE); + } } - } - if (info != null) { - mSelectedSubtitleTrackInfo = info; - mSubtitleAnchorView.setVisibility(View.VISIBLE); - } - } - }; + }; mSubtitleController = new SubtitleController(context, null, listener); mSubtitleController.registerRenderer(new Cea608CaptionRenderer(context)); mSubtitleController.registerRenderer(new Cea708CaptionRenderer(context)); @@ -355,21 +370,26 @@ public class VideoView extends SelectiveLayout { } /** - * Sets {@link MediaController} to display media content. - * Setting a {@link MediaController} will unset any {@link MediaController} or - * {@link SessionPlayer} that was previously set. - * <p> - * If VideoView has a {@link MediaControlView} instance, this controller will also be set to it. - * <p> - * Calling this method will automatically set VideoView's surface to {@link MediaController} - * by calling {@link MediaController#setSurface(Surface)}. If the {@link MediaController} is - * connected to a {@link MediaSession} and that {@link MediaSession} is associated with a - * {@link SessionPlayer}, VideoView's surface will be set to that {@link SessionPlayer}. + * Sets {@link androidx.media2.session.MediaController} to display media content. Setting a + * {@link androidx.media2.session.MediaController} will unset any {@link + * androidx.media2.session.MediaController} or {@link androidx.media2.common.SessionPlayer} that + * was previously set. + * + * <p>If VideoView has a {@link MediaControlView} instance, this controller will also be set to + * it. + * + * <p>Calling this method will automatically set VideoView's surface to {@link + * androidx.media2.session.MediaController} by calling {@link + * androidx.media2.session.MediaController#setSurface(Surface)}. If the {@link + * androidx.media2.session.MediaController} is connected to a {@link + * androidx.media2.session.MediaSession} and that {@link androidx.media2.session.MediaSession} + * is associated with a {@link androidx.media2.common.SessionPlayer}, VideoView's surface will + * be set to that {@link androidx.media2.common.SessionPlayer}. * * @param controller the controller * @see #setPlayer */ - public void setMediaController(@NonNull MediaController controller) { + public void setMediaController(@NonNull androidx.media2.session.MediaController controller) { if (controller == null) { throw new NullPointerException("controller must not be null"); } @@ -392,21 +412,21 @@ public class VideoView extends SelectiveLayout { } } - /** - * Sets {@link SessionPlayer} to display media content. - * Setting a SessionPlayer will unset any MediaController or SessionPlayer that was previously - * set. - * <p> - * If VideoView has a {@link MediaControlView} instance, this player will also be set to it. - * <p> - * Calling this method will automatically set VideoView's surface to {@link SessionPlayer} - * by calling {@link SessionPlayer#setSurface(Surface)}. + * Sets {@link androidx.media2.common.SessionPlayer} to display media content. Setting a + * androidx.media2.common.SessionPlayer will unset any androidx.media2.session.MediaController + * or androidx.media2.common.SessionPlayer that was previously set. + * + * <p>If VideoView has a {@link MediaControlView} instance, this player will also be set to it. + * + * <p>Calling this method will automatically set VideoView's surface to {@link + * androidx.media2.common.SessionPlayer} by calling {@link + * androidx.media2.common.SessionPlayer#setSurface(Surface)}. * * @param player the player * @see #setMediaController */ - public void setPlayer(@NonNull SessionPlayer player) { + public void setPlayer(@NonNull androidx.media2.common.SessionPlayer player) { if (player == null) { throw new NullPointerException("player must not be null"); } @@ -430,16 +450,17 @@ public class VideoView extends SelectiveLayout { } /** - * Sets {@link MediaControlView} instance. It will replace the previously assigned - * {@link MediaControlView} instance if any. - * <p> - * If a {@link MediaController} or a {@link SessionPlayer} instance has been set to - * {@link VideoView}, the same instance will be set to {@link MediaControlView}. + * Sets {@link MediaControlView} instance. It will replace the previously assigned {@link + * MediaControlView} instance if any. + * + * <p>If a {@link androidx.media2.session.MediaController} or a {@link + * androidx.media2.common.SessionPlayer} instance has been set to {@link VideoView}, the same + * instance will be set to {@link MediaControlView}. * * @param mediaControlView a {@link MediaControlView} instance. * @param intervalMs time interval in milliseconds until {@link MediaControlView} transitions - * into a different mode. -1 can be set to disable all UI transitions. See - * {@link MediaControlView} Javadoc Section "UI transitions" for details. + * into a different mode. -1 can be set to disable all UI transitions. See {@link + * MediaControlView} Javadoc Section "UI transitions" for details. */ public void setMediaControlView(@NonNull MediaControlView mediaControlView, long intervalMs) { if (mMediaControlView != null) { @@ -578,15 +599,17 @@ public class VideoView extends SelectiveLayout { /////////////////////////////////////////////////// boolean isMediaPrepared() { return mPlayer != null - && mPlayer.getPlayerState() != SessionPlayer.PLAYER_STATE_ERROR - && mPlayer.getPlayerState() != SessionPlayer.PLAYER_STATE_IDLE; + && mPlayer.getPlayerState() + != androidx.media2.common.SessionPlayer.PLAYER_STATE_ERROR + && mPlayer.getPlayerState() + != androidx.media2.common.SessionPlayer.PLAYER_STATE_IDLE; } boolean hasActualVideo() { if (mVideoTrackCount > 0) { return true; } - VideoSize videoSize = mPlayer.getVideoSize(); + androidx.media2.common.VideoSize videoSize = mPlayer.getVideoSize(); if (videoSize.getHeight() > 0 && videoSize.getWidth() > 0) { Log.w(TAG, "video track count is zero, but it renders video. size: " + videoSize.getWidth() + "/" + videoSize.getHeight()); @@ -599,42 +622,54 @@ public class VideoView extends SelectiveLayout { return !hasActualVideo() && mAudioTrackCount > 0; } - void updateTracks(PlayerWrapper player, List<TrackInfo> trackInfos) { + void updateTracks( + PlayerWrapper player, List<androidx.media2.common.SessionPlayer.TrackInfo> trackInfos) { mSubtitleTracks = new LinkedHashMap<>(); mVideoTrackCount = 0; mAudioTrackCount = 0; for (int i = 0; i < trackInfos.size(); i++) { - TrackInfo trackInfo = trackInfos.get(i); + androidx.media2.common.SessionPlayer.TrackInfo trackInfo = trackInfos.get(i); int trackType = trackInfos.get(i).getTrackType(); - if (trackType == TrackInfo.MEDIA_TRACK_TYPE_VIDEO) { + if (trackType + == androidx.media2.common.SessionPlayer.TrackInfo.MEDIA_TRACK_TYPE_VIDEO) { mVideoTrackCount++; - } else if (trackType == TrackInfo.MEDIA_TRACK_TYPE_AUDIO) { + } else if (trackType + == androidx.media2.common.SessionPlayer.TrackInfo.MEDIA_TRACK_TYPE_AUDIO) { mAudioTrackCount++; - } else if (trackType == TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE) { + } else if (trackType + == androidx.media2.common.SessionPlayer.TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE) { SubtitleTrack track = mSubtitleController.addTrack(trackInfo.getFormat()); if (track != null) { mSubtitleTracks.put(trackInfo, track); } } } - mSelectedSubtitleTrackInfo = player.getSelectedTrack(TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE); + mSelectedSubtitleTrackInfo = + player.getSelectedTrack( + androidx.media2.common.SessionPlayer.TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE); } - void updateMusicView(MediaItem item) { + void updateMusicView(androidx.media2.common.MediaItem item) { boolean shouldShowMusicView = item != null && isCurrentItemMusic(); if (shouldShowMusicView) { mMusicView.setVisibility(View.VISIBLE); - MediaMetadata metadata = item.getMetadata(); + androidx.media2.common.MediaMetadata metadata = item.getMetadata(); Resources resources = getResources(); Drawable albumDrawable = getAlbumArt(metadata, ContextCompat.getDrawable( getContext(), R.drawable.media2_widget_ic_default_album_image)); - String title = getString(metadata, MediaMetadata.METADATA_KEY_TITLE, - resources.getString(R.string.mcv2_music_title_unknown_text)); - String artist = getString(metadata, MediaMetadata.METADATA_KEY_ARTIST, - resources.getString(R.string.mcv2_music_artist_unknown_text)); + String title = + getString( + metadata, + androidx.media2.common.MediaMetadata.METADATA_KEY_TITLE, + resources.getString(R.string.mcv2_music_title_unknown_text)); + String artist = + getString( + metadata, + androidx.media2.common.MediaMetadata.METADATA_KEY_ARTIST, + resources.getString(R.string.mcv2_music_artist_unknown_text)); mMusicView.setAlbumDrawable(albumDrawable); mMusicView.setTitleText(title); @@ -652,7 +687,7 @@ public class VideoView extends SelectiveLayout { try { int resultCode = mPlayer.setSurface(null).get(100, TimeUnit.MILLISECONDS) .getResultCode(); - if (resultCode != BaseResult.RESULT_SUCCESS) { + if (resultCode != androidx.media2.common.BaseResult.RESULT_SUCCESS) { Log.e(TAG, "calling setSurface(null) was not " + "successful. ResultCode: " + resultCode); } @@ -663,30 +698,39 @@ public class VideoView extends SelectiveLayout { @SuppressWarnings("WeakerAccess") /* synthetic access */ void resetPlayerSurfaceWithNullAsync() { - ListenableFuture<? extends BaseResult> future = mPlayer.setSurface(null); + ListenableFuture<? extends androidx.media2.common.BaseResult> future = + mPlayer.setSurface(null); future.addListener( new Runnable() { @Override public void run() { try { int resultCode = future.get().getResultCode(); - if (resultCode != BaseResult.RESULT_SUCCESS) { - Log.e(TAG, "calling setSurface(null) was not " - + "successful. ResultCode: " + resultCode); + if (resultCode != androidx.media2.common.BaseResult.RESULT_SUCCESS) { + Log.e( + TAG, + "calling setSurface(null) was not " + + "successful. ResultCode: " + + resultCode); } } catch (ExecutionException | InterruptedException e) { Log.e(TAG, "calling setSurface(null) was not successful.", e); } } - }, ContextCompat.getMainExecutor(getContext())); + }, + ContextCompat.getMainExecutor(getContext())); } - private Drawable getAlbumArt(@NonNull MediaMetadata metadata, Drawable defaultDrawable) { + private Drawable getAlbumArt( + @NonNull androidx.media2.common.MediaMetadata metadata, Drawable defaultDrawable) { Drawable drawable = defaultDrawable; Bitmap bitmap = null; - if (metadata != null && metadata.containsKey(MediaMetadata.METADATA_KEY_ALBUM_ART)) { - bitmap = metadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART); + if (metadata != null + && metadata.containsKey( + androidx.media2.common.MediaMetadata.METADATA_KEY_ALBUM_ART)) { + bitmap = + metadata.getBitmap(androidx.media2.common.MediaMetadata.METADATA_KEY_ALBUM_ART); } if (bitmap != null) { Palette.Builder builder = Palette.from(bitmap); @@ -705,7 +749,9 @@ public class VideoView extends SelectiveLayout { return drawable; } - private String getString(@NonNull MediaMetadata metadata, String stringKey, + private String getString( + @NonNull androidx.media2.common.MediaMetadata metadata, + String stringKey, String defaultValue) { String value = (metadata == null) ? defaultValue : metadata.getString(stringKey); return value == null ? defaultValue : value; @@ -724,14 +770,17 @@ public class VideoView extends SelectiveLayout { } @Override - void onVideoSizeChanged(@NonNull PlayerWrapper player, @NonNull VideoSize videoSize) { + void onVideoSizeChanged( + @NonNull PlayerWrapper player, + @NonNull androidx.media2.common.VideoSize videoSize) { if (DEBUG) { - Log.d(TAG, "onVideoSizeChanged(): size: " + videoSize); + Log.d(TAG, "onandroidx.media2.common.VideoSizeChanged(): size: " + videoSize); } if (shouldIgnoreCallback(player)) return; if (mVideoTrackCount == 0 && videoSize.getHeight() > 0 && videoSize.getWidth() > 0) { if (isMediaPrepared()) { - List<TrackInfo> trackInfos = player.getTracks(); + List<androidx.media2.common.SessionPlayer.TrackInfo> trackInfos = + player.getTracks(); if (trackInfos != null) { updateTracks(player, trackInfos); } @@ -743,16 +792,25 @@ public class VideoView extends SelectiveLayout { } @Override - void onSubtitleData(@NonNull PlayerWrapper player, @NonNull MediaItem item, - @NonNull TrackInfo track, @NonNull SubtitleData data) { + void onSubtitleData( + @NonNull PlayerWrapper player, + @NonNull androidx.media2.common.MediaItem item, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo track, + @NonNull androidx.media2.common.SubtitleData data) { if (DEBUG) { - Log.d(TAG, "onSubtitleData():" - + " TrackInfo: " + track - + ", getCurrentPosition: " + player.getCurrentPosition() - + ", getStartTimeUs(): " + data.getStartTimeUs() - + ", diff: " - + (data.getStartTimeUs() / 1000 - player.getCurrentPosition()) - + "ms, getDurationUs(): " + data.getDurationUs()); + Log.d( + TAG, + "onandroidx.media2.common.SubtitleData():" + + " androidx.media2.common.SessionPlayer.TrackInfo: " + + track + + ", getCurrentPosition: " + + player.getCurrentPosition() + + ", getStartTimeUs(): " + + data.getStartTimeUs() + + ", diff: " + + (data.getStartTimeUs() / 1000 - player.getCurrentPosition()) + + "ms, getDurationUs(): " + + data.getDurationUs()); } if (shouldIgnoreCallback(player)) return; if (!track.equals(mSelectedSubtitleTrackInfo)) { @@ -770,15 +828,20 @@ public class VideoView extends SelectiveLayout { Log.d(TAG, "onPlayerStateChanged(): state: " + state); } if (shouldIgnoreCallback(player)) return; - if (state == SessionPlayer.PLAYER_STATE_ERROR) { + if (state == androidx.media2.common.SessionPlayer.PLAYER_STATE_ERROR) { // TODO: Show error state (b/123498635) } } @Override - void onCurrentMediaItemChanged(@NonNull PlayerWrapper player, @Nullable MediaItem item) { + void onCurrentMediaItemChanged( + @NonNull PlayerWrapper player, @Nullable androidx.media2.common.MediaItem item) { if (DEBUG) { - Log.d(TAG, "onCurrentMediaItemChanged(): MediaItem: " + item); + Log.d( + TAG, + "onCurrentMediaItemChanged():" + + " androidx.media2.common.MediaItem: " + + item); } if (shouldIgnoreCallback(player)) return; @@ -786,9 +849,14 @@ public class VideoView extends SelectiveLayout { } @Override - void onTracksChanged(@NonNull PlayerWrapper player, @NonNull List<TrackInfo> tracks) { + void onTracksChanged( + @NonNull PlayerWrapper player, + @NonNull List<androidx.media2.common.SessionPlayer.TrackInfo> tracks) { if (DEBUG) { - Log.d(TAG, "onTrackInfoChanged(): tracks: " + tracks); + Log.d( + TAG, + "onandroidx.media2.common.SessionPlayer.TrackInfoChanged(): tracks: " + + tracks); } if (shouldIgnoreCallback(player)) return; updateTracks(player, tracks); @@ -796,7 +864,9 @@ public class VideoView extends SelectiveLayout { } @Override - void onTrackSelected(@NonNull PlayerWrapper player, @NonNull TrackInfo trackInfo) { + void onTrackSelected( + @NonNull PlayerWrapper player, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo trackInfo) { if (DEBUG) { Log.d(TAG, "onTrackSelected(): selected track: " + trackInfo); } @@ -808,7 +878,9 @@ public class VideoView extends SelectiveLayout { } @Override - void onTrackDeselected(@NonNull PlayerWrapper player, @NonNull TrackInfo trackInfo) { + void onTrackDeselected( + @NonNull PlayerWrapper player, + @NonNull androidx.media2.common.SessionPlayer.TrackInfo trackInfo) { if (DEBUG) { Log.d(TAG, "onTrackDeselected(): deselected track: " + trackInfo); } @@ -838,7 +910,11 @@ public class VideoView extends SelectiveLayout { /** * Interface definition of a callback to be invoked when the view type has been changed. + * + * @deprecated androidx.media2 is deprecated. Please migrate to <a + * href="https://developer.android.com/guide/topics/media/media3">androidx.media3</a>. */ + @Deprecated public interface OnViewTypeChangedListener { /** * Called when the view type has been changed. |