Javadoc tweaks for MediaSession.MediaItemsWithPosition

Also change some type parameter names in `MediaSession.BuilderBase`
because `C` now clashes with the import of `androidx.media3.common.C`.

#minor-release

PiperOrigin-RevId: 529665698
This commit is contained in:
ibaker 2023-05-05 09:53:52 +00:00 committed by Tofunmi Adigun-Hameed
parent 83b5f824f8
commit 78f20257bd

View File

@ -39,6 +39,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat;
import androidx.media.MediaSessionManager.RemoteUserInfo; import androidx.media.MediaSessionManager.RemoteUserInfo;
import androidx.media3.common.AudioAttributes; import androidx.media3.common.AudioAttributes;
import androidx.media3.common.C;
import androidx.media3.common.DeviceInfo; import androidx.media3.common.DeviceInfo;
import androidx.media3.common.MediaItem; import androidx.media3.common.MediaItem;
import androidx.media3.common.MediaLibraryInfo; import androidx.media3.common.MediaLibraryInfo;
@ -1180,9 +1181,9 @@ public class MediaSession {
* the items directly by using Guava's {@link Futures#immediateFuture(Object)}. Once the {@link * the items directly by using Guava's {@link Futures#immediateFuture(Object)}. Once the {@link
* MediaItemsWithStartPosition} has been resolved, the session will call {@link * MediaItemsWithStartPosition} has been resolved, the session will call {@link
* Player#setMediaItems} as requested. If the resolved {@link * Player#setMediaItems} as requested. If the resolved {@link
* MediaItemsWithStartPosition#startIndex startIndex} is {@link * MediaItemsWithStartPosition#startIndex startIndex} is {@link C#INDEX_UNSET C.INDEX_UNSET}
* androidx.media3.common.C#INDEX_UNSET C.INDEX_UNSET} then the session will call {@link * then the session will call {@link Player#setMediaItem(MediaItem, boolean)} with {@code
* Player#setMediaItem(MediaItem, boolean)} with {@code resetPosition} set to {@code true}. * resetPosition} set to {@code true}.
* *
* <p>Interoperability: This method will be called in response to the following {@link * <p>Interoperability: This method will be called in response to the following {@link
* MediaControllerCompat} methods: * MediaControllerCompat} methods:
@ -1207,19 +1208,18 @@ public class MediaSession {
* @param controller The controller information. * @param controller The controller information.
* @param mediaItems The list of requested {@linkplain MediaItem media items}. * @param mediaItems The list of requested {@linkplain MediaItem media items}.
* @param startIndex The start index in the {@link MediaItem} list from which to start playing, * @param startIndex The start index in the {@link MediaItem} list from which to start playing,
* or {@link androidx.media3.common.C#INDEX_UNSET C.INDEX_UNSET} to start playing from the * or {@link C#INDEX_UNSET C.INDEX_UNSET} to start playing from the default index in the
* default index in the playlist. * playlist.
* @param startPositionMs The starting position in the media item from where to start playing, * @param startPositionMs The starting position in the media item from where to start playing,
* or {@link androidx.media3.common.C#TIME_UNSET C.TIME_UNSET} to start playing from the * or {@link C#TIME_UNSET C.TIME_UNSET} to start playing from the default position in the
* default position in the media item. This value is ignored if startIndex is C.INDEX_UNSET * media item. This value is ignored if startIndex is C.INDEX_UNSET
* @return A {@link ListenableFuture} with a {@link MediaItemsWithStartPosition} containing a * @return A {@link ListenableFuture} with a {@link MediaItemsWithStartPosition} containing a
* list of resolved {@linkplain MediaItem media items}, and a starting index and position * list of resolved {@linkplain MediaItem media items}, and a starting index and position
* that are playable by the underlying {@link Player}. If returned {@link * that are playable by the underlying {@link Player}. If returned {@link
* MediaItemsWithStartPosition#startIndex} is {@link androidx.media3.common.C#INDEX_UNSET * MediaItemsWithStartPosition#startIndex} is {@link C#INDEX_UNSET C.INDEX_UNSET} and {@link
* C.INDEX_UNSET} and {@link MediaItemsWithStartPosition#startPositionMs} is {@link * MediaItemsWithStartPosition#startPositionMs} is {@link C#TIME_UNSET C.TIME_UNSET}, then
* androidx.media3.common.C#TIME_UNSET C.TIME_UNSET}, then {@linkplain * {@linkplain Player#setMediaItems(List, boolean) Player#setMediaItems(List, true)} will be
* Player#setMediaItems(List, boolean) Player#setMediaItems(List, true)} will be called to * called to set media items with default index and position.
* set media items with default index and position.
*/ */
@UnstableApi @UnstableApi
default ListenableFuture<MediaItemsWithStartPosition> onSetMediaItems( default ListenableFuture<MediaItemsWithStartPosition> onSetMediaItems(
@ -1251,34 +1251,35 @@ public class MediaSession {
} }
} }
/** Representation of list of media items and where to start playing */ /** Representation of a list of {@linkplain MediaItem media items} and where to start playing. */
@UnstableApi @UnstableApi
public static final class MediaItemsWithStartPosition { public static final class MediaItemsWithStartPosition {
/** List of {@link MediaItem media items}. */ /** List of {@linkplain MediaItem media items}. */
public final ImmutableList<MediaItem> mediaItems; public final ImmutableList<MediaItem> mediaItems;
/** /**
* Index to start playing at in {@link MediaItem} list. * Index to start playing at in {@link #mediaItems}.
* *
* <p>The start index in the {@link MediaItem} list from which to start playing, or {@link * <p>The start index in {@link #mediaItems} from which to start playing, or {@link
* androidx.media3.common.C#INDEX_UNSET C.INDEX_UNSET} to start playing from the default index * C#INDEX_UNSET} to start playing from the default index in the playlist.
* in the playlist.
*/ */
public final int startIndex; public final int startIndex;
/** /**
* Position to start playing from in starting media item. * Position in milliseconds to start playing from in the starting media item.
* *
* <p>The starting position in the media item from where to start playing, or {@link * <p>The starting position in the media item from where to start playing, or {@link
* androidx.media3.common.C#TIME_UNSET C.TIME_UNSET} to start playing from the default position * C#TIME_UNSET} to start playing from the default position in the media item. This value is
* in the media item. This value is ignored if startIndex is C.INDEX_UNSET * ignored if {@code startIndex} is {@link C#INDEX_UNSET}.
*/ */
public final long startPositionMs; public final long startPositionMs;
/** /**
* Create an instance. * Creates an instance.
* *
* @param mediaItems List of {@link MediaItem media items}. * @param mediaItems List of {@linkplain MediaItem media items}.
* @param startIndex Index to start playing at in {@link MediaItem} list. * @param startIndex Index to start playing at in {@code mediaItems}, or {@link C#INDEX_UNSET}
* @param startPositionMs Position to start playing from in starting media item. * to start from the default index.
* @param startPositionMs Position in milliseconds to start playing from in the starting media
* item, or {@link C#TIME_UNSET} to start from the default position.
*/ */
public MediaItemsWithStartPosition( public MediaItemsWithStartPosition(
List<MediaItem> mediaItems, int startIndex, long startPositionMs) { List<MediaItem> mediaItems, int startIndex, long startPositionMs) {
@ -1507,17 +1508,19 @@ public class MediaSession {
* applied to the subclasses. * applied to the subclasses.
*/ */
/* package */ abstract static class BuilderBase< /* package */ abstract static class BuilderBase<
T extends MediaSession, U extends BuilderBase<T, U, C>, C extends Callback> { SessionT extends MediaSession,
BuilderT extends BuilderBase<SessionT, BuilderT, CallbackT>,
CallbackT extends Callback> {
/* package */ final Context context; /* package */ final Context context;
/* package */ final Player player; /* package */ final Player player;
/* package */ String id; /* package */ String id;
/* package */ C callback; /* package */ CallbackT callback;
/* package */ @Nullable PendingIntent sessionActivity; /* package */ @Nullable PendingIntent sessionActivity;
/* package */ Bundle extras; /* package */ Bundle extras;
/* package */ @MonotonicNonNull BitmapLoader bitmapLoader; /* package */ @MonotonicNonNull BitmapLoader bitmapLoader;
public BuilderBase(Context context, Player player, C callback) { public BuilderBase(Context context, Player player, CallbackT callback) {
this.context = checkNotNull(context); this.context = checkNotNull(context);
this.player = checkNotNull(player); this.player = checkNotNull(player);
checkArgument(player.canAdvertiseSession()); checkArgument(player.canAdvertiseSession());
@ -1527,35 +1530,35 @@ public class MediaSession {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public U setSessionActivity(PendingIntent pendingIntent) { public BuilderT setSessionActivity(PendingIntent pendingIntent) {
sessionActivity = checkNotNull(pendingIntent); sessionActivity = checkNotNull(pendingIntent);
return (U) this; return (BuilderT) this;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public U setId(String id) { public BuilderT setId(String id) {
this.id = checkNotNull(id); this.id = checkNotNull(id);
return (U) this; return (BuilderT) this;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
/* package */ U setCallback(C callback) { /* package */ BuilderT setCallback(CallbackT callback) {
this.callback = checkNotNull(callback); this.callback = checkNotNull(callback);
return (U) this; return (BuilderT) this;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public U setExtras(Bundle extras) { public BuilderT setExtras(Bundle extras) {
this.extras = new Bundle(checkNotNull(extras)); this.extras = new Bundle(checkNotNull(extras));
return (U) this; return (BuilderT) this;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public U setBitmapLoader(BitmapLoader bitmapLoader) { public BuilderT setBitmapLoader(BitmapLoader bitmapLoader) {
this.bitmapLoader = bitmapLoader; this.bitmapLoader = bitmapLoader;
return (U) this; return (BuilderT) this;
} }
public abstract T build(); public abstract SessionT build();
} }
} }