39
39
import androidx .core .app .NotificationCompat ;
40
40
import androidx .media .MediaSessionManager .RemoteUserInfo ;
41
41
import androidx .media3 .common .AudioAttributes ;
42
+ import androidx .media3 .common .C ;
42
43
import androidx .media3 .common .DeviceInfo ;
43
44
import androidx .media3 .common .MediaItem ;
44
45
import androidx .media3 .common .MediaLibraryInfo ;
@@ -1180,9 +1181,9 @@ default ListenableFuture<List<MediaItem>> onAddMediaItems(
1180
1181
* the items directly by using Guava's {@link Futures#immediateFuture(Object)}. Once the {@link
1181
1182
* MediaItemsWithStartPosition} has been resolved, the session will call {@link
1182
1183
* 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}.
1186
1187
*
1187
1188
* <p>Interoperability: This method will be called in response to the following {@link
1188
1189
* MediaControllerCompat} methods:
@@ -1207,19 +1208,18 @@ default ListenableFuture<List<MediaItem>> onAddMediaItems(
1207
1208
* @param controller The controller information.
1208
1209
* @param mediaItems The list of requested {@linkplain MediaItem media items}.
1209
1210
* @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.
1212
1213
* @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
1215
1216
* @return A {@link ListenableFuture} with a {@link MediaItemsWithStartPosition} containing a
1216
1217
* list of resolved {@linkplain MediaItem media items}, and a starting index and position
1217
1218
* 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.
1223
1223
*/
1224
1224
@ UnstableApi
1225
1225
default ListenableFuture <MediaItemsWithStartPosition > onSetMediaItems (
@@ -1251,34 +1251,35 @@ default ListenableFuture<MediaItemsWithStartPosition> onPlaybackResumption(
1251
1251
}
1252
1252
}
1253
1253
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. */
1255
1255
@ UnstableApi
1256
1256
public static final class MediaItemsWithStartPosition {
1257
- /** List of {@link MediaItem media items}. */
1257
+ /** List of {@linkplain MediaItem media items}. */
1258
1258
public final ImmutableList <MediaItem > mediaItems ;
1259
1259
/**
1260
- * Index to start playing at in {@link MediaItem} list .
1260
+ * Index to start playing at in {@link #mediaItems} .
1261
1261
*
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.
1265
1264
*/
1266
1265
public final int startIndex ;
1267
1266
/**
1268
- * Position to start playing from in starting media item.
1267
+ * Position in milliseconds to start playing from in the starting media item.
1269
1268
*
1270
1269
* <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}.
1273
1272
*/
1274
1273
public final long startPositionMs ;
1275
1274
1276
1275
/**
1277
- * Create an instance.
1276
+ * Creates an instance.
1278
1277
*
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.
1282
1283
*/
1283
1284
public MediaItemsWithStartPosition (
1284
1285
List <MediaItem > mediaItems , int startIndex , long startPositionMs ) {
@@ -1507,17 +1508,19 @@ default void onRenderedFirstFrame(int seq) throws RemoteException {}
1507
1508
* applied to the subclasses.
1508
1509
*/
1509
1510
/* 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 > {
1511
1514
1512
1515
/* package */ final Context context ;
1513
1516
/* package */ final Player player ;
1514
1517
/* package */ String id ;
1515
- /* package */ C callback ;
1518
+ /* package */ CallbackT callback ;
1516
1519
/* package */ @ Nullable PendingIntent sessionActivity ;
1517
1520
/* package */ Bundle extras ;
1518
1521
/* package */ @ MonotonicNonNull BitmapLoader bitmapLoader ;
1519
1522
1520
- public BuilderBase (Context context , Player player , C callback ) {
1523
+ public BuilderBase (Context context , Player player , CallbackT callback ) {
1521
1524
this .context = checkNotNull (context );
1522
1525
this .player = checkNotNull (player );
1523
1526
checkArgument (player .canAdvertiseSession ());
@@ -1527,35 +1530,35 @@ public BuilderBase(Context context, Player player, C callback) {
1527
1530
}
1528
1531
1529
1532
@ SuppressWarnings ("unchecked" )
1530
- public U setSessionActivity (PendingIntent pendingIntent ) {
1533
+ public BuilderT setSessionActivity (PendingIntent pendingIntent ) {
1531
1534
sessionActivity = checkNotNull (pendingIntent );
1532
- return (U ) this ;
1535
+ return (BuilderT ) this ;
1533
1536
}
1534
1537
1535
1538
@ SuppressWarnings ("unchecked" )
1536
- public U setId (String id ) {
1539
+ public BuilderT setId (String id ) {
1537
1540
this .id = checkNotNull (id );
1538
- return (U ) this ;
1541
+ return (BuilderT ) this ;
1539
1542
}
1540
1543
1541
1544
@ SuppressWarnings ("unchecked" )
1542
- /* package */ U setCallback (C callback ) {
1545
+ /* package */ BuilderT setCallback (CallbackT callback ) {
1543
1546
this .callback = checkNotNull (callback );
1544
- return (U ) this ;
1547
+ return (BuilderT ) this ;
1545
1548
}
1546
1549
1547
1550
@ SuppressWarnings ("unchecked" )
1548
- public U setExtras (Bundle extras ) {
1551
+ public BuilderT setExtras (Bundle extras ) {
1549
1552
this .extras = new Bundle (checkNotNull (extras ));
1550
- return (U ) this ;
1553
+ return (BuilderT ) this ;
1551
1554
}
1552
1555
1553
1556
@ SuppressWarnings ("unchecked" )
1554
- public U setBitmapLoader (BitmapLoader bitmapLoader ) {
1557
+ public BuilderT setBitmapLoader (BitmapLoader bitmapLoader ) {
1555
1558
this .bitmapLoader = bitmapLoader ;
1556
- return (U ) this ;
1559
+ return (BuilderT ) this ;
1557
1560
}
1558
1561
1559
- public abstract T build ();
1562
+ public abstract SessionT build ();
1560
1563
}
1561
1564
}
0 commit comments