Commit 4f982763 by bachinger Committed by Oliver Woodman

Add getMediaItemCount() and getMediaItemAt(int)

PiperOrigin-RevId: 331211708
parent 12b0537c
# Release notes # Release notes
### 2.12.0 (2020-09-03) ### ### 2.12.0 (2020-09-11) ###
* Core library: * Core library:
* `Player`: * `Player`:
...@@ -8,8 +8,9 @@ ...@@ -8,8 +8,9 @@
([#6161](https://github.com/google/ExoPlayer/issues/6161)). The ([#6161](https://github.com/google/ExoPlayer/issues/6161)). The
new methods for playlist manipulation are `setMediaItem(s)`, new methods for playlist manipulation are `setMediaItem(s)`,
`addMediaItem(s)`, `moveMediaItem(s)`, `removeMediaItem(s)` and `addMediaItem(s)`, `moveMediaItem(s)`, `removeMediaItem(s)` and
`clearMediaItems`. This API should be used instead of `clearMediaItems`. The playlist can be queried using
`ConcatenatingMediaSource` in most cases. `getMediaItemCount` and `getMediaItemAt`. This API should be used
instead of `ConcatenatingMediaSource` in most cases.
* Add `getCurrentMediaItem` for getting the currently playing item * Add `getCurrentMediaItem` for getting the currently playing item
in the playlist. in the playlist.
* Add `EventListener.onMediaItemTransition` to report when * Add `EventListener.onMediaItemTransition` to report when
......
...@@ -186,6 +186,16 @@ public abstract class BasePlayer implements Player { ...@@ -186,6 +186,16 @@ public abstract class BasePlayer implements Player {
} }
@Override @Override
public int getMediaItemCount() {
return getCurrentTimeline().getWindowCount();
}
@Override
public MediaItem getMediaItemAt(int index) {
return getCurrentTimeline().getWindow(index, window).mediaItem;
}
@Override
@Nullable @Nullable
public final Object getCurrentManifest() { public final Object getCurrentManifest() {
Timeline timeline = getCurrentTimeline(); Timeline timeline = getCurrentTimeline();
......
...@@ -1284,6 +1284,12 @@ public interface Player { ...@@ -1284,6 +1284,12 @@ public interface Player {
@Nullable @Nullable
MediaItem getCurrentMediaItem(); 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 * Returns the duration of the current content window or ad in milliseconds, or {@link
* C#TIME_UNSET} if the duration is not known. * C#TIME_UNSET} if the duration is not known.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment