Skip to content

Commit 78f2025

Browse files
icbakertof-tof
authored andcommitted
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
1 parent 83b5f82 commit 78f2025

File tree

1 file changed

+42
-39
lines changed

1 file changed

+42
-39
lines changed

libraries/session/src/main/java/androidx/media3/session/MediaSession.java

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import androidx.core.app.NotificationCompat;
4040
import androidx.media.MediaSessionManager.RemoteUserInfo;
4141
import androidx.media3.common.AudioAttributes;
42+
import androidx.media3.common.C;
4243
import androidx.media3.common.DeviceInfo;
4344
import androidx.media3.common.MediaItem;
4445
import androidx.media3.common.MediaLibraryInfo;
@@ -1180,9 +1181,9 @@ default ListenableFuture<List<MediaItem>> onAddMediaItems(
11801181
* the items directly by using Guava's {@link Futures#immediateFuture(Object)}. Once the {@link
11811182
* MediaItemsWithStartPosition} has been resolved, the session will call {@link
11821183
* Player#setMediaItems} as requested. If the resolved {@link
1183-
* MediaItemsWithStartPosition#startIndex startIndex} is {@link
1184-
* androidx.media3.common.C#INDEX_UNSET C.INDEX_UNSET} then the session will call {@link
1185-
* Player#setMediaItem(MediaItem, boolean)} with {@code resetPosition} set to {@code true}.
1184+
* MediaItemsWithStartPosition#startIndex startIndex} is {@link C#INDEX_UNSET C.INDEX_UNSET}
1185+
* then the session will call {@link Player#setMediaItem(MediaItem, boolean)} with {@code
1186+
* resetPosition} set to {@code true}.
11861187
*
11871188
* <p>Interoperability: This method will be called in response to the following {@link
11881189
* MediaControllerCompat} methods:
@@ -1207,19 +1208,18 @@ default ListenableFuture<List<MediaItem>> onAddMediaItems(
12071208
* @param controller The controller information.
12081209
* @param mediaItems The list of requested {@linkplain MediaItem media items}.
12091210
* @param startIndex The start index in the {@link MediaItem} list from which to start playing,
1210-
* or {@link androidx.media3.common.C#INDEX_UNSET C.INDEX_UNSET} to start playing from the
1211-
* default index in the playlist.
1211+
* or {@link C#INDEX_UNSET C.INDEX_UNSET} to start playing from the default index in the
1212+
* playlist.
12121213
* @param startPositionMs The starting position in the media item from where to start playing,
1213-
* or {@link androidx.media3.common.C#TIME_UNSET C.TIME_UNSET} to start playing from the
1214-
* default position in the media item. This value is ignored if startIndex is C.INDEX_UNSET
1214+
* or {@link C#TIME_UNSET C.TIME_UNSET} to start playing from the default position in the
1215+
* media item. This value is ignored if startIndex is C.INDEX_UNSET
12151216
* @return A {@link ListenableFuture} with a {@link MediaItemsWithStartPosition} containing a
12161217
* list of resolved {@linkplain MediaItem media items}, and a starting index and position
12171218
* that are playable by the underlying {@link Player}. If returned {@link
1218-
* MediaItemsWithStartPosition#startIndex} is {@link androidx.media3.common.C#INDEX_UNSET
1219-
* C.INDEX_UNSET} and {@link MediaItemsWithStartPosition#startPositionMs} is {@link
1220-
* androidx.media3.common.C#TIME_UNSET C.TIME_UNSET}, then {@linkplain
1221-
* Player#setMediaItems(List, boolean) Player#setMediaItems(List, true)} will be called to
1222-
* set media items with default index and position.
1219+
* MediaItemsWithStartPosition#startIndex} is {@link C#INDEX_UNSET C.INDEX_UNSET} and {@link
1220+
* MediaItemsWithStartPosition#startPositionMs} is {@link C#TIME_UNSET C.TIME_UNSET}, then
1221+
* {@linkplain Player#setMediaItems(List, boolean) Player#setMediaItems(List, true)} will be
1222+
* called to set media items with default index and position.
12231223
*/
12241224
@UnstableApi
12251225
default ListenableFuture<MediaItemsWithStartPosition> onSetMediaItems(
@@ -1251,34 +1251,35 @@ default ListenableFuture<MediaItemsWithStartPosition> onPlaybackResumption(
12511251
}
12521252
}
12531253

1254-
/** Representation of list of media items and where to start playing */
1254+
/** Representation of a list of {@linkplain MediaItem media items} and where to start playing. */
12551255
@UnstableApi
12561256
public static final class MediaItemsWithStartPosition {
1257-
/** List of {@link MediaItem media items}. */
1257+
/** List of {@linkplain MediaItem media items}. */
12581258
public final ImmutableList<MediaItem> mediaItems;
12591259
/**
1260-
* Index to start playing at in {@link MediaItem} list.
1260+
* Index to start playing at in {@link #mediaItems}.
12611261
*
1262-
* <p>The start index in the {@link MediaItem} list from which to start playing, or {@link
1263-
* androidx.media3.common.C#INDEX_UNSET C.INDEX_UNSET} to start playing from the default index
1264-
* in the playlist.
1262+
* <p>The start index in {@link #mediaItems} from which to start playing, or {@link
1263+
* C#INDEX_UNSET} to start playing from the default index in the playlist.
12651264
*/
12661265
public final int startIndex;
12671266
/**
1268-
* Position to start playing from in starting media item.
1267+
* Position in milliseconds to start playing from in the starting media item.
12691268
*
12701269
* <p>The starting position in the media item from where to start playing, or {@link
1271-
* androidx.media3.common.C#TIME_UNSET C.TIME_UNSET} to start playing from the default position
1272-
* in the media item. This value is ignored if startIndex is C.INDEX_UNSET
1270+
* C#TIME_UNSET} to start playing from the default position in the media item. This value is
1271+
* ignored if {@code startIndex} is {@link C#INDEX_UNSET}.
12731272
*/
12741273
public final long startPositionMs;
12751274

12761275
/**
1277-
* Create an instance.
1276+
* Creates an instance.
12781277
*
1279-
* @param mediaItems List of {@link MediaItem media items}.
1280-
* @param startIndex Index to start playing at in {@link MediaItem} list.
1281-
* @param startPositionMs Position to start playing from in starting media item.
1278+
* @param mediaItems List of {@linkplain MediaItem media items}.
1279+
* @param startIndex Index to start playing at in {@code mediaItems}, or {@link C#INDEX_UNSET}
1280+
* to start from the default index.
1281+
* @param startPositionMs Position in milliseconds to start playing from in the starting media
1282+
* item, or {@link C#TIME_UNSET} to start from the default position.
12821283
*/
12831284
public MediaItemsWithStartPosition(
12841285
List<MediaItem> mediaItems, int startIndex, long startPositionMs) {
@@ -1507,17 +1508,19 @@ default void onRenderedFirstFrame(int seq) throws RemoteException {}
15071508
* applied to the subclasses.
15081509
*/
15091510
/* package */ abstract static class BuilderBase<
1510-
T extends MediaSession, U extends BuilderBase<T, U, C>, C extends Callback> {
1511+
SessionT extends MediaSession,
1512+
BuilderT extends BuilderBase<SessionT, BuilderT, CallbackT>,
1513+
CallbackT extends Callback> {
15111514

15121515
/* package */ final Context context;
15131516
/* package */ final Player player;
15141517
/* package */ String id;
1515-
/* package */ C callback;
1518+
/* package */ CallbackT callback;
15161519
/* package */ @Nullable PendingIntent sessionActivity;
15171520
/* package */ Bundle extras;
15181521
/* package */ @MonotonicNonNull BitmapLoader bitmapLoader;
15191522

1520-
public BuilderBase(Context context, Player player, C callback) {
1523+
public BuilderBase(Context context, Player player, CallbackT callback) {
15211524
this.context = checkNotNull(context);
15221525
this.player = checkNotNull(player);
15231526
checkArgument(player.canAdvertiseSession());
@@ -1527,35 +1530,35 @@ public BuilderBase(Context context, Player player, C callback) {
15271530
}
15281531

15291532
@SuppressWarnings("unchecked")
1530-
public U setSessionActivity(PendingIntent pendingIntent) {
1533+
public BuilderT setSessionActivity(PendingIntent pendingIntent) {
15311534
sessionActivity = checkNotNull(pendingIntent);
1532-
return (U) this;
1535+
return (BuilderT) this;
15331536
}
15341537

15351538
@SuppressWarnings("unchecked")
1536-
public U setId(String id) {
1539+
public BuilderT setId(String id) {
15371540
this.id = checkNotNull(id);
1538-
return (U) this;
1541+
return (BuilderT) this;
15391542
}
15401543

15411544
@SuppressWarnings("unchecked")
1542-
/* package */ U setCallback(C callback) {
1545+
/* package */ BuilderT setCallback(CallbackT callback) {
15431546
this.callback = checkNotNull(callback);
1544-
return (U) this;
1547+
return (BuilderT) this;
15451548
}
15461549

15471550
@SuppressWarnings("unchecked")
1548-
public U setExtras(Bundle extras) {
1551+
public BuilderT setExtras(Bundle extras) {
15491552
this.extras = new Bundle(checkNotNull(extras));
1550-
return (U) this;
1553+
return (BuilderT) this;
15511554
}
15521555

15531556
@SuppressWarnings("unchecked")
1554-
public U setBitmapLoader(BitmapLoader bitmapLoader) {
1557+
public BuilderT setBitmapLoader(BitmapLoader bitmapLoader) {
15551558
this.bitmapLoader = bitmapLoader;
1556-
return (U) this;
1559+
return (BuilderT) this;
15571560
}
15581561

1559-
public abstract T build();
1562+
public abstract SessionT build();
15601563
}
15611564
}

0 commit comments

Comments
 (0)