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 bff7ac0dbe
commit 91a491ea31
3 changed files with 18 additions and 0 deletions

View file

@ -2,6 +2,8 @@
### dev-v2 (not yet released)
* `Player`:
* add `getMediaItemCount()` and `getMediaItemAt(int)`.
* Track selection:
* Add option to specify multiple preferred audio or text languages.
* Data sources:

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.