Add getMediaItemCount() and getMediaItemAt(int)

PiperOrigin-RevId: 331211708
This commit is contained in:
bachinger 2020-09-11 21:27:43 +01:00 committed by Oliver Woodman
parent 12b0537c2f
commit 4f982763cf
3 changed files with 20 additions and 3 deletions

View file

@ -1,6 +1,6 @@
# Release notes
### 2.12.0 (2020-09-03) ###
### 2.12.0 (2020-09-11) ###
* Core library:
* `Player`:
@ -8,8 +8,9 @@
([#6161](https://github.com/google/ExoPlayer/issues/6161)). The
new methods for playlist manipulation are `setMediaItem(s)`,
`addMediaItem(s)`, `moveMediaItem(s)`, `removeMediaItem(s)` and
`clearMediaItems`. This API should be used instead of
`ConcatenatingMediaSource` in most cases.
`clearMediaItems`. The playlist can be queried using
`getMediaItemCount` and `getMediaItemAt`. This API should be used
instead of `ConcatenatingMediaSource` in most cases.
* Add `getCurrentMediaItem` for getting the currently playing item
in the playlist.
* Add `EventListener.onMediaItemTransition` to report when

View file

@ -185,6 +185,16 @@ public abstract class BasePlayer implements Player {
: timeline.getWindow(getCurrentWindowIndex(), window).mediaItem;
}
@Override
public int getMediaItemCount() {
return getCurrentTimeline().getWindowCount();
}
@Override
public MediaItem getMediaItemAt(int index) {
return getCurrentTimeline().getWindow(index, window).mediaItem;
}
@Override
@Nullable
public final Object getCurrentManifest() {

View file

@ -1284,6 +1284,12 @@ public interface Player {
@Nullable
MediaItem getCurrentMediaItem();
/** Returns the number of {@link MediaItem media items} in the playlist. */
int getMediaItemCount();
/** Returns the {@link MediaItem} at the given index. */
MediaItem getMediaItemAt(int index);
/**
* Returns the duration of the current content window or ad in milliseconds, or {@link
* C#TIME_UNSET} if the duration is not known.