diff --git a/demos/cast/src/main/java/androidx/media3/demo/cast/PlayerManager.java b/demos/cast/src/main/java/androidx/media3/demo/cast/PlayerManager.java index 6258963db4..12dc271c40 100644 --- a/demos/cast/src/main/java/androidx/media3/demo/cast/PlayerManager.java +++ b/demos/cast/src/main/java/androidx/media3/demo/cast/PlayerManager.java @@ -261,7 +261,7 @@ import java.util.ArrayList; int playbackState = currentPlayer.getPlaybackState(); maybeSetCurrentItemAndNotify( playbackState != Player.STATE_IDLE && playbackState != Player.STATE_ENDED - ? currentPlayer.getCurrentWindowIndex() + ? currentPlayer.getCurrentMediaItemIndex() : C.INDEX_UNSET); } @@ -281,7 +281,7 @@ import java.util.ArrayList; // Player state management. long playbackPositionMs = C.TIME_UNSET; - int windowIndex = C.INDEX_UNSET; + int currentItemIndex = C.INDEX_UNSET; boolean playWhenReady = false; Player previousPlayer = this.currentPlayer; @@ -291,10 +291,10 @@ import java.util.ArrayList; if (playbackState != Player.STATE_ENDED) { playbackPositionMs = previousPlayer.getCurrentPosition(); playWhenReady = previousPlayer.getPlayWhenReady(); - windowIndex = previousPlayer.getCurrentWindowIndex(); - if (windowIndex != currentItemIndex) { + currentItemIndex = previousPlayer.getCurrentMediaItemIndex(); + if (currentItemIndex != this.currentItemIndex) { playbackPositionMs = C.TIME_UNSET; - windowIndex = currentItemIndex; + currentItemIndex = this.currentItemIndex; } } previousPlayer.stop(); @@ -304,7 +304,7 @@ import java.util.ArrayList; this.currentPlayer = currentPlayer; // Media queue management. - currentPlayer.setMediaItems(mediaQueue, windowIndex, playbackPositionMs); + currentPlayer.setMediaItems(mediaQueue, currentItemIndex, playbackPositionMs); currentPlayer.setPlayWhenReady(playWhenReady); currentPlayer.prepare(); } diff --git a/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java b/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java index 3e99c3b252..ca86d5ea06 100644 --- a/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java +++ b/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java @@ -65,7 +65,7 @@ public class PlayerActivity extends AppCompatActivity // Saved instance state keys. private static final String KEY_TRACK_SELECTION_PARAMETERS = "track_selection_parameters"; - private static final String KEY_WINDOW = "window"; + private static final String KEY_ITEM_INDEX = "item_index"; private static final String KEY_POSITION = "position"; private static final String KEY_AUTO_PLAY = "auto_play"; @@ -83,7 +83,7 @@ public class PlayerActivity extends AppCompatActivity private DebugTextViewHelper debugViewHelper; private TracksInfo lastSeenTracksInfo; private boolean startAutoPlay; - private int startWindow; + private int startItemIndex; private long startPosition; // For ad playback only. @@ -114,7 +114,7 @@ public class PlayerActivity extends AppCompatActivity DefaultTrackSelector.Parameters.CREATOR.fromBundle( savedInstanceState.getBundle(KEY_TRACK_SELECTION_PARAMETERS)); startAutoPlay = savedInstanceState.getBoolean(KEY_AUTO_PLAY); - startWindow = savedInstanceState.getInt(KEY_WINDOW); + startItemIndex = savedInstanceState.getInt(KEY_ITEM_INDEX); startPosition = savedInstanceState.getLong(KEY_POSITION); } else { trackSelectionParameters = @@ -206,7 +206,7 @@ public class PlayerActivity extends AppCompatActivity updateStartPosition(); outState.putBundle(KEY_TRACK_SELECTION_PARAMETERS, trackSelectionParameters.toBundle()); outState.putBoolean(KEY_AUTO_PLAY, startAutoPlay); - outState.putInt(KEY_WINDOW, startWindow); + outState.putInt(KEY_ITEM_INDEX, startItemIndex); outState.putLong(KEY_POSITION, startPosition); } @@ -282,9 +282,9 @@ public class PlayerActivity extends AppCompatActivity debugViewHelper = new DebugTextViewHelper(player, debugTextView); debugViewHelper.start(); } - boolean haveStartPosition = startWindow != C.INDEX_UNSET; + boolean haveStartPosition = startItemIndex != C.INDEX_UNSET; if (haveStartPosition) { - player.seekTo(startWindow, startPosition); + player.seekTo(startItemIndex, startPosition); } player.setMediaItems(mediaItems, /* resetPosition= */ !haveStartPosition); player.prepare(); @@ -382,14 +382,14 @@ public class PlayerActivity extends AppCompatActivity private void updateStartPosition() { if (player != null) { startAutoPlay = player.getPlayWhenReady(); - startWindow = player.getCurrentWindowIndex(); + startItemIndex = player.getCurrentMediaItemIndex(); startPosition = Math.max(0, player.getContentPosition()); } } protected void clearStartPosition() { startAutoPlay = true; - startWindow = C.INDEX_UNSET; + startItemIndex = C.INDEX_UNSET; startPosition = C.TIME_UNSET; } diff --git a/demos/session/src/main/java/androidx/media3/demo/session/PlayerActivity.kt b/demos/session/src/main/java/androidx/media3/demo/session/PlayerActivity.kt index 0798a52795..94d24de72f 100644 --- a/demos/session/src/main/java/androidx/media3/demo/session/PlayerActivity.kt +++ b/demos/session/src/main/java/androidx/media3/demo/session/PlayerActivity.kt @@ -204,7 +204,7 @@ class PlayerActivity : AppCompatActivity() { returnConvertView.findViewById(R.id.media_item).text = mediaItem.mediaMetadata.title - if (position == controller?.currentWindowIndex) { + if (position == controller?.currentMediaItemIndex) { returnConvertView.setBackgroundColor(ContextCompat.getColor(context, R.color.white)) returnConvertView .findViewById(R.id.media_item) diff --git a/libraries/cast/src/main/java/androidx/media3/cast/CastPlayer.java b/libraries/cast/src/main/java/androidx/media3/cast/CastPlayer.java index 15bad01f45..ead783827e 100644 --- a/libraries/cast/src/main/java/androidx/media3/cast/CastPlayer.java +++ b/libraries/cast/src/main/java/androidx/media3/cast/CastPlayer.java @@ -320,9 +320,9 @@ public final class CastPlayer extends BasePlayer { @Override public void setMediaItems(List mediaItems, boolean resetPosition) { - int windowIndex = resetPosition ? 0 : getCurrentWindowIndex(); + int mediaItemIndex = resetPosition ? 0 : getCurrentMediaItemIndex(); long startPositionMs = resetPosition ? C.TIME_UNSET : getContentPosition(); - setMediaItems(mediaItems, windowIndex, startPositionMs); + setMediaItems(mediaItems, mediaItemIndex, startPositionMs); } @Override @@ -445,7 +445,7 @@ public final class CastPlayer extends BasePlayer { // in RemoteMediaClient. positionMs = positionMs != C.TIME_UNSET ? positionMs : 0; if (mediaStatus != null) { - if (getCurrentWindowIndex() != mediaItemIndex) { + if (getCurrentMediaItemIndex() != mediaItemIndex) { remoteMediaClient .queueJumpToItem( (int) currentTimeline.getPeriod(mediaItemIndex, period).uid, positionMs, null) @@ -638,7 +638,7 @@ public final class CastPlayer extends BasePlayer { @Override public int getCurrentPeriodIndex() { - return getCurrentWindowIndex(); + return getCurrentMediaItemIndex(); } @Override @@ -1105,15 +1105,15 @@ public final class CastPlayer extends BasePlayer { @Nullable private PendingResult setMediaItemsInternal( MediaQueueItem[] mediaQueueItems, - int startWindowIndex, + int startIndex, long startPositionMs, @RepeatMode int repeatMode) { if (remoteMediaClient == null || mediaQueueItems.length == 0) { return null; } startPositionMs = startPositionMs == C.TIME_UNSET ? 0 : startPositionMs; - if (startWindowIndex == C.INDEX_UNSET) { - startWindowIndex = getCurrentWindowIndex(); + if (startIndex == C.INDEX_UNSET) { + startIndex = getCurrentMediaItemIndex(); startPositionMs = getCurrentPosition(); } Timeline currentTimeline = getCurrentTimeline(); @@ -1122,7 +1122,7 @@ public final class CastPlayer extends BasePlayer { } return remoteMediaClient.queueLoad( mediaQueueItems, - min(startWindowIndex, mediaQueueItems.length - 1), + min(startIndex, mediaQueueItems.length - 1), getCastRepeatMode(repeatMode), startPositionMs, /* customData= */ null); @@ -1182,7 +1182,7 @@ public final class CastPlayer extends BasePlayer { } return new PositionInfo( newWindowUid, - getCurrentWindowIndex(), + getCurrentMediaItemIndex(), newMediaItem, newPeriodUid, getCurrentPeriodIndex(), diff --git a/libraries/common/src/main/java/androidx/media3/common/BasePlayer.java b/libraries/common/src/main/java/androidx/media3/common/BasePlayer.java index 4f4a241363..44926b25fc 100644 --- a/libraries/common/src/main/java/androidx/media3/common/BasePlayer.java +++ b/libraries/common/src/main/java/androidx/media3/common/BasePlayer.java @@ -120,7 +120,7 @@ public abstract class BasePlayer implements Player { @Override public final void seekToDefaultPosition() { - seekToDefaultPosition(getCurrentWindowIndex()); + seekToDefaultPosition(getCurrentMediaItemIndex()); } @Override @@ -130,7 +130,7 @@ public abstract class BasePlayer implements Player { @Override public final void seekTo(long positionMs) { - seekTo(getCurrentWindowIndex(), positionMs); + seekTo(getCurrentMediaItemIndex(), positionMs); } @Override @@ -186,13 +186,13 @@ public abstract class BasePlayer implements Player { if (timeline.isEmpty() || isPlayingAd()) { return; } - boolean hasPreviousWindow = hasPreviousWindow(); - if (isCurrentWindowLive() && !isCurrentWindowSeekable()) { - if (hasPreviousWindow) { - seekToPreviousWindow(); + boolean hasPreviousMediaItem = hasPreviousMediaItem(); + if (isCurrentMediaItemLive() && !isCurrentMediaItemSeekable()) { + if (hasPreviousMediaItem) { + seekToPreviousMediaItem(); } - } else if (hasPreviousWindow && getCurrentPosition() <= getMaxSeekToPreviousPosition()) { - seekToPreviousWindow(); + } else if (hasPreviousMediaItem && getCurrentPosition() <= getMaxSeekToPreviousPosition()) { + seekToPreviousMediaItem(); } else { seekTo(/* positionMs= */ 0); } @@ -241,9 +241,9 @@ public abstract class BasePlayer implements Player { if (timeline.isEmpty() || isPlayingAd()) { return; } - if (hasNextWindow()) { - seekToNextWindow(); - } else if (isCurrentWindowLive() && isCurrentWindowDynamic()) { + if (hasNextMediaItem()) { + seekToNextMediaItem(); + } else if (isCurrentMediaItemLive() && isCurrentMediaItemDynamic()) { seekToDefaultPosition(); } } @@ -295,7 +295,7 @@ public abstract class BasePlayer implements Player { Timeline timeline = getCurrentTimeline(); return timeline.isEmpty() ? null - : timeline.getWindow(getCurrentWindowIndex(), window).mediaItem; + : timeline.getWindow(getCurrentMediaItemIndex(), window).mediaItem; } @Override @@ -312,7 +312,9 @@ public abstract class BasePlayer implements Player { @Nullable public final Object getCurrentManifest() { Timeline timeline = getCurrentTimeline(); - return timeline.isEmpty() ? null : timeline.getWindow(getCurrentWindowIndex(), window).manifest; + return timeline.isEmpty() + ? null + : timeline.getWindow(getCurrentMediaItemIndex(), window).manifest; } @Override @@ -354,7 +356,8 @@ public abstract class BasePlayer implements Player { if (timeline.isEmpty()) { return C.TIME_UNSET; } - long windowStartTimeMs = timeline.getWindow(getCurrentWindowIndex(), window).windowStartTimeMs; + long windowStartTimeMs = + timeline.getWindow(getCurrentMediaItemIndex(), window).windowStartTimeMs; if (windowStartTimeMs == C.TIME_UNSET) { return C.TIME_UNSET; } @@ -378,7 +381,7 @@ public abstract class BasePlayer implements Player { Timeline timeline = getCurrentTimeline(); return timeline.isEmpty() ? C.TIME_UNSET - : timeline.getWindow(getCurrentWindowIndex(), window).getDurationMs(); + : timeline.getWindow(getCurrentMediaItemIndex(), window).getDurationMs(); } /** @@ -391,22 +394,24 @@ public abstract class BasePlayer implements Player { return new Commands.Builder() .addAll(permanentAvailableCommands) .addIf(COMMAND_SEEK_TO_DEFAULT_POSITION, !isPlayingAd()) - .addIf(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM, isCurrentWindowSeekable() && !isPlayingAd()) - .addIf(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, hasPreviousWindow() && !isPlayingAd()) + .addIf(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM, isCurrentMediaItemSeekable() && !isPlayingAd()) + .addIf(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, hasPreviousMediaItem() && !isPlayingAd()) .addIf( COMMAND_SEEK_TO_PREVIOUS, !getCurrentTimeline().isEmpty() - && (hasPreviousWindow() || !isCurrentWindowLive() || isCurrentWindowSeekable()) + && (hasPreviousMediaItem() + || !isCurrentMediaItemLive() + || isCurrentMediaItemSeekable()) && !isPlayingAd()) - .addIf(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, hasNextWindow() && !isPlayingAd()) + .addIf(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, hasNextMediaItem() && !isPlayingAd()) .addIf( COMMAND_SEEK_TO_NEXT, !getCurrentTimeline().isEmpty() - && (hasNextWindow() || (isCurrentWindowLive() && isCurrentWindowDynamic())) + && (hasNextMediaItem() || (isCurrentMediaItemLive() && isCurrentMediaItemDynamic())) && !isPlayingAd()) .addIf(COMMAND_SEEK_TO_MEDIA_ITEM, !isPlayingAd()) - .addIf(COMMAND_SEEK_BACK, isCurrentWindowSeekable() && !isPlayingAd()) - .addIf(COMMAND_SEEK_FORWARD, isCurrentWindowSeekable() && !isPlayingAd()) + .addIf(COMMAND_SEEK_BACK, isCurrentMediaItemSeekable() && !isPlayingAd()) + .addIf(COMMAND_SEEK_FORWARD, isCurrentMediaItemSeekable() && !isPlayingAd()) .build(); } diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java index f2111e64f9..a596cb07b6 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java @@ -1182,7 +1182,7 @@ public interface ExoPlayer extends Player { * @param mediaSources The new {@link MediaSource MediaSources}. * @param resetPosition Whether the playback position should be reset to the default position in * the first {@link Timeline.Window}. If false, playback will start from the position defined - * by {@link #getCurrentWindowIndex()} and {@link #getCurrentPosition()}. + * by {@link #getCurrentMediaItemIndex()} and {@link #getCurrentPosition()}. */ @UnstableApi void setMediaSources(List mediaSources, boolean resetPosition); @@ -1191,15 +1191,16 @@ public interface ExoPlayer extends Player { * Clears the playlist and adds the specified {@link MediaSource MediaSources}. * * @param mediaSources The new {@link MediaSource MediaSources}. - * @param startWindowIndex The window index to start playback from. If {@link C#INDEX_UNSET} is - * passed, the current position is not reset. + * @param startMediaItemIndex The media item index to start playback from. If {@link + * C#INDEX_UNSET} is passed, the current position is not reset. * @param startPositionMs The position in milliseconds to start playback from. If {@link - * C#TIME_UNSET} is passed, the default position of the given window is used. In any case, if - * {@code startWindowIndex} is set to {@link C#INDEX_UNSET}, this parameter is ignored and the - * position is not reset at all. + * C#TIME_UNSET} is passed, the default position of the given media item is used. In any case, + * if {@code startMediaItemIndex} is set to {@link C#INDEX_UNSET}, this parameter is ignored + * and the position is not reset at all. */ @UnstableApi - void setMediaSources(List mediaSources, int startWindowIndex, long startPositionMs); + void setMediaSources( + List mediaSources, int startMediaItemIndex, long startPositionMs); /** * Clears the playlist, adds the specified {@link MediaSource} and resets the position to the @@ -1224,7 +1225,7 @@ public interface ExoPlayer extends Player { * * @param mediaSource The new {@link MediaSource}. * @param resetPosition Whether the playback position should be reset to the default position. If - * false, playback will start from the position defined by {@link #getCurrentWindowIndex()} + * false, playback will start from the position defined by {@link #getCurrentMediaItemIndex()} * and {@link #getCurrentPosition()}. */ @UnstableApi @@ -1411,9 +1412,9 @@ public interface ExoPlayer extends Player { * will be delivered immediately without blocking on the playback thread. The default {@link * PlayerMessage#getType()} is 0 and the default {@link PlayerMessage#getPayload()} is null. If a * position is specified with {@link PlayerMessage#setPosition(long)}, the message will be - * delivered at this position in the current window defined by {@link #getCurrentWindowIndex()}. - * Alternatively, the message can be sent at a specific window using {@link - * PlayerMessage#setPosition(int, long)}. + * delivered at this position in the current media item defined by {@link + * #getCurrentMediaItemIndex()}. Alternatively, the message can be sent at a specific mediaItem + * using {@link PlayerMessage#setPosition(int, long)}. */ @UnstableApi PlayerMessage createMessage(PlayerMessage.Target target); diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java index c1c4c10f63..84599fc4dc 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java @@ -550,7 +550,7 @@ import java.util.concurrent.CopyOnWriteArraySet; playbackInfo, timeline, getPeriodPositionOrMaskWindowPosition( - timeline, getCurrentWindowIndex(), getCurrentPosition())); + timeline, getCurrentMediaItemIndex(), getCurrentPosition())); pendingOperationAcks++; this.shuffleOrder = shuffleOrder; internalPlayer.setShuffleOrder(shuffleOrder); @@ -675,7 +675,7 @@ import java.util.concurrent.CopyOnWriteArraySet; @Player.State int newPlaybackState = getPlaybackState() == Player.STATE_IDLE ? Player.STATE_IDLE : Player.STATE_BUFFERING; - int oldMaskingWindowIndex = getCurrentWindowIndex(); + int oldMaskingMediaItemIndex = getCurrentMediaItemIndex(); PlaybackInfo newPlaybackInfo = playbackInfo.copyWithPlaybackState(newPlaybackState); newPlaybackInfo = maskTimelineAndPosition( @@ -691,7 +691,7 @@ import java.util.concurrent.CopyOnWriteArraySet; /* positionDiscontinuity= */ true, /* positionDiscontinuityReason= */ DISCONTINUITY_REASON_SEEK, /* discontinuityWindowStartPositionUs= */ getCurrentPositionUsInternal(newPlaybackInfo), - oldMaskingWindowIndex); + oldMaskingMediaItemIndex); } @Override @@ -852,7 +852,7 @@ import java.util.concurrent.CopyOnWriteArraySet; internalPlayer, target, playbackInfo.timeline, - getCurrentWindowIndex(), + getCurrentMediaItemIndex(), clock, internalPlayer.getPlaybackLooper()); } @@ -923,7 +923,10 @@ import java.util.concurrent.CopyOnWriteArraySet; if (isPlayingAd()) { playbackInfo.timeline.getPeriodByUid(playbackInfo.periodId.periodUid, period); return playbackInfo.requestedContentPositionUs == C.TIME_UNSET - ? playbackInfo.timeline.getWindow(getCurrentWindowIndex(), window).getDefaultPositionMs() + ? playbackInfo + .timeline + .getWindow(getCurrentMediaItemIndex(), window) + .getDefaultPositionMs() : period.getPositionInWindowMs() + Util.usToMs(playbackInfo.requestedContentPositionUs); } else { return getCurrentPosition(); @@ -937,7 +940,7 @@ import java.util.concurrent.CopyOnWriteArraySet; } if (playbackInfo.loadingMediaPeriodId.windowSequenceNumber != playbackInfo.periodId.windowSequenceNumber) { - return playbackInfo.timeline.getWindow(getCurrentWindowIndex(), window).getDurationMs(); + return playbackInfo.timeline.getWindow(getCurrentMediaItemIndex(), window).getDurationMs(); } long contentBufferedPositionUs = playbackInfo.bufferedPositionUs; if (playbackInfo.loadingMediaPeriodId.isAd()) { @@ -1231,7 +1234,7 @@ import java.util.concurrent.CopyOnWriteArraySet; boolean positionDiscontinuity, @DiscontinuityReason int positionDiscontinuityReason, long discontinuityWindowStartPositionUs, - int oldMaskingWindowIndex) { + int oldMaskingMediaItemIndex) { // Assign playback info immediately such that all getters return the right values, but keep // snapshot of previous and new state so that listener invocations are triggered correctly. @@ -1280,7 +1283,7 @@ import java.util.concurrent.CopyOnWriteArraySet; if (positionDiscontinuity) { PositionInfo previousPositionInfo = getPreviousPositionInfo( - positionDiscontinuityReason, previousPlaybackInfo, oldMaskingWindowIndex); + positionDiscontinuityReason, previousPlaybackInfo, oldMaskingMediaItemIndex); PositionInfo positionInfo = getPositionInfo(discontinuityWindowStartPositionUs); listeners.queueEvent( Player.EVENT_POSITION_DISCONTINUITY, @@ -1391,19 +1394,19 @@ import java.util.concurrent.CopyOnWriteArraySet; private PositionInfo getPreviousPositionInfo( @DiscontinuityReason int positionDiscontinuityReason, PlaybackInfo oldPlaybackInfo, - int oldMaskingWindowIndex) { + int oldMaskingMediaItemIndex) { @Nullable Object oldWindowUid = null; @Nullable Object oldPeriodUid = null; - int oldWindowIndex = oldMaskingWindowIndex; + int oldMediaItemIndex = oldMaskingMediaItemIndex; int oldPeriodIndex = C.INDEX_UNSET; @Nullable MediaItem oldMediaItem = null; Timeline.Period oldPeriod = new Timeline.Period(); if (!oldPlaybackInfo.timeline.isEmpty()) { oldPeriodUid = oldPlaybackInfo.periodId.periodUid; oldPlaybackInfo.timeline.getPeriodByUid(oldPeriodUid, oldPeriod); - oldWindowIndex = oldPeriod.windowIndex; + oldMediaItemIndex = oldPeriod.windowIndex; oldPeriodIndex = oldPlaybackInfo.timeline.getIndexOfPeriod(oldPeriodUid); - oldWindowUid = oldPlaybackInfo.timeline.getWindow(oldWindowIndex, window).uid; + oldWindowUid = oldPlaybackInfo.timeline.getWindow(oldMediaItemIndex, window).uid; oldMediaItem = window.mediaItem; } long oldPositionUs; @@ -1434,7 +1437,7 @@ import java.util.concurrent.CopyOnWriteArraySet; } return new PositionInfo( oldWindowUid, - oldWindowIndex, + oldMediaItemIndex, oldMediaItem, oldPeriodUid, oldPeriodIndex, @@ -1447,20 +1450,20 @@ import java.util.concurrent.CopyOnWriteArraySet; private PositionInfo getPositionInfo(long discontinuityWindowStartPositionUs) { @Nullable Object newWindowUid = null; @Nullable Object newPeriodUid = null; - int newWindowIndex = getCurrentWindowIndex(); + int newMediaItemIndex = getCurrentMediaItemIndex(); int newPeriodIndex = C.INDEX_UNSET; @Nullable MediaItem newMediaItem = null; if (!playbackInfo.timeline.isEmpty()) { newPeriodUid = playbackInfo.periodId.periodUid; playbackInfo.timeline.getPeriodByUid(newPeriodUid, period); newPeriodIndex = playbackInfo.timeline.getIndexOfPeriod(newPeriodUid); - newWindowUid = playbackInfo.timeline.getWindow(newWindowIndex, window).uid; + newWindowUid = playbackInfo.timeline.getWindow(newMediaItemIndex, window).uid; newMediaItem = window.mediaItem; } long positionMs = Util.usToMs(discontinuityWindowStartPositionUs); return new PositionInfo( newWindowUid, - newWindowIndex, + newMediaItemIndex, newMediaItem, newPeriodUid, newPeriodIndex, @@ -1614,7 +1617,7 @@ import java.util.concurrent.CopyOnWriteArraySet; private PlaybackInfo removeMediaItemsInternal(int fromIndex, int toIndex) { Assertions.checkArgument( fromIndex >= 0 && toIndex >= fromIndex && toIndex <= mediaSourceHolderSnapshots.size()); - int currentWindowIndex = getCurrentWindowIndex(); + int currentIndex = getCurrentMediaItemIndex(); Timeline oldTimeline = getCurrentTimeline(); int currentMediaSourceCount = mediaSourceHolderSnapshots.size(); pendingOperationAcks++; @@ -1631,7 +1634,7 @@ import java.util.concurrent.CopyOnWriteArraySet; && newPlaybackInfo.playbackState != STATE_ENDED && fromIndex < toIndex && toIndex == currentMediaSourceCount - && currentWindowIndex >= newPlaybackInfo.timeline.getWindowCount(); + && currentIndex >= newPlaybackInfo.timeline.getWindowCount(); if (transitionsToEnded) { newPlaybackInfo = newPlaybackInfo.copyWithPlaybackState(STATE_ENDED); } @@ -1766,11 +1769,11 @@ import java.util.concurrent.CopyOnWriteArraySet; isCleared ? C.INDEX_UNSET : getCurrentWindowIndexInternal(), isCleared ? C.TIME_UNSET : currentPositionMs); } - int currentWindowIndex = getCurrentWindowIndex(); + int currentMediaItemIndex = getCurrentMediaItemIndex(); @Nullable Pair oldPeriodPosition = oldTimeline.getPeriodPosition( - window, period, currentWindowIndex, Util.msToUs(currentPositionMs)); + window, period, currentMediaItemIndex, Util.msToUs(currentPositionMs)); Object periodUid = castNonNull(oldPeriodPosition).first; if (newTimeline.getIndexOfPeriod(periodUid) != C.INDEX_UNSET) { // The old period position is still available in the new timeline. diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImplInternal.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImplInternal.java index c347d10a07..82d6367ee3 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImplInternal.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImplInternal.java @@ -2726,7 +2726,7 @@ import java.util.concurrent.atomic.AtomicBoolean; newTimeline, new SeekPosition( pendingMessageInfo.message.getTimeline(), - pendingMessageInfo.message.getWindowIndex(), + pendingMessageInfo.message.getMediaItemIndex(), requestPositionUs), /* trySubsequentPeriods= */ false, repeatMode, diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/PlayerMessage.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/PlayerMessage.java index f6e5846843..5b4acaf980 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/PlayerMessage.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/PlayerMessage.java @@ -70,7 +70,7 @@ public final class PlayerMessage { private int type; @Nullable private Object payload; private Looper looper; - private int windowIndex; + private int mediaItemIndex; private long positionMs; private boolean deleteAfterDelivery; private boolean isSent; @@ -85,8 +85,8 @@ public final class PlayerMessage { * @param target The {@link Target} the message is sent to. * @param timeline The timeline used when setting the position with {@link #setPosition(long)}. If * set to {@link Timeline#EMPTY}, any position can be specified. - * @param defaultWindowIndex The default window index in the {@code timeline} when no other window - * index is specified. + * @param defaultMediaItemIndex The default media item index in the {@code timeline} when no other + * media item index is specified. * @param clock The {@link Clock}. * @param defaultLooper The default {@link Looper} to send the message on when no other looper is * specified. @@ -95,7 +95,7 @@ public final class PlayerMessage { Sender sender, Target target, Timeline timeline, - int defaultWindowIndex, + int defaultMediaItemIndex, Clock clock, Looper defaultLooper) { this.sender = sender; @@ -103,7 +103,7 @@ public final class PlayerMessage { this.timeline = timeline; this.looper = defaultLooper; this.clock = clock; - this.windowIndex = defaultWindowIndex; + this.mediaItemIndex = defaultMediaItemIndex; this.positionMs = C.TIME_UNSET; this.deleteAfterDelivery = true; } @@ -180,21 +180,21 @@ public final class PlayerMessage { } /** - * Returns position in window at {@link #getWindowIndex()} at which the message will be delivered, - * in milliseconds. If {@link C#TIME_UNSET}, the message will be delivered immediately. If {@link - * C#TIME_END_OF_SOURCE}, the message will be delivered at the end of the window at {@link - * #getWindowIndex()}. + * Returns position in the media item at {@link #getMediaItemIndex()} at which the message will be + * delivered, in milliseconds. If {@link C#TIME_UNSET}, the message will be delivered immediately. + * If {@link C#TIME_END_OF_SOURCE}, the message will be delivered at the end of the media item at + * {@link #getMediaItemIndex()}. */ public long getPositionMs() { return positionMs; } /** - * Sets a position in the current window at which the message will be delivered. + * Sets a position in the current media item at which the message will be delivered. * - * @param positionMs The position in the current window at which the message will be sent, in + * @param positionMs The position in the current media item at which the message will be sent, in * milliseconds, or {@link C#TIME_END_OF_SOURCE} to deliver the message at the end of the - * current window. + * current media item. * @return This message. * @throws IllegalStateException If {@link #send()} has already been called. */ @@ -205,31 +205,32 @@ public final class PlayerMessage { } /** - * Sets a position in a window at which the message will be delivered. + * Sets a position in a media item at which the message will be delivered. * - * @param windowIndex The index of the window at which the message will be sent. - * @param positionMs The position in the window with index {@code windowIndex} at which the + * @param mediaItemIndex The index of the media item at which the message will be sent. + * @param positionMs The position in the media item with index {@code mediaItemIndex} at which the * message will be sent, in milliseconds, or {@link C#TIME_END_OF_SOURCE} to deliver the - * message at the end of the window with index {@code windowIndex}. + * message at the end of the media item with index {@code mediaItemIndex}. * @return This message. * @throws IllegalSeekPositionException If the timeline returned by {@link #getTimeline()} is not - * empty and the provided window index is not within the bounds of the timeline. + * empty and the provided media item index is not within the bounds of the timeline. * @throws IllegalStateException If {@link #send()} has already been called. */ - public PlayerMessage setPosition(int windowIndex, long positionMs) { + public PlayerMessage setPosition(int mediaItemIndex, long positionMs) { Assertions.checkState(!isSent); Assertions.checkArgument(positionMs != C.TIME_UNSET); - if (windowIndex < 0 || (!timeline.isEmpty() && windowIndex >= timeline.getWindowCount())) { - throw new IllegalSeekPositionException(timeline, windowIndex, positionMs); + if (mediaItemIndex < 0 + || (!timeline.isEmpty() && mediaItemIndex >= timeline.getWindowCount())) { + throw new IllegalSeekPositionException(timeline, mediaItemIndex, positionMs); } - this.windowIndex = windowIndex; + this.mediaItemIndex = mediaItemIndex; this.positionMs = positionMs; return this; } - /** Returns window index at which the message will be delivered. */ - public int getWindowIndex() { - return windowIndex; + /** Returns media item index at which the message will be delivered. */ + public int getMediaItemIndex() { + return mediaItemIndex; } /** diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/SimpleExoPlayer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/SimpleExoPlayer.java index 03369c4c19..a4f383d507 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/SimpleExoPlayer.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/SimpleExoPlayer.java @@ -1121,9 +1121,9 @@ public class SimpleExoPlayer extends BasePlayer @Override public void setMediaSources( - List mediaSources, int startWindowIndex, long startPositionMs) { + List mediaSources, int startMediaItemIndex, long startPositionMs) { verifyApplicationThread(); - player.setMediaSources(mediaSources, startWindowIndex, startPositionMs); + player.setMediaSources(mediaSources, startMediaItemIndex, startPositionMs); } @Override @@ -1430,7 +1430,7 @@ public class SimpleExoPlayer extends BasePlayer @Override public int getCurrentMediaItemIndex() { verifyApplicationThread(); - return player.getCurrentWindowIndex(); + return player.getCurrentMediaItemIndex(); } @Override diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/analytics/AnalyticsCollector.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/analytics/AnalyticsCollector.java index 6e508b36dd..9a8c13f4ee 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/analytics/AnalyticsCollector.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/analytics/AnalyticsCollector.java @@ -916,7 +916,7 @@ public class AnalyticsCollector long eventPositionMs; boolean isInCurrentWindow = timeline.equals(player.getCurrentTimeline()) - && windowIndex == player.getCurrentWindowIndex(); + && windowIndex == player.getCurrentMediaItemIndex(); if (mediaPeriodId != null && mediaPeriodId.isAd()) { boolean isCurrentAd = isInCurrentWindow @@ -941,7 +941,7 @@ public class AnalyticsCollector mediaPeriodId, eventPositionMs, player.getCurrentTimeline(), - player.getCurrentWindowIndex(), + player.getCurrentMediaItemIndex(), currentMediaPeriodId, player.getCurrentPosition(), player.getTotalBufferedDuration()); @@ -964,7 +964,7 @@ public class AnalyticsCollector ? null : mediaPeriodQueueTracker.getMediaPeriodIdTimeline(mediaPeriodId); if (mediaPeriodId == null || knownTimeline == null) { - int windowIndex = player.getCurrentWindowIndex(); + int windowIndex = player.getCurrentMediaItemIndex(); Timeline timeline = player.getCurrentTimeline(); boolean windowIsInTimeline = windowIndex < timeline.getWindowCount(); return generateEventTime( diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/analytics/AnalyticsListener.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/analytics/AnalyticsListener.java index d4dbd59282..948f3e954a 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/analytics/AnalyticsListener.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/analytics/AnalyticsListener.java @@ -384,7 +384,7 @@ public interface AnalyticsListener { /** * The current window index in {@link #currentTimeline} at the time of the event, or the * prospective window index if the timeline is not yet known and empty (equivalent to {@link - * Player#getCurrentWindowIndex()}). + * Player#getCurrentMediaItemIndex()}). */ public final int currentWindowIndex; @@ -421,7 +421,7 @@ public interface AnalyticsListener { * {@link Player#getCurrentTimeline()}). * @param currentWindowIndex The current window index in {@code currentTimeline} at the time of * the event, or the prospective window index if the timeline is not yet known and empty - * (equivalent to {@link Player#getCurrentWindowIndex()}). + * (equivalent to {@link Player#getCurrentMediaItemIndex()}). * @param currentMediaPeriodId {@link MediaPeriodId Media period identifier} for the currently * playing media period at the time of the event, or {@code null} if no current media period * identifier is available. @@ -1206,9 +1206,9 @@ public interface AnalyticsListener { * {@link Player#seekTo(long)} after a {@link * AnalyticsListener#onMediaItemTransition(EventTime, MediaItem, int)}). *
  • They intend to use multiple state values together or in combination with {@link Player} - * getter methods. For example using {@link Player#getCurrentWindowIndex()} with the {@code - * timeline} provided in {@link #onTimelineChanged(EventTime, int)} is only safe from within - * this method. + * getter methods. For example using {@link Player#getCurrentMediaItemIndex()} with the + * {@code timeline} provided in {@link #onTimelineChanged(EventTime, int)} is only safe from + * within this method. *
  • They are interested in events that logically happened together (e.g {@link * #onPlaybackStateChanged(EventTime, int)} to {@link Player#STATE_BUFFERING} because of * {@link #onMediaItemTransition(EventTime, MediaItem, int)}). diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/util/DebugTextViewHelper.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/util/DebugTextViewHelper.java index 8be9f5f78c..7b23318fec 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/util/DebugTextViewHelper.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/util/DebugTextViewHelper.java @@ -141,8 +141,8 @@ public class DebugTextViewHelper implements Player.Listener, Runnable { break; } return String.format( - "playWhenReady:%s playbackState:%s window:%s", - player.getPlayWhenReady(), playbackStateString, player.getCurrentWindowIndex()); + "playWhenReady:%s playbackState:%s item:%s", + player.getPlayWhenReady(), playbackStateString, player.getCurrentMediaItemIndex()); } /** Returns a string containing video debugging information. */ diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java index 6fb8979ad0..8b10724667 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java @@ -51,7 +51,7 @@ import static androidx.media3.test.utils.FakeSampleStream.FakeSampleStreamItem.o import static androidx.media3.test.utils.TestUtil.assertTimelinesSame; import static androidx.media3.test.utils.robolectric.RobolectricUtil.runMainLooperUntil; import static androidx.media3.test.utils.robolectric.TestPlayerRunHelper.playUntilPosition; -import static androidx.media3.test.utils.robolectric.TestPlayerRunHelper.playUntilStartOfWindow; +import static androidx.media3.test.utils.robolectric.TestPlayerRunHelper.playUntilStartOfMediaItem; import static androidx.media3.test.utils.robolectric.TestPlayerRunHelper.runUntilPendingCommandsAreFullyHandled; import static androidx.media3.test.utils.robolectric.TestPlayerRunHelper.runUntilPlaybackState; import static androidx.media3.test.utils.robolectric.TestPlayerRunHelper.runUntilPositionDiscontinuity; @@ -391,7 +391,7 @@ public final class ExoPlayerTest { player.play(); runUntilPositionDiscontinuity(player, Player.DISCONTINUITY_REASON_AUTO_TRANSITION); player.setForegroundMode(/* foregroundMode= */ true); - // Only the video renderer that is disabled in the second window has been reset. + // Only the video renderer that is disabled in the second media item has been reset. assertThat(audioRenderer.resetCount).isEqualTo(0); assertThat(videoRenderer.resetCount).isEqualTo(1); @@ -470,7 +470,7 @@ public final class ExoPlayerTest { // Disable text renderer by selecting a language that is not available. player.setTrackSelectionParameters( player.getTrackSelectionParameters().buildUpon().setPreferredTextLanguage("de").build()); - player.seekTo(/* windowIndex= */ 0, /* positionMs= */ 1000); + player.seekTo(/* mediaItemIndex= */ 0, /* positionMs= */ 1000); runUntilPlaybackState(player, Player.STATE_READY); // Expect formerly enabled renderers to be reset after seek. assertThat(textRenderer.resetCount).isEqualTo(1); @@ -657,21 +657,21 @@ public final class ExoPlayerTest { player.setMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT)); player.prepare(); runUntilTimelineChanged(player); - playUntilStartOfWindow(player, /* windowIndex= */ 1); + playUntilStartOfMediaItem(player, /* mediaItemIndex= */ 1); player.setRepeatMode(Player.REPEAT_MODE_ONE); - playUntilStartOfWindow(player, /* windowIndex= */ 1); + playUntilStartOfMediaItem(player, /* mediaItemIndex= */ 1); player.setRepeatMode(Player.REPEAT_MODE_OFF); - playUntilStartOfWindow(player, /* windowIndex= */ 2); + playUntilStartOfMediaItem(player, /* mediaItemIndex= */ 2); player.setRepeatMode(Player.REPEAT_MODE_ONE); - playUntilStartOfWindow(player, /* windowIndex= */ 2); + playUntilStartOfMediaItem(player, /* mediaItemIndex= */ 2); player.setRepeatMode(Player.REPEAT_MODE_ALL); - playUntilStartOfWindow(player, /* windowIndex= */ 0); + playUntilStartOfMediaItem(player, /* mediaItemIndex= */ 0); player.setRepeatMode(Player.REPEAT_MODE_ONE); - playUntilStartOfWindow(player, /* windowIndex= */ 0); - playUntilStartOfWindow(player, /* windowIndex= */ 0); + playUntilStartOfMediaItem(player, /* mediaItemIndex= */ 0); + playUntilStartOfMediaItem(player, /* mediaItemIndex= */ 0); player.setRepeatMode(Player.REPEAT_MODE_OFF); - playUntilStartOfWindow(player, /* windowIndex= */ 1); - playUntilStartOfWindow(player, /* windowIndex= */ 2); + playUntilStartOfMediaItem(player, /* mediaItemIndex= */ 1); + playUntilStartOfMediaItem(player, /* mediaItemIndex= */ 2); player.play(); runUntilPlaybackState(player, Player.STATE_ENDED); @@ -704,9 +704,9 @@ public final class ExoPlayerTest { .pause() .waitForPlaybackState(Player.STATE_READY) .setRepeatMode(Player.REPEAT_MODE_ALL) - .playUntilStartOfWindow(/* windowIndex= */ 1) + .playUntilStartOfMediaItem(/* mediaItemIndex= */ 1) .setShuffleModeEnabled(true) - .playUntilStartOfWindow(/* windowIndex= */ 1) + .playUntilStartOfMediaItem(/* mediaItemIndex= */ 1) .setShuffleModeEnabled(false) .setRepeatMode(Player.REPEAT_MODE_OFF) .play() @@ -816,7 +816,7 @@ public final class ExoPlayerTest { @Override public void run(ExoPlayer player) { try { - player.seekTo(/* windowIndex= */ 100, /* positionMs= */ 0); + player.seekTo(/* mediaItemIndex= */ 100, /* positionMs= */ 0); } catch (IllegalSeekPositionException e) { exception[0] = e; } @@ -1291,7 +1291,7 @@ public final class ExoPlayerTest { .play() .build(); new ExoPlayerTestRunner.Builder(context) - .initialSeek(/* windowIndex= */ 0, /* positionMs= */ 2000) + .initialSeek(/* mediaItemIndex= */ 0, /* positionMs= */ 2000) .setMediaSources(mediaSource) .setActionSchedule(actionSchedule) .build() @@ -1303,7 +1303,7 @@ public final class ExoPlayerTest { @Test public void stop_withoutReset_doesNotResetPosition_correctMasking() throws Exception { - int[] currentWindowIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + int[] currentMediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] bufferedPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] totalBufferedDuration = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; @@ -1312,18 +1312,18 @@ public final class ExoPlayerTest { ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .pause() - .seek(/* windowIndex= */ 1, /* positionMs= */ 1000) + .seek(/* mediaItemIndex= */ 1, /* positionMs= */ 1000) .waitForPlaybackState(Player.STATE_READY) .executeRunnable( new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndex[0] = player.getCurrentWindowIndex(); + currentMediaItemIndex[0] = player.getCurrentMediaItemIndex(); currentPosition[0] = player.getCurrentPosition(); bufferedPosition[0] = player.getBufferedPosition(); totalBufferedDuration[0] = player.getTotalBufferedDuration(); player.stop(/* reset= */ false); - currentWindowIndex[1] = player.getCurrentWindowIndex(); + currentMediaItemIndex[1] = player.getCurrentMediaItemIndex(); currentPosition[1] = player.getCurrentPosition(); bufferedPosition[1] = player.getBufferedPosition(); totalBufferedDuration[1] = player.getTotalBufferedDuration(); @@ -1334,7 +1334,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndex[2] = player.getCurrentWindowIndex(); + currentMediaItemIndex[2] = player.getCurrentMediaItemIndex(); currentPosition[2] = player.getCurrentPosition(); bufferedPosition[2] = player.getBufferedPosition(); totalBufferedDuration[2] = player.getTotalBufferedDuration(); @@ -1355,17 +1355,17 @@ public final class ExoPlayerTest { Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE); testRunner.assertPositionDiscontinuityReasonsEqual(Player.DISCONTINUITY_REASON_SEEK); - assertThat(currentWindowIndex[0]).isEqualTo(1); + assertThat(currentMediaItemIndex[0]).isEqualTo(1); assertThat(currentPosition[0]).isEqualTo(1000); assertThat(bufferedPosition[0]).isEqualTo(10000); assertThat(totalBufferedDuration[0]).isEqualTo(9000); - assertThat(currentWindowIndex[1]).isEqualTo(1); + assertThat(currentMediaItemIndex[1]).isEqualTo(1); assertThat(currentPosition[1]).isEqualTo(1000); assertThat(bufferedPosition[1]).isEqualTo(1000); assertThat(totalBufferedDuration[1]).isEqualTo(0); - assertThat(currentWindowIndex[2]).isEqualTo(1); + assertThat(currentMediaItemIndex[2]).isEqualTo(1); assertThat(currentPosition[2]).isEqualTo(1000); assertThat(bufferedPosition[2]).isEqualTo(1000); assertThat(totalBufferedDuration[2]).isEqualTo(0); @@ -1395,7 +1395,7 @@ public final class ExoPlayerTest { @Test public void stop_withReset_doesResetPosition_correctMasking() throws Exception { - int[] currentWindowIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + int[] currentMediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] bufferedPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] totalBufferedDuration = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; @@ -1404,18 +1404,18 @@ public final class ExoPlayerTest { ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .pause() - .seek(/* windowIndex= */ 1, /* positionMs= */ 1000) + .seek(/* mediaItemIndex= */ 1, /* positionMs= */ 1000) .waitForPlaybackState(Player.STATE_READY) .executeRunnable( new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndex[0] = player.getCurrentWindowIndex(); + currentMediaItemIndex[0] = player.getCurrentMediaItemIndex(); currentPosition[0] = player.getCurrentPosition(); bufferedPosition[0] = player.getBufferedPosition(); totalBufferedDuration[0] = player.getTotalBufferedDuration(); player.stop(/* reset= */ true); - currentWindowIndex[1] = player.getCurrentWindowIndex(); + currentMediaItemIndex[1] = player.getCurrentMediaItemIndex(); currentPosition[1] = player.getCurrentPosition(); bufferedPosition[1] = player.getBufferedPosition(); totalBufferedDuration[1] = player.getTotalBufferedDuration(); @@ -1426,7 +1426,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndex[2] = player.getCurrentWindowIndex(); + currentMediaItemIndex[2] = player.getCurrentMediaItemIndex(); currentPosition[2] = player.getCurrentPosition(); bufferedPosition[2] = player.getBufferedPosition(); totalBufferedDuration[2] = player.getTotalBufferedDuration(); @@ -1449,17 +1449,17 @@ public final class ExoPlayerTest { testRunner.assertPositionDiscontinuityReasonsEqual( Player.DISCONTINUITY_REASON_SEEK, Player.DISCONTINUITY_REASON_REMOVE); - assertThat(currentWindowIndex[0]).isEqualTo(1); + assertThat(currentMediaItemIndex[0]).isEqualTo(1); assertThat(currentPosition[0]).isGreaterThan(0); assertThat(bufferedPosition[0]).isEqualTo(10000); assertThat(totalBufferedDuration[0]).isEqualTo(10000 - currentPosition[0]); - assertThat(currentWindowIndex[1]).isEqualTo(0); + assertThat(currentMediaItemIndex[1]).isEqualTo(0); assertThat(currentPosition[1]).isEqualTo(0); assertThat(bufferedPosition[1]).isEqualTo(0); assertThat(totalBufferedDuration[1]).isEqualTo(0); - assertThat(currentWindowIndex[2]).isEqualTo(0); + assertThat(currentMediaItemIndex[2]).isEqualTo(0); assertThat(currentPosition[2]).isEqualTo(0); assertThat(bufferedPosition[2]).isEqualTo(0); assertThat(totalBufferedDuration[2]).isEqualTo(0); @@ -1489,7 +1489,7 @@ public final class ExoPlayerTest { @Test public void release_correctMasking() throws Exception { - int[] currentWindowIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + int[] currentMediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] bufferedPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] totalBufferedDuration = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; @@ -1498,18 +1498,18 @@ public final class ExoPlayerTest { ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .pause() - .seek(/* windowIndex= */ 1, /* positionMs= */ 1000) + .seek(/* mediaItemIndex= */ 1, /* positionMs= */ 1000) .waitForPlaybackState(Player.STATE_READY) .executeRunnable( new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndex[0] = player.getCurrentWindowIndex(); + currentMediaItemIndex[0] = player.getCurrentMediaItemIndex(); currentPosition[0] = player.getCurrentPosition(); bufferedPosition[0] = player.getBufferedPosition(); totalBufferedDuration[0] = player.getTotalBufferedDuration(); player.release(); - currentWindowIndex[1] = player.getCurrentWindowIndex(); + currentMediaItemIndex[1] = player.getCurrentMediaItemIndex(); currentPosition[1] = player.getCurrentPosition(); bufferedPosition[1] = player.getBufferedPosition(); totalBufferedDuration[1] = player.getTotalBufferedDuration(); @@ -1520,7 +1520,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndex[2] = player.getCurrentWindowIndex(); + currentMediaItemIndex[2] = player.getCurrentMediaItemIndex(); currentPosition[2] = player.getCurrentPosition(); bufferedPosition[2] = player.getBufferedPosition(); totalBufferedDuration[2] = player.getTotalBufferedDuration(); @@ -1535,17 +1535,17 @@ public final class ExoPlayerTest { .start() .blockUntilActionScheduleFinished(TIMEOUT_MS); - assertThat(currentWindowIndex[0]).isEqualTo(1); + assertThat(currentMediaItemIndex[0]).isEqualTo(1); assertThat(currentPosition[0]).isGreaterThan(0); assertThat(bufferedPosition[0]).isEqualTo(10000); assertThat(totalBufferedDuration[0]).isEqualTo(10000 - currentPosition[0]); - assertThat(currentWindowIndex[1]).isEqualTo(1); + assertThat(currentMediaItemIndex[1]).isEqualTo(1); assertThat(currentPosition[1]).isEqualTo(currentPosition[0]); assertThat(bufferedPosition[1]).isEqualTo(1000); assertThat(totalBufferedDuration[1]).isEqualTo(0); - assertThat(currentWindowIndex[2]).isEqualTo(1); + assertThat(currentMediaItemIndex[2]).isEqualTo(1); assertThat(currentPosition[2]).isEqualTo(currentPosition[0]); assertThat(bufferedPosition[2]).isEqualTo(1000); assertThat(totalBufferedDuration[2]).isEqualTo(0); @@ -1557,21 +1557,21 @@ public final class ExoPlayerTest { Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 2); MediaSource secondSource = new FakeMediaSource(secondTimeline, ExoPlayerTestRunner.VIDEO_FORMAT); - AtomicInteger windowIndexAfterStop = new AtomicInteger(); + AtomicInteger mediaItemIndexAfterStop = new AtomicInteger(); AtomicLong positionAfterStop = new AtomicLong(); ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .waitForPlaybackState(Player.STATE_READY) .stop(/* reset= */ true) .waitForPlaybackState(Player.STATE_IDLE) - .seek(/* windowIndex= */ 1, /* positionMs= */ 1000) + .seek(/* mediaItemIndex= */ 1, /* positionMs= */ 1000) .setMediaSources(secondSource) .prepare() .executeRunnable( new PlayerRunnable() { @Override public void run(ExoPlayer player) { - windowIndexAfterStop.set(player.getCurrentWindowIndex()); + mediaItemIndexAfterStop.set(player.getCurrentMediaItemIndex()); positionAfterStop.set(player.getCurrentPosition()); } }) @@ -1604,7 +1604,7 @@ public final class ExoPlayerTest { Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, // stop(true) Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE); - assertThat(windowIndexAfterStop.get()).isEqualTo(1); + assertThat(mediaItemIndexAfterStop.get()).isEqualTo(1); assertThat(positionAfterStop.get()).isAtLeast(1000L); testRunner.assertPlayedPeriodIndices(0, 1); } @@ -1631,8 +1631,8 @@ public final class ExoPlayerTest { new ActionSchedule.Builder(TAG) .pause() .waitForPlaybackState(Player.STATE_READY) - .playUntilPosition(/* windowIndex= */ 0, /* positionMs= */ 2000) - .setMediaSources(/* windowIndex= */ 0, /* positionMs= */ 2000, secondSource) + .playUntilPosition(/* mediaItemIndex= */ 0, /* positionMs= */ 2000) + .setMediaSources(/* mediaItemIndex= */ 0, /* positionMs= */ 2000, secondSource) .waitForTimelineChanged( secondTimeline, /* expectedReason */ Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE) .executeRunnable( @@ -1685,7 +1685,7 @@ public final class ExoPlayerTest { new ActionSchedule.Builder(TAG) .pause() .waitForPlaybackState(Player.STATE_READY) - .playUntilPosition(/* windowIndex= */ 0, /* positionMs= */ 2000) + .playUntilPosition(/* mediaItemIndex= */ 0, /* positionMs= */ 2000) .setMediaSources(/* resetPosition= */ true, secondSource) .waitForTimelineChanged( secondTimeline, /* expectedReason */ Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE) @@ -1742,7 +1742,7 @@ public final class ExoPlayerTest { new ActionSchedule.Builder(TAG) .pause() .waitForPlaybackState(Player.STATE_READY) - .playUntilPosition(/* windowIndex= */ 0, /* positionMs= */ 2000) + .playUntilPosition(/* mediaItemIndex= */ 0, /* positionMs= */ 2000) .setMediaSources(secondSource) .waitForTimelineChanged( secondTimeline, /* expectedReason */ Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE) @@ -1902,7 +1902,7 @@ public final class ExoPlayerTest { throws Exception { ConcatenatingMediaSource concatenatingMediaSource = new ConcatenatingMediaSource(/* isAtomic= */ false, new FakeShuffleOrder(0)); - AtomicInteger windowIndexAfterAddingSources = new AtomicInteger(); + AtomicInteger mediaItemIndexAfterAddingSources = new AtomicInteger(); ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .setShuffleModeEnabled(true) @@ -1919,7 +1919,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - windowIndexAfterAddingSources.set(player.getCurrentWindowIndex()); + mediaItemIndexAfterAddingSources.set(player.getCurrentMediaItemIndex()); } }) .build(); @@ -1930,20 +1930,20 @@ public final class ExoPlayerTest { .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertThat(windowIndexAfterAddingSources.get()).isEqualTo(1); + assertThat(mediaItemIndexAfterAddingSources.get()).isEqualTo(1); } @Test public void playbackErrorAndReprepareDoesNotResetPosition() throws Exception { final Timeline timeline = new FakeTimeline(/* windowCount= */ 2); final long[] positionHolder = new long[3]; - final int[] windowIndexHolder = new int[3]; + final int[] mediaItemIndexHolder = new int[3]; final FakeMediaSource firstMediaSource = new FakeMediaSource(timeline); ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .pause() .waitForPlaybackState(Player.STATE_READY) - .playUntilPosition(/* windowIndex= */ 1, /* positionMs= */ 500) + .playUntilPosition(/* mediaItemIndex= */ 1, /* positionMs= */ 500) .throwPlaybackException( ExoPlaybackException.createForSource( new IOException(), PlaybackException.ERROR_CODE_IO_UNSPECIFIED)) @@ -1954,7 +1954,7 @@ public final class ExoPlayerTest { public void run(ExoPlayer player) { // Position while in error state positionHolder[0] = player.getCurrentPosition(); - windowIndexHolder[0] = player.getCurrentWindowIndex(); + mediaItemIndexHolder[0] = player.getCurrentMediaItemIndex(); } }) .prepare() @@ -1964,7 +1964,7 @@ public final class ExoPlayerTest { public void run(ExoPlayer player) { // Position while repreparing. positionHolder[1] = player.getCurrentPosition(); - windowIndexHolder[1] = player.getCurrentWindowIndex(); + mediaItemIndexHolder[1] = player.getCurrentMediaItemIndex(); } }) .waitForPlaybackState(Player.STATE_READY) @@ -1974,7 +1974,7 @@ public final class ExoPlayerTest { public void run(ExoPlayer player) { // Position after repreparation finished. positionHolder[2] = player.getCurrentPosition(); - windowIndexHolder[2] = player.getCurrentWindowIndex(); + mediaItemIndexHolder[2] = player.getCurrentMediaItemIndex(); } }) .play() @@ -1993,22 +1993,22 @@ public final class ExoPlayerTest { assertThat(positionHolder[0]).isAtLeast(500L); assertThat(positionHolder[1]).isEqualTo(positionHolder[0]); assertThat(positionHolder[2]).isEqualTo(positionHolder[0]); - assertThat(windowIndexHolder[0]).isEqualTo(1); - assertThat(windowIndexHolder[1]).isEqualTo(1); - assertThat(windowIndexHolder[2]).isEqualTo(1); + assertThat(mediaItemIndexHolder[0]).isEqualTo(1); + assertThat(mediaItemIndexHolder[1]).isEqualTo(1); + assertThat(mediaItemIndexHolder[2]).isEqualTo(1); } @Test public void seekAfterPlaybackError() throws Exception { final Timeline timeline = new FakeTimeline(/* windowCount= */ 2); final long[] positionHolder = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; - final int[] windowIndexHolder = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndexHolder = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; final FakeMediaSource firstMediaSource = new FakeMediaSource(timeline); ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .pause() .waitForPlaybackState(Player.STATE_READY) - .playUntilPosition(/* windowIndex= */ 1, /* positionMs= */ 500) + .playUntilPosition(/* mediaItemIndex= */ 1, /* positionMs= */ 500) .throwPlaybackException( ExoPlaybackException.createForSource( new IOException(), PlaybackException.ERROR_CODE_IO_UNSPECIFIED)) @@ -2019,10 +2019,10 @@ public final class ExoPlayerTest { public void run(ExoPlayer player) { // Position while in error state positionHolder[0] = player.getCurrentPosition(); - windowIndexHolder[0] = player.getCurrentWindowIndex(); + mediaItemIndexHolder[0] = player.getCurrentMediaItemIndex(); } }) - .seek(/* windowIndex= */ 0, /* positionMs= */ C.TIME_UNSET) + .seek(/* mediaItemIndex= */ 0, /* positionMs= */ C.TIME_UNSET) .waitForPendingPlayerCommands() .executeRunnable( new PlayerRunnable() { @@ -2030,7 +2030,7 @@ public final class ExoPlayerTest { public void run(ExoPlayer player) { // Position while in error state positionHolder[1] = player.getCurrentPosition(); - windowIndexHolder[1] = player.getCurrentWindowIndex(); + mediaItemIndexHolder[1] = player.getCurrentMediaItemIndex(); } }) .prepare() @@ -2040,7 +2040,7 @@ public final class ExoPlayerTest { public void run(ExoPlayer player) { // Position after prepare. positionHolder[2] = player.getCurrentPosition(); - windowIndexHolder[2] = player.getCurrentWindowIndex(); + mediaItemIndexHolder[2] = player.getCurrentMediaItemIndex(); } }) .play() @@ -2061,9 +2061,9 @@ public final class ExoPlayerTest { assertThat(positionHolder[0]).isAtLeast(500L); assertThat(positionHolder[1]).isEqualTo(0L); assertThat(positionHolder[2]).isEqualTo(0L); - assertThat(windowIndexHolder[0]).isEqualTo(1); - assertThat(windowIndexHolder[1]).isEqualTo(0); - assertThat(windowIndexHolder[2]).isEqualTo(0); + assertThat(mediaItemIndexHolder[0]).isEqualTo(1); + assertThat(mediaItemIndexHolder[1]).isEqualTo(0); + assertThat(mediaItemIndexHolder[2]).isEqualTo(0); } @Test @@ -2226,7 +2226,7 @@ public final class ExoPlayerTest { .pause() .sendMessage( (messageType, payload) -> counter.getAndIncrement(), - /* windowIndex= */ 0, + /* mediaItemIndex= */ 0, /* positionMs= */ 2000, /* deleteAfterDelivery= */ false) .seek(/* positionMs= */ 2000) @@ -2300,23 +2300,23 @@ public final class ExoPlayerTest { long duration2Ms = timeline.getWindow(1, new Window()).getDurationMs(); ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) - .sendMessage(targetStartFirstPeriod, /* windowIndex= */ 0, /* positionMs= */ 0) + .sendMessage(targetStartFirstPeriod, /* mediaItemIndex= */ 0, /* positionMs= */ 0) .sendMessage( targetEndMiddlePeriodResolved, - /* windowIndex= */ 0, + /* mediaItemIndex= */ 0, /* positionMs= */ duration1Ms - 1) .sendMessage( targetEndMiddlePeriodUnresolved, - /* windowIndex= */ 0, + /* mediaItemIndex= */ 0, /* positionMs= */ C.TIME_END_OF_SOURCE) - .sendMessage(targetStartMiddlePeriod, /* windowIndex= */ 1, /* positionMs= */ 0) + .sendMessage(targetStartMiddlePeriod, /* mediaItemIndex= */ 1, /* positionMs= */ 0) .sendMessage( targetEndLastPeriodResolved, - /* windowIndex= */ 1, + /* mediaItemIndex= */ 1, /* positionMs= */ duration2Ms - 1) .sendMessage( targetEndLastPeriodUnresolved, - /* windowIndex= */ 1, + /* mediaItemIndex= */ 1, /* positionMs= */ C.TIME_END_OF_SOURCE) .waitForMessage(targetEndLastPeriodUnresolved) .build(); @@ -2327,19 +2327,19 @@ public final class ExoPlayerTest { .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertThat(targetStartFirstPeriod.windowIndex).isEqualTo(0); + assertThat(targetStartFirstPeriod.mediaItemIndex).isEqualTo(0); assertThat(targetStartFirstPeriod.positionMs).isAtLeast(0L); - assertThat(targetEndMiddlePeriodResolved.windowIndex).isEqualTo(0); + assertThat(targetEndMiddlePeriodResolved.mediaItemIndex).isEqualTo(0); assertThat(targetEndMiddlePeriodResolved.positionMs).isAtLeast(duration1Ms - 1); - assertThat(targetEndMiddlePeriodUnresolved.windowIndex).isEqualTo(0); + assertThat(targetEndMiddlePeriodUnresolved.mediaItemIndex).isEqualTo(0); assertThat(targetEndMiddlePeriodUnresolved.positionMs).isAtLeast(duration1Ms - 1); assertThat(targetEndMiddlePeriodResolved.positionMs) .isEqualTo(targetEndMiddlePeriodUnresolved.positionMs); - assertThat(targetStartMiddlePeriod.windowIndex).isEqualTo(1); + assertThat(targetStartMiddlePeriod.mediaItemIndex).isEqualTo(1); assertThat(targetStartMiddlePeriod.positionMs).isAtLeast(0L); - assertThat(targetEndLastPeriodResolved.windowIndex).isEqualTo(1); + assertThat(targetEndLastPeriodResolved.mediaItemIndex).isEqualTo(1); assertThat(targetEndLastPeriodResolved.positionMs).isAtLeast(duration2Ms - 1); - assertThat(targetEndLastPeriodUnresolved.windowIndex).isEqualTo(1); + assertThat(targetEndLastPeriodUnresolved.mediaItemIndex).isEqualTo(1); assertThat(targetEndLastPeriodUnresolved.positionMs).isAtLeast(duration2Ms - 1); assertThat(targetEndLastPeriodResolved.positionMs) .isEqualTo(targetEndLastPeriodUnresolved.positionMs); @@ -2455,12 +2455,12 @@ public final class ExoPlayerTest { .waitForPlaybackState(Player.STATE_BUFFERING) .sendMessage( target, - /* windowIndex= */ 0, + /* mediaItemIndex= */ 0, /* positionMs= */ 50, /* deleteAfterDelivery= */ false) .setRepeatMode(Player.REPEAT_MODE_ALL) - .playUntilPosition(/* windowIndex= */ 0, /* positionMs= */ 1) - .playUntilStartOfWindow(/* windowIndex= */ 0) + .playUntilPosition(/* mediaItemIndex= */ 0, /* positionMs= */ 1) + .playUntilStartOfMediaItem(/* mediaItemIndex= */ 0) .setRepeatMode(Player.REPEAT_MODE_OFF) .play() .build(); @@ -2474,7 +2474,7 @@ public final class ExoPlayerTest { } @Test - public void sendMessagesMoveCurrentWindowIndex() throws Exception { + public void sendMessagesMoveCurrentMediaItemIndex() throws Exception { Timeline timeline = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ 0)); final Timeline secondTimeline = @@ -2502,7 +2502,7 @@ public final class ExoPlayerTest { .start() .blockUntilEnded(TIMEOUT_MS); assertThat(target.positionMs).isAtLeast(50L); - assertThat(target.windowIndex).isEqualTo(1); + assertThat(target.mediaItemIndex).isEqualTo(1); } @Test @@ -2513,7 +2513,7 @@ public final class ExoPlayerTest { new ActionSchedule.Builder(TAG) .pause() .waitForTimelineChanged(timeline, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE) - .sendMessage(target, /* windowIndex = */ 2, /* positionMs= */ 50) + .sendMessage(target, /* mediaItemIndex = */ 2, /* positionMs= */ 50) .play() .build(); new ExoPlayerTestRunner.Builder(context) @@ -2522,7 +2522,7 @@ public final class ExoPlayerTest { .build() .start() .blockUntilEnded(TIMEOUT_MS); - assertThat(target.windowIndex).isEqualTo(2); + assertThat(target.mediaItemIndex).isEqualTo(2); assertThat(target.positionMs).isAtLeast(50L); } @@ -2535,7 +2535,7 @@ public final class ExoPlayerTest { .pause() .waitForTimelineChanged( timeline, /* expectedReason */ Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE) - .sendMessage(target, /* windowIndex = */ 2, /* positionMs= */ 50) + .sendMessage(target, /* mediaItemIndex = */ 2, /* positionMs= */ 50) .play() .build(); new ExoPlayerTestRunner.Builder(context) @@ -2544,12 +2544,12 @@ public final class ExoPlayerTest { .build() .start() .blockUntilEnded(TIMEOUT_MS); - assertThat(target.windowIndex).isEqualTo(2); + assertThat(target.mediaItemIndex).isEqualTo(2); assertThat(target.positionMs).isAtLeast(50L); } @Test - public void sendMessagesMoveWindowIndex() throws Exception { + public void sendMessagesMoveMediaItemIndex() throws Exception { Timeline timeline = new FakeTimeline( new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ 0), @@ -2566,11 +2566,11 @@ public final class ExoPlayerTest { .pause() .waitForTimelineChanged( timeline, /* expectedReason */ Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE) - .sendMessage(target, /* windowIndex = */ 1, /* positionMs= */ 50) + .sendMessage(target, /* mediaItemIndex = */ 1, /* positionMs= */ 50) .executeRunnable(() -> mediaSource.setNewSourceInfo(secondTimeline)) .waitForTimelineChanged( secondTimeline, /* expectedReason */ Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE) - .seek(/* windowIndex= */ 0, /* positionMs= */ 0) + .seek(/* mediaItemIndex= */ 0, /* positionMs= */ 0) .play() .build(); new ExoPlayerTestRunner.Builder(context) @@ -2580,7 +2580,7 @@ public final class ExoPlayerTest { .start() .blockUntilEnded(TIMEOUT_MS); assertThat(target.positionMs).isAtLeast(50L); - assertThat(target.windowIndex).isEqualTo(0); + assertThat(target.mediaItemIndex).isEqualTo(0); } @Test @@ -2600,11 +2600,11 @@ public final class ExoPlayerTest { new ActionSchedule.Builder(TAG) .pause() .waitForPlaybackState(Player.STATE_READY) - .sendMessage(target1, /* windowIndex = */ 0, /* positionMs= */ 50) - .sendMessage(target2, /* windowIndex = */ 1, /* positionMs= */ 50) - .sendMessage(target3, /* windowIndex = */ 2, /* positionMs= */ 50) + .sendMessage(target1, /* mediaItemIndex = */ 0, /* positionMs= */ 50) + .sendMessage(target2, /* mediaItemIndex = */ 1, /* positionMs= */ 50) + .sendMessage(target3, /* mediaItemIndex = */ 2, /* positionMs= */ 50) .setShuffleModeEnabled(true) - .seek(/* windowIndex= */ 2, /* positionMs= */ 0) + .seek(/* mediaItemIndex= */ 2, /* positionMs= */ 0) .play() .build(); new ExoPlayerTestRunner.Builder(context) @@ -2613,9 +2613,9 @@ public final class ExoPlayerTest { .build() .start() .blockUntilEnded(TIMEOUT_MS); - assertThat(target1.windowIndex).isEqualTo(0); - assertThat(target2.windowIndex).isEqualTo(1); - assertThat(target3.windowIndex).isEqualTo(2); + assertThat(target1.mediaItemIndex).isEqualTo(0); + assertThat(target2.mediaItemIndex).isEqualTo(1); + assertThat(target3.mediaItemIndex).isEqualTo(2); } @Test @@ -2635,7 +2635,7 @@ public final class ExoPlayerTest { } }) // Play a bit to ensure message arrived in internal player. - .playUntilPosition(/* windowIndex= */ 0, /* positionMs= */ 30) + .playUntilPosition(/* mediaItemIndex= */ 0, /* positionMs= */ 30) .executeRunnable(() -> message.get().cancel()) .play() .build(); @@ -2669,7 +2669,7 @@ public final class ExoPlayerTest { } }) // Play until the message has been delivered. - .playUntilPosition(/* windowIndex= */ 0, /* positionMs= */ 51) + .playUntilPosition(/* mediaItemIndex= */ 0, /* positionMs= */ 51) // Seek back, cancel the message, and play past the same position again. .seek(/* positionMs= */ 0) .executeRunnable(() -> message.get().cancel()) @@ -2691,13 +2691,13 @@ public final class ExoPlayerTest { player.addMediaSources(ImmutableList.of(new FakeMediaSource(), new FakeMediaSource())); player .createMessage((messageType, payload) -> {}) - .setPosition(/* windowIndex= */ 0, /* positionMs= */ 0) + .setPosition(/* mediaItemIndex= */ 0, /* positionMs= */ 0) .setDeleteAfterDelivery(false) .send(); PlayerMessage.Target secondMediaItemTarget = mock(PlayerMessage.Target.class); player .createMessage(secondMediaItemTarget) - .setPosition(/* windowIndex= */ 1, /* positionMs= */ 0) + .setPosition(/* mediaItemIndex= */ 1, /* positionMs= */ 0) .setDeleteAfterDelivery(false) .send(); @@ -2775,7 +2775,7 @@ public final class ExoPlayerTest { .waitForPlaybackState(Player.STATE_READY) // Ensure next period is pre-buffered by playing until end of first period. .playUntilPosition( - /* windowIndex= */ 0, + /* mediaItemIndex= */ 0, /* positionMs= */ Util.usToMs(TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US)) .executeRunnable(() -> mediaSource.setNewSourceInfo(timeline2)) .waitForTimelineChanged( @@ -2931,12 +2931,12 @@ public final class ExoPlayerTest { new ActionSchedule.Builder(TAG) .pause() .waitForPlaybackState(Player.STATE_READY) - .seek(/* windowIndex= */ 0, /* positionMs= */ 9999) + .seek(/* mediaItemIndex= */ 0, /* positionMs= */ 9999) // Wait after each seek until the internal player has updated its state. .waitForPendingPlayerCommands() - .seek(/* windowIndex= */ 0, /* positionMs= */ 1) + .seek(/* mediaItemIndex= */ 0, /* positionMs= */ 1) .waitForPendingPlayerCommands() - .seek(/* windowIndex= */ 0, /* positionMs= */ 9999) + .seek(/* mediaItemIndex= */ 0, /* positionMs= */ 9999) .waitForPendingPlayerCommands() .play() .build(); @@ -2998,7 +2998,7 @@ public final class ExoPlayerTest { } catch (InterruptedException e) { throw new IllegalStateException(e); } - player.seekTo(/* windowIndex= */ 0, /* positionMs= */ 1000L); + player.seekTo(/* mediaItemIndex= */ 0, /* positionMs= */ 1000L); } }) .waitForPendingPlayerCommands() @@ -3264,8 +3264,8 @@ public final class ExoPlayerTest { .setRepeatMode(Player.REPEAT_MODE_ALL) .waitForPlaybackState(Player.STATE_READY) // Play until the media repeats once. - .playUntilPosition(/* windowIndex= */ 0, /* positionMs= */ 1) - .playUntilStartOfWindow(/* windowIndex= */ 0) + .playUntilPosition(/* mediaItemIndex= */ 0, /* positionMs= */ 1) + .playUntilStartOfMediaItem(/* mediaItemIndex= */ 0) .setRepeatMode(Player.REPEAT_MODE_OFF) .play() .build(); @@ -3299,7 +3299,7 @@ public final class ExoPlayerTest { new ActionSchedule.Builder(TAG) .pause() .waitForPlaybackState(Player.STATE_READY) - .seek(/* windowIndex= */ 1, /* positionMs= */ 0) + .seek(/* mediaItemIndex= */ 1, /* positionMs= */ 0) .waitForPendingPlayerCommands() .play() .build(); @@ -3347,7 +3347,7 @@ public final class ExoPlayerTest { .pause() .waitForPlaybackState(Player.STATE_READY) // Play almost to end to ensure the current period is fully buffered. - .playUntilPosition(/* windowIndex= */ 0, /* positionMs= */ 90) + .playUntilPosition(/* mediaItemIndex= */ 0, /* positionMs= */ 90) // Enable repeat mode to trigger the creation of new media periods. .setRepeatMode(Player.REPEAT_MODE_ALL) // Remove the media source. @@ -3862,20 +3862,20 @@ public final class ExoPlayerTest { return Timeline.EMPTY; } }; - int[] currentWindowIndices = new int[1]; + int[] currentMediaItemIndices = new int[1]; long[] currentPlaybackPositions = new long[1]; long[] windowCounts = new long[1]; - int seekToWindowIndex = 1; + int seekToMediaItemIndex = 1; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) - .seek(/* windowIndex= */ 1, /* positionMs= */ 5000) + .seek(/* mediaItemIndex= */ 1, /* positionMs= */ 5000) .waitForTimelineChanged( /* expectedTimeline= */ null, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE) .executeRunnable( new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); currentPlaybackPositions[0] = player.getCurrentPosition(); windowCounts[0] = player.getCurrentTimeline().getWindowCount(); } @@ -3892,23 +3892,23 @@ public final class ExoPlayerTest { exoPlayerTestRunner.assertTimelineChangeReasonsEqual( Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE); assertArrayEquals(new long[] {2}, windowCounts); - assertArrayEquals(new int[] {seekToWindowIndex}, currentWindowIndices); + assertArrayEquals(new int[] {seekToMediaItemIndex}, currentMediaItemIndices); assertArrayEquals(new long[] {5_000}, currentPlaybackPositions); } @SuppressWarnings("deprecation") @Test - public void seekTo_windowIndexIsReset_deprecated() throws Exception { + public void seekTo_mediaItemIndexIsReset_deprecated() throws Exception { FakeTimeline fakeTimeline = new FakeTimeline(); FakeMediaSource mediaSource = new FakeMediaSource(fakeTimeline); - final int[] windowIndex = {C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET}; final long[] positionMs = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; final long[] bufferedPositions = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .pause() - .seek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET) - .playUntilPosition(/* windowIndex= */ 1, /* positionMs= */ 3000) + .seek(/* mediaItemIndex= */ 1, /* positionMs= */ C.TIME_UNSET) + .playUntilPosition(/* mediaItemIndex= */ 1, /* positionMs= */ 3000) .executeRunnable( new PlayerRunnable() { @Override @@ -3927,7 +3927,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - windowIndex[0] = player.getCurrentWindowIndex(); + mediaItemIndex[0] = player.getCurrentMediaItemIndex(); positionMs[2] = player.getCurrentPosition(); bufferedPositions[2] = player.getBufferedPosition(); } @@ -3940,7 +3940,7 @@ public final class ExoPlayerTest { .start() .blockUntilActionScheduleFinished(TIMEOUT_MS); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(positionMs[0]).isAtLeast(3000L); assertThat(positionMs[1]).isEqualTo(7000L); assertThat(positionMs[2]).isEqualTo(7000L); @@ -3951,17 +3951,17 @@ public final class ExoPlayerTest { } @Test - public void seekTo_windowIndexIsReset() throws Exception { + public void seekTo_mediaItemIndexIsReset() throws Exception { FakeTimeline fakeTimeline = new FakeTimeline(); FakeMediaSource mediaSource = new FakeMediaSource(fakeTimeline); - final int[] windowIndex = {C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET}; final long[] positionMs = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; final long[] bufferedPositions = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .pause() - .seek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET) - .playUntilPosition(/* windowIndex= */ 1, /* positionMs= */ 3000) + .seek(/* mediaItemIndex= */ 1, /* positionMs= */ C.TIME_UNSET) + .playUntilPosition(/* mediaItemIndex= */ 1, /* positionMs= */ 3000) .pause() .executeRunnable( new PlayerRunnable() { @@ -3980,7 +3980,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - windowIndex[0] = player.getCurrentWindowIndex(); + mediaItemIndex[0] = player.getCurrentMediaItemIndex(); positionMs[2] = player.getCurrentPosition(); bufferedPositions[2] = player.getBufferedPosition(); } @@ -3993,7 +3993,7 @@ public final class ExoPlayerTest { .start() .blockUntilActionScheduleFinished(TIMEOUT_MS); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(positionMs[0]).isAtLeast(3000); assertThat(positionMs[1]).isEqualTo(7000); assertThat(positionMs[2]).isEqualTo(7000); @@ -4005,7 +4005,7 @@ public final class ExoPlayerTest { @Test public void seekTo_singlePeriod_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4017,19 +4017,19 @@ public final class ExoPlayerTest { player.seekTo(9000); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 9200)); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(positionMs[0]).isEqualTo(9000); assertThat(bufferedPositions[0]).isEqualTo(9200); assertThat(totalBufferedDuration[0]).isEqualTo(200); - assertThat(windowIndex[1]).isEqualTo(windowIndex[0]); + assertThat(mediaItemIndex[1]).isEqualTo(mediaItemIndex[0]); assertThat(positionMs[1]).isEqualTo(positionMs[0]); assertThat(bufferedPositions[1]).isEqualTo(9200); assertThat(totalBufferedDuration[1]).isEqualTo(200); @@ -4037,7 +4037,7 @@ public final class ExoPlayerTest { @Test public void seekTo_singlePeriod_beyondBufferedData_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4049,19 +4049,19 @@ public final class ExoPlayerTest { player.seekTo(9200); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 9200)); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(positionMs[0]).isEqualTo(9200); assertThat(bufferedPositions[0]).isEqualTo(9200); assertThat(totalBufferedDuration[0]).isEqualTo(0); - assertThat(windowIndex[1]).isEqualTo(windowIndex[0]); + assertThat(mediaItemIndex[1]).isEqualTo(mediaItemIndex[0]); assertThat(positionMs[1]).isEqualTo(positionMs[0]); assertThat(bufferedPositions[1]).isEqualTo(9200); assertThat(totalBufferedDuration[1]).isEqualTo(0); @@ -4069,7 +4069,7 @@ public final class ExoPlayerTest { @Test public void seekTo_backwardsSinglePeriod_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4081,14 +4081,14 @@ public final class ExoPlayerTest { player.seekTo(1000); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 9200)); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(positionMs[0]).isEqualTo(1000); assertThat(bufferedPositions[0]).isEqualTo(1000); assertThat(totalBufferedDuration[0]).isEqualTo(0); @@ -4096,7 +4096,7 @@ public final class ExoPlayerTest { @Test public void seekTo_backwardsMultiplePeriods_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4108,8 +4108,8 @@ public final class ExoPlayerTest { player.seekTo(0, 1000); } }, - /* pauseWindowIndex= */ 1, - windowIndex, + /* pauseMediaItemIndex= */ 1, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, @@ -4117,7 +4117,7 @@ public final class ExoPlayerTest { new FakeMediaSource(), createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 9200)); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(positionMs[0]).isEqualTo(1000); assertThat(bufferedPositions[0]).isEqualTo(1000); assertThat(totalBufferedDuration[0]).isEqualTo(0); @@ -4125,7 +4125,7 @@ public final class ExoPlayerTest { @Test public void seekTo_toUnbufferedPeriod_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4137,8 +4137,8 @@ public final class ExoPlayerTest { player.seekTo(2, 1000); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, @@ -4146,12 +4146,12 @@ public final class ExoPlayerTest { new FakeMediaSource(), createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 0)); - assertThat(windowIndex[0]).isEqualTo(2); + assertThat(mediaItemIndex[0]).isEqualTo(2); assertThat(positionMs[0]).isEqualTo(1000); assertThat(bufferedPositions[0]).isEqualTo(1000); assertThat(totalBufferedDuration[0]).isEqualTo(0); - assertThat(windowIndex[1]).isEqualTo(2); + assertThat(mediaItemIndex[1]).isEqualTo(2); assertThat(positionMs[1]).isEqualTo(1000); assertThat(bufferedPositions[1]).isEqualTo(1000); assertThat(totalBufferedDuration[1]).isEqualTo(0); @@ -4159,7 +4159,7 @@ public final class ExoPlayerTest { @Test public void seekTo_toLoadingPeriod_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4171,22 +4171,22 @@ public final class ExoPlayerTest { player.seekTo(1, 1000); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, new FakeMediaSource(), new FakeMediaSource()); - assertThat(windowIndex[0]).isEqualTo(1); + assertThat(mediaItemIndex[0]).isEqualTo(1); assertThat(positionMs[0]).isEqualTo(1000); // TODO(b/160450903): Verify masking of buffering properties when behaviour in EPII is fully // covered. // assertThat(bufferedPositions[0]).isEqualTo(10_000); // assertThat(totalBufferedDuration[0]).isEqualTo(10_000 - positionMs[0]); - assertThat(windowIndex[1]).isEqualTo(windowIndex[0]); + assertThat(mediaItemIndex[1]).isEqualTo(mediaItemIndex[0]); assertThat(positionMs[1]).isEqualTo(positionMs[0]); assertThat(bufferedPositions[1]).isEqualTo(10_000); assertThat(totalBufferedDuration[1]).isEqualTo(10_000 - positionMs[1]); @@ -4195,7 +4195,7 @@ public final class ExoPlayerTest { @Test public void seekTo_toLoadingPeriod_withinPartiallyBufferedData_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4207,22 +4207,22 @@ public final class ExoPlayerTest { player.seekTo(1, 1000); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, new FakeMediaSource(), createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); - assertThat(windowIndex[0]).isEqualTo(1); + assertThat(mediaItemIndex[0]).isEqualTo(1); assertThat(positionMs[0]).isEqualTo(1000); // TODO(b/160450903): Verify masking of buffering properties when behaviour in EPII is fully // covered. // assertThat(bufferedPositions[0]).isEqualTo(1000); // assertThat(totalBufferedDuration[0]).isEqualTo(0); - assertThat(windowIndex[1]).isEqualTo(windowIndex[0]); + assertThat(mediaItemIndex[1]).isEqualTo(mediaItemIndex[0]); assertThat(positionMs[1]).isEqualTo(positionMs[0]); assertThat(bufferedPositions[1]).isEqualTo(4000); assertThat(totalBufferedDuration[1]).isEqualTo(3000); @@ -4230,7 +4230,7 @@ public final class ExoPlayerTest { @Test public void seekTo_toLoadingPeriod_beyondBufferedData_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4242,20 +4242,20 @@ public final class ExoPlayerTest { player.seekTo(1, 5000); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, new FakeMediaSource(), createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); - assertThat(windowIndex[0]).isEqualTo(1); + assertThat(mediaItemIndex[0]).isEqualTo(1); assertThat(positionMs[0]).isEqualTo(5000); assertThat(bufferedPositions[0]).isEqualTo(5000); assertThat(totalBufferedDuration[0]).isEqualTo(0); - assertThat(windowIndex[1]).isEqualTo(1); + assertThat(mediaItemIndex[1]).isEqualTo(1); assertThat(positionMs[1]).isEqualTo(5000); assertThat(bufferedPositions[1]).isEqualTo(5000); assertThat(totalBufferedDuration[1]).isEqualTo(0); @@ -4263,7 +4263,7 @@ public final class ExoPlayerTest { @Test public void seekTo_toInnerFullyBufferedPeriod_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4275,8 +4275,8 @@ public final class ExoPlayerTest { player.seekTo(1, 5000); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, @@ -4284,14 +4284,14 @@ public final class ExoPlayerTest { new FakeMediaSource(), createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); - assertThat(windowIndex[0]).isEqualTo(1); + assertThat(mediaItemIndex[0]).isEqualTo(1); assertThat(positionMs[0]).isEqualTo(5000); // TODO(b/160450903): Verify masking of buffering properties when behaviour in EPII is fully // covered. // assertThat(bufferedPositions[0]).isEqualTo(10_000); // assertThat(totalBufferedDuration[0]).isEqualTo(10_000 - positionMs[0]); - assertThat(windowIndex[1]).isEqualTo(windowIndex[0]); + assertThat(mediaItemIndex[1]).isEqualTo(mediaItemIndex[0]); assertThat(positionMs[1]).isEqualTo(positionMs[0]); assertThat(bufferedPositions[1]).isEqualTo(10_000); assertThat(totalBufferedDuration[1]).isEqualTo(10_000 - positionMs[1]); @@ -4299,7 +4299,7 @@ public final class ExoPlayerTest { @Test public void addMediaSource_withinBufferedPeriods_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4312,20 +4312,20 @@ public final class ExoPlayerTest { /* index= */ 1, createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 0)); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, new FakeMediaSource(), createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(positionMs[0]).isAtLeast(8000); assertThat(bufferedPositions[0]).isEqualTo(10_000); assertThat(totalBufferedDuration[0]).isEqualTo(10_000 - positionMs[0]); - assertThat(windowIndex[1]).isEqualTo(windowIndex[0]); + assertThat(mediaItemIndex[1]).isEqualTo(mediaItemIndex[0]); assertThat(positionMs[1]).isEqualTo(positionMs[0]); assertThat(bufferedPositions[1]).isEqualTo(10_000); assertThat(totalBufferedDuration[1]).isEqualTo(10_000 - positionMs[1]); @@ -4333,7 +4333,7 @@ public final class ExoPlayerTest { @Test public void moveMediaItem_behindLoadingPeriod_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4345,8 +4345,8 @@ public final class ExoPlayerTest { player.moveMediaItem(/* currentIndex= */ 1, /* newIndex= */ 2); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, @@ -4354,12 +4354,12 @@ public final class ExoPlayerTest { new FakeMediaSource(), createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(positionMs[0]).isAtLeast(8000); assertThat(bufferedPositions[0]).isEqualTo(10_000); assertThat(totalBufferedDuration[0]).isEqualTo(10_000 - positionMs[0]); - assertThat(windowIndex[1]).isEqualTo(windowIndex[0]); + assertThat(mediaItemIndex[1]).isEqualTo(mediaItemIndex[0]); assertThat(positionMs[1]).isEqualTo(positionMs[0]); assertThat(bufferedPositions[1]).isEqualTo(10_000); assertThat(totalBufferedDuration[1]).isEqualTo(10_000 - positionMs[1]); @@ -4367,7 +4367,7 @@ public final class ExoPlayerTest { @Test public void moveMediaItem_undloadedBehindPlaying_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4379,8 +4379,8 @@ public final class ExoPlayerTest { player.moveMediaItem(/* currentIndex= */ 3, /* newIndex= */ 1); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, @@ -4389,12 +4389,12 @@ public final class ExoPlayerTest { createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000), createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 0)); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(positionMs[0]).isAtLeast(8000); assertThat(bufferedPositions[0]).isEqualTo(10_000); assertThat(totalBufferedDuration[0]).isEqualTo(10_000 - positionMs[0]); - assertThat(windowIndex[1]).isEqualTo(windowIndex[0]); + assertThat(mediaItemIndex[1]).isEqualTo(mediaItemIndex[0]); assertThat(positionMs[1]).isEqualTo(positionMs[0]); assertThat(bufferedPositions[1]).isEqualTo(10000); assertThat(totalBufferedDuration[1]).isEqualTo(10_000 - positionMs[1]); @@ -4402,7 +4402,7 @@ public final class ExoPlayerTest { @Test public void removeMediaItem_removePlayingWindow_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4414,22 +4414,22 @@ public final class ExoPlayerTest { player.removeMediaItem(/* index= */ 0); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, new FakeMediaSource(), createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(positionMs[0]).isEqualTo(0); // TODO(b/160450903): Verify masking of buffering properties when behaviour in EPII is fully // covered. // assertThat(bufferedPositions[0]).isEqualTo(4000); // assertThat(totalBufferedDuration[0]).isEqualTo(4000); - assertThat(windowIndex[1]).isEqualTo(windowIndex[0]); + assertThat(mediaItemIndex[1]).isEqualTo(mediaItemIndex[0]); assertThat(positionMs[1]).isEqualTo(positionMs[0]); assertThat(bufferedPositions[1]).isEqualTo(4000); assertThat(totalBufferedDuration[1]).isEqualTo(4000); @@ -4437,7 +4437,7 @@ public final class ExoPlayerTest { @Test public void removeMediaItem_removeLoadingWindow_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4449,8 +4449,8 @@ public final class ExoPlayerTest { player.removeMediaItem(/* index= */ 2); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, @@ -4458,12 +4458,12 @@ public final class ExoPlayerTest { new FakeMediaSource(), createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(positionMs[0]).isAtLeast(8000); assertThat(bufferedPositions[0]).isEqualTo(10_000); assertThat(totalBufferedDuration[0]).isEqualTo(10_000 - positionMs[0]); - assertThat(windowIndex[1]).isEqualTo(windowIndex[0]); + assertThat(mediaItemIndex[1]).isEqualTo(mediaItemIndex[0]); assertThat(positionMs[1]).isEqualTo(positionMs[0]); assertThat(bufferedPositions[1]).isEqualTo(10_000); assertThat(totalBufferedDuration[1]).isEqualTo(10_000 - positionMs[1]); @@ -4472,7 +4472,7 @@ public final class ExoPlayerTest { @Test public void removeMediaItem_removeInnerFullyBufferedWindow_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4484,8 +4484,8 @@ public final class ExoPlayerTest { player.removeMediaItem(/* index= */ 1); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, @@ -4493,12 +4493,12 @@ public final class ExoPlayerTest { new FakeMediaSource(), createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(positionMs[0]).isEqualTo(8000); assertThat(bufferedPositions[0]).isEqualTo(10_000); assertThat(totalBufferedDuration[0]).isEqualTo(10_000 - positionMs[0]); - assertThat(windowIndex[1]).isEqualTo(0); + assertThat(mediaItemIndex[1]).isEqualTo(0); assertThat(positionMs[1]).isEqualTo(positionMs[0]); assertThat(bufferedPositions[1]).isEqualTo(10_000); assertThat(totalBufferedDuration[1]).isEqualTo(10_000 - positionMs[0]); @@ -4506,7 +4506,7 @@ public final class ExoPlayerTest { @Test public void clearMediaItems_correctMaskingPosition() throws Exception { - final int[] windowIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] mediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] positionMs = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] bufferedPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] totalBufferedDuration = {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4518,8 +4518,8 @@ public final class ExoPlayerTest { player.clearMediaItems(); } }, - /* pauseWindowIndex= */ 0, - windowIndex, + /* pauseMediaItemIndex= */ 0, + mediaItemIndex, positionMs, bufferedPositions, totalBufferedDuration, @@ -4527,12 +4527,12 @@ public final class ExoPlayerTest { new FakeMediaSource(), createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(positionMs[0]).isEqualTo(0); assertThat(bufferedPositions[0]).isEqualTo(0); assertThat(totalBufferedDuration[0]).isEqualTo(0); - assertThat(windowIndex[1]).isEqualTo(windowIndex[0]); + assertThat(mediaItemIndex[1]).isEqualTo(mediaItemIndex[0]); assertThat(positionMs[1]).isEqualTo(positionMs[0]); assertThat(bufferedPositions[1]).isEqualTo(bufferedPositions[0]); assertThat(totalBufferedDuration[1]).isEqualTo(totalBufferedDuration[0]); @@ -4540,8 +4540,8 @@ public final class ExoPlayerTest { private void runPositionMaskingCapturingActionSchedule( PlayerRunnable actionRunnable, - int pauseWindowIndex, - int[] windowIndex, + int pauseMediaItemIndex, + int[] mediaItemIndex, long[] positionMs, long[] bufferedPosition, long[] totalBufferedDuration, @@ -4549,13 +4549,13 @@ public final class ExoPlayerTest { throws Exception { ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) - .playUntilPosition(pauseWindowIndex, /* positionMs= */ 8000) + .playUntilPosition(pauseMediaItemIndex, /* positionMs= */ 8000) .executeRunnable(actionRunnable) .executeRunnable( new PlayerRunnable() { @Override public void run(ExoPlayer player) { - windowIndex[0] = player.getCurrentWindowIndex(); + mediaItemIndex[0] = player.getCurrentMediaItemIndex(); positionMs[0] = player.getCurrentPosition(); bufferedPosition[0] = player.getBufferedPosition(); totalBufferedDuration[0] = player.getTotalBufferedDuration(); @@ -4566,7 +4566,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - windowIndex[1] = player.getCurrentWindowIndex(); + mediaItemIndex[1] = player.getCurrentMediaItemIndex(); positionMs[1] = player.getCurrentPosition(); bufferedPosition[1] = player.getBufferedPosition(); totalBufferedDuration[1] = player.getTotalBufferedDuration(); @@ -4647,7 +4647,7 @@ public final class ExoPlayerTest { /* durationUs= */ Util.msToUs(contentDurationMs), adPlaybackState)); FakeMediaSource adsMediaSource = new FakeMediaSource(adTimeline); - int[] windowIndex = new int[] {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + int[] mediaItemIndex = new int[] {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; long[] positionMs = new long[] {C.TIME_UNSET, C.TIME_UNSET, C.INDEX_UNSET}; long[] bufferedPositionMs = new long[] {C.TIME_UNSET, C.TIME_UNSET, C.INDEX_UNSET}; long[] totalBufferedDurationMs = new long[] {C.TIME_UNSET, C.TIME_UNSET, C.INDEX_UNSET}; @@ -4663,7 +4663,7 @@ public final class ExoPlayerTest { @Override public void run(ExoPlayer player) { player.addMediaSource(/* index= */ 1, new FakeMediaSource()); - windowIndex[0] = player.getCurrentWindowIndex(); + mediaItemIndex[0] = player.getCurrentMediaItemIndex(); isPlayingAd[0] = player.isPlayingAd(); positionMs[0] = player.getCurrentPosition(); bufferedPositionMs[0] = player.getBufferedPosition(); @@ -4675,21 +4675,21 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - windowIndex[1] = player.getCurrentWindowIndex(); + mediaItemIndex[1] = player.getCurrentMediaItemIndex(); isPlayingAd[1] = player.isPlayingAd(); positionMs[1] = player.getCurrentPosition(); bufferedPositionMs[1] = player.getBufferedPosition(); totalBufferedDurationMs[1] = player.getTotalBufferedDuration(); } }) - .playUntilPosition(/* windowIndex= */ 0, /* positionMs= */ 8000) + .playUntilPosition(/* mediaItemIndex= */ 0, /* positionMs= */ 8000) .waitForPendingPlayerCommands() .executeRunnable( new PlayerRunnable() { @Override public void run(ExoPlayer player) { player.addMediaSource(new FakeMediaSource()); - windowIndex[2] = player.getCurrentWindowIndex(); + mediaItemIndex[2] = player.getCurrentMediaItemIndex(); isPlayingAd[2] = player.isPlayingAd(); positionMs[2] = player.getCurrentPosition(); bufferedPositionMs[2] = player.getBufferedPosition(); @@ -4707,19 +4707,19 @@ public final class ExoPlayerTest { .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(isPlayingAd[0]).isTrue(); assertThat(positionMs[0]).isAtMost(adDurationMs); assertThat(bufferedPositionMs[0]).isEqualTo(adDurationMs); assertThat(totalBufferedDurationMs[0]).isAtLeast(adDurationMs - positionMs[0]); - assertThat(windowIndex[1]).isEqualTo(0); + assertThat(mediaItemIndex[1]).isEqualTo(0); assertThat(isPlayingAd[1]).isTrue(); assertThat(positionMs[1]).isAtMost(adDurationMs); assertThat(bufferedPositionMs[1]).isEqualTo(adDurationMs); assertThat(totalBufferedDurationMs[1]).isAtLeast(adDurationMs - positionMs[1]); - assertThat(windowIndex[2]).isEqualTo(0); + assertThat(mediaItemIndex[2]).isEqualTo(0); assertThat(isPlayingAd[2]).isFalse(); assertThat(positionMs[2]).isEqualTo(8000); assertThat(bufferedPositionMs[2]).isEqualTo(contentDurationMs); @@ -4748,7 +4748,7 @@ public final class ExoPlayerTest { /* durationUs= */ Util.msToUs(contentDurationMs), adPlaybackState)); FakeMediaSource adsMediaSource = new FakeMediaSource(adTimeline); - int[] windowIndex = new int[] {C.INDEX_UNSET, C.INDEX_UNSET}; + int[] mediaItemIndex = new int[] {C.INDEX_UNSET, C.INDEX_UNSET}; long[] positionMs = new long[] {C.TIME_UNSET, C.TIME_UNSET}; long[] bufferedPositionMs = new long[] {C.TIME_UNSET, C.TIME_UNSET}; long[] totalBufferedDurationMs = new long[] {C.TIME_UNSET, C.TIME_UNSET}; @@ -4763,8 +4763,8 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - player.seekTo(/* windowIndex= */ 0, /* positionMs= */ 8000); - windowIndex[0] = player.getCurrentWindowIndex(); + player.seekTo(/* mediaItemIndex= */ 0, /* positionMs= */ 8000); + mediaItemIndex[0] = player.getCurrentMediaItemIndex(); isPlayingAd[0] = player.isPlayingAd(); positionMs[0] = player.getCurrentPosition(); bufferedPositionMs[0] = player.getBufferedPosition(); @@ -4776,7 +4776,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - windowIndex[1] = player.getCurrentWindowIndex(); + mediaItemIndex[1] = player.getCurrentMediaItemIndex(); isPlayingAd[1] = player.isPlayingAd(); positionMs[1] = player.getCurrentPosition(); bufferedPositionMs[1] = player.getBufferedPosition(); @@ -4794,13 +4794,13 @@ public final class ExoPlayerTest { .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertThat(windowIndex[0]).isEqualTo(0); + assertThat(mediaItemIndex[0]).isEqualTo(0); assertThat(isPlayingAd[0]).isTrue(); assertThat(positionMs[0]).isEqualTo(0); assertThat(bufferedPositionMs[0]).isEqualTo(adDurationMs); assertThat(totalBufferedDurationMs[0]).isEqualTo(adDurationMs); - assertThat(windowIndex[1]).isEqualTo(0); + assertThat(mediaItemIndex[1]).isEqualTo(0); assertThat(isPlayingAd[1]).isTrue(); assertThat(positionMs[1]).isEqualTo(0); assertThat(bufferedPositionMs[1]).isEqualTo(adDurationMs); @@ -5342,7 +5342,7 @@ public final class ExoPlayerTest { .addMediaSources(new FakeMediaSource()) .executeRunnable( new PlaybackStateCollector(/* index= */ 3, playbackStates, timelineWindowCounts)) - .seek(/* windowIndex= */ 1, /* positionMs= */ 2000) + .seek(/* mediaItemIndex= */ 1, /* positionMs= */ 2000) .prepare() // The first expected buffering state arrives after prepare but not before. .waitForPlaybackState(Player.STATE_BUFFERING) @@ -5512,7 +5512,7 @@ public final class ExoPlayerTest { @Test public void prepareWithInvalidInitialSeek_expectEndedImmediately() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET}; + final int[] currentMediaItemIndices = {C.INDEX_UNSET}; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .waitForPlaybackState(Player.STATE_ENDED) @@ -5520,7 +5520,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); } }) .prepare() @@ -5528,7 +5528,7 @@ public final class ExoPlayerTest { ExoPlayerTestRunner exoPlayerTestRunner = new ExoPlayerTestRunner.Builder(context) .skipSettingMediaSources() - .initialSeek(/* windowIndex= */ 1, C.TIME_UNSET) + .initialSeek(/* mediaItemIndex= */ 1, C.TIME_UNSET) .setActionSchedule(actionSchedule) .build() .start() @@ -5538,7 +5538,7 @@ public final class ExoPlayerTest { exoPlayerTestRunner.assertPlaybackStatesEqual(Player.STATE_ENDED); exoPlayerTestRunner.assertTimelinesSame(); exoPlayerTestRunner.assertTimelineChangeReasonsEqual(); - assertArrayEquals(new int[] {1}, currentWindowIndices); + assertArrayEquals(new int[] {1}, currentMediaItemIndices); } @Test @@ -5574,9 +5574,9 @@ public final class ExoPlayerTest { /* isAtomic= */ false, new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT)); - int[] currentWindowIndices = new int[1]; + int[] currentMediaItemIndices = new int[1]; long[] currentPlaybackPositions = new long[1]; - int seekToWindowIndex = 1; + int seekToMediaItemIndex = 1; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .waitForPlaybackState(Player.STATE_BUFFERING) @@ -5585,21 +5585,21 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); currentPlaybackPositions[0] = player.getCurrentPosition(); } }) .build(); new ExoPlayerTestRunner.Builder(context) .setMediaSources(concatenatingMediaSource) - .initialSeek(seekToWindowIndex, 5000) + .initialSeek(seekToMediaItemIndex, 5000) .setActionSchedule(actionSchedule) .build() .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); assertArrayEquals(new long[] {5_000}, currentPlaybackPositions); - assertArrayEquals(new int[] {seekToWindowIndex}, currentWindowIndices); + assertArrayEquals(new int[] {seekToMediaItemIndex}, currentMediaItemIndices); } @Test @@ -5610,10 +5610,10 @@ public final class ExoPlayerTest { /* isSeekable= */ true, /* isDynamic= */ false, /* durationUs= */ 10_000_000)); ConcatenatingMediaSource concatenatingMediaSource = new ConcatenatingMediaSource(/* isAtomic= */ false); - int[] currentWindowIndices = new int[2]; + int[] currentMediaItemIndices = new int[2]; long[] currentPlaybackPositions = new long[2]; long[] windowCounts = new long[2]; - int seekToWindowIndex = 1; + int seekToMediaItemIndex = 1; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .waitForPlaybackState(Player.STATE_ENDED) @@ -5621,7 +5621,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); currentPlaybackPositions[0] = player.getCurrentPosition(); windowCounts[0] = player.getCurrentTimeline().getWindowCount(); } @@ -5637,7 +5637,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); currentPlaybackPositions[1] = player.getCurrentPosition(); windowCounts[1] = player.getCurrentTimeline().getWindowCount(); } @@ -5645,14 +5645,15 @@ public final class ExoPlayerTest { .build(); new ExoPlayerTestRunner.Builder(context) .setMediaSources(concatenatingMediaSource) - .initialSeek(seekToWindowIndex, 5000) + .initialSeek(seekToMediaItemIndex, 5000) .setActionSchedule(actionSchedule) .build() .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); assertArrayEquals(new long[] {0, 2}, windowCounts); - assertArrayEquals(new int[] {seekToWindowIndex, seekToWindowIndex}, currentWindowIndices); + assertArrayEquals( + new int[] {seekToMediaItemIndex, seekToMediaItemIndex}, currentMediaItemIndices); assertArrayEquals(new long[] {5_000, 5_000}, currentPlaybackPositions); } @@ -5681,10 +5682,10 @@ public final class ExoPlayerTest { /* isSeekable= */ true, /* isDynamic= */ false, /* durationUs= */ 10_000_000)); ConcatenatingMediaSource concatenatingMediaSource = new ConcatenatingMediaSource(/* isAtomic= */ false); - int[] currentWindowIndices = new int[2]; + int[] currentMediaItemIndices = new int[2]; long[] currentPlaybackPositions = new long[2]; long[] windowCounts = new long[2]; - int seekToWindowIndex = 1; + int seekToMediaItemIndex = 1; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .waitForPlaybackState(Player.STATE_ENDED) @@ -5692,7 +5693,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); currentPlaybackPositions[0] = player.getCurrentPosition(); windowCounts[0] = player.getCurrentTimeline().getWindowCount(); } @@ -5708,7 +5709,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); currentPlaybackPositions[1] = player.getCurrentPosition(); windowCounts[1] = player.getCurrentTimeline().getWindowCount(); } @@ -5717,14 +5718,15 @@ public final class ExoPlayerTest { new ExoPlayerTestRunner.Builder(context) .setMediaSources(concatenatingMediaSource) .setUseLazyPreparation(/* useLazyPreparation= */ true) - .initialSeek(seekToWindowIndex, 5000) + .initialSeek(seekToMediaItemIndex, 5000) .setActionSchedule(actionSchedule) .build() .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); assertArrayEquals(new long[] {0, 2}, windowCounts); - assertArrayEquals(new int[] {seekToWindowIndex, seekToWindowIndex}, currentWindowIndices); + assertArrayEquals( + new int[] {seekToMediaItemIndex, seekToMediaItemIndex}, currentMediaItemIndices); assertArrayEquals(new long[] {5_000, 5_000}, currentPlaybackPositions); } @@ -5885,19 +5887,19 @@ public final class ExoPlayerTest { } @Test - public void setMediaSources_empty_whenEmpty_correctMaskingWindowIndex() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + public void setMediaSources_empty_whenEmpty_correctMaskingMediaItemIndex() throws Exception { + final int[] currentMediaItemIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .executeRunnable( new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); List listOfTwo = ImmutableList.of(new FakeMediaSource(), new FakeMediaSource()); player.addMediaSources(/* index= */ 0, listOfTwo); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); } }) .prepare() @@ -5906,7 +5908,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[2] = player.getCurrentWindowIndex(); + currentMediaItemIndices[2] = player.getCurrentMediaItemIndex(); } }) .build(); @@ -5917,12 +5919,12 @@ public final class ExoPlayerTest { .start(/* doPrepare= */ false) .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {0, 0, 0}, currentWindowIndices); + assertArrayEquals(new int[] {0, 0, 0}, currentMediaItemIndices); } @Test public void setMediaItems_resetPosition_resetsPosition() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] currentMediaItemIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] currentPositions = {C.INDEX_UNSET, C.INDEX_UNSET}; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) @@ -5931,14 +5933,14 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - player.seekTo(/* windowIndex= */ 1, /* positionMs= */ 1000); - currentWindowIndices[0] = player.getCurrentWindowIndex(); + player.seekTo(/* mediaItemIndex= */ 1, /* positionMs= */ 1000); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); currentPositions[0] = player.getCurrentPosition(); List listOfTwo = ImmutableList.of( MediaItem.fromUri(Uri.EMPTY), MediaItem.fromUri(Uri.EMPTY)); player.setMediaItems(listOfTwo, /* resetPosition= */ true); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); currentPositions[1] = player.getCurrentPosition(); } }) @@ -5952,14 +5954,14 @@ public final class ExoPlayerTest { .start(/* doPrepare= */ false) .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {1, 0}, currentWindowIndices); + assertArrayEquals(new int[] {1, 0}, currentMediaItemIndices); assertArrayEquals(new long[] {1000, 0}, currentPositions); } @Test - public void setMediaSources_empty_whenEmpty_validInitialSeek_correctMaskingWindowIndex() + public void setMediaSources_empty_whenEmpty_validInitialSeek_correctMaskingMediaItemIndex() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] currentMediaItemIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) // Wait for initial seek to be fully handled by internal player. @@ -5969,11 +5971,11 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); List listOfTwo = ImmutableList.of(new FakeMediaSource(), new FakeMediaSource()); player.addMediaSources(/* index= */ 0, listOfTwo); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); } }) .prepare() @@ -5982,25 +5984,25 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[2] = player.getCurrentWindowIndex(); + currentMediaItemIndices[2] = player.getCurrentMediaItemIndex(); } }) .build(); new ExoPlayerTestRunner.Builder(context) - .initialSeek(/* windowIndex= */ 1, C.TIME_UNSET) + .initialSeek(/* mediaItemIndex= */ 1, C.TIME_UNSET) .setMediaSources(new ConcatenatingMediaSource()) .setActionSchedule(actionSchedule) .build() .start(/* doPrepare= */ false) .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {1, 1, 1}, currentWindowIndices); + assertArrayEquals(new int[] {1, 1, 1}, currentMediaItemIndices); } @Test - public void setMediaSources_empty_whenEmpty_invalidInitialSeek_correctMaskingWindowIndex() + public void setMediaSources_empty_whenEmpty_invalidInitialSeek_correctMaskingMediaItemIndex() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] currentMediaItemIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) // Wait for initial seek to be fully handled by internal player. @@ -6010,11 +6012,11 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); List listOfTwo = ImmutableList.of(new FakeMediaSource(), new FakeMediaSource()); player.addMediaSources(/* index= */ 0, listOfTwo); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); } }) .prepare() @@ -6023,24 +6025,26 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[2] = player.getCurrentWindowIndex(); + currentMediaItemIndices[2] = player.getCurrentMediaItemIndex(); } }) .build(); new ExoPlayerTestRunner.Builder(context) - .initialSeek(/* windowIndex= */ 4, C.TIME_UNSET) + .initialSeek(/* mediaItemIndex= */ 4, C.TIME_UNSET) .setMediaSources(new ConcatenatingMediaSource()) .setActionSchedule(actionSchedule) .build() .start(/* doPrepare= */ false) .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {4, 0, 0}, currentWindowIndices); + assertArrayEquals(new int[] {4, 0, 0}, currentMediaItemIndices); } @Test - public void setMediaSources_whenEmpty_correctMaskingWindowIndex() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + public void setMediaSources_whenEmpty_correctMaskingMediaItemIndex() throws Exception { + final int[] currentMediaItemIndices = { + C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET + }; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .waitForPlaybackState(Player.STATE_READY) @@ -6048,18 +6052,18 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - // Increase current window index. + // Increase current media item index. player.addMediaSource(/* index= */ 0, new FakeMediaSource()); - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); } }) .executeRunnable( new PlayerRunnable() { @Override public void run(ExoPlayer player) { - // Current window index is unchanged. + // Current media item index is unchanged. player.addMediaSource(/* index= */ 2, new FakeMediaSource()); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); } }) .executeRunnable( @@ -6069,9 +6073,9 @@ public final class ExoPlayerTest { MediaSource mediaSource = new FakeMediaSource(); ConcatenatingMediaSource concatenatingMediaSource = new ConcatenatingMediaSource(mediaSource, mediaSource, mediaSource); - // Increase current window with multi window source. + // Increase current media item with multi media item source. player.addMediaSource(/* index= */ 0, concatenatingMediaSource); - currentWindowIndices[2] = player.getCurrentWindowIndex(); + currentMediaItemIndices[2] = player.getCurrentMediaItemIndex(); } }) .executeRunnable( @@ -6080,9 +6084,9 @@ public final class ExoPlayerTest { public void run(ExoPlayer player) { ConcatenatingMediaSource concatenatingMediaSource = new ConcatenatingMediaSource(); - // Current window index is unchanged when adding empty source. + // Current media item index is unchanged when adding empty source. player.addMediaSource(/* index= */ 0, concatenatingMediaSource); - currentWindowIndices[3] = player.getCurrentWindowIndex(); + currentMediaItemIndices[3] = player.getCurrentMediaItemIndex(); } }) .build(); @@ -6093,7 +6097,7 @@ public final class ExoPlayerTest { .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {1, 1, 4, 4}, currentWindowIndices); + assertArrayEquals(new int[] {1, 1, 4, 4}, currentMediaItemIndices); } @Test @@ -6102,7 +6106,7 @@ public final class ExoPlayerTest { MediaSource firstMediaSource = new FakeMediaSource(firstTimeline); Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1, new Object()); MediaSource secondMediaSource = new FakeMediaSource(secondTimeline); - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] currentMediaItemIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; final long[] currentPositions = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; final long[] bufferedPositions = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; ActionSchedule actionSchedule = @@ -6114,12 +6118,12 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); currentPositions[0] = player.getCurrentPosition(); bufferedPositions[0] = player.getBufferedPosition(); - // Increase current window index. + // Increase current media item index. player.addMediaSource(/* index= */ 0, secondMediaSource); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); currentPositions[1] = player.getCurrentPosition(); bufferedPositions[1] = player.getBufferedPosition(); } @@ -6130,28 +6134,28 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[2] = player.getCurrentWindowIndex(); + currentMediaItemIndices[2] = player.getCurrentMediaItemIndex(); currentPositions[2] = player.getCurrentPosition(); bufferedPositions[2] = player.getBufferedPosition(); } }) .build(); new ExoPlayerTestRunner.Builder(context) - .initialSeek(/* windowIndex= */ 1, 2000) + .initialSeek(/* mediaItemIndex= */ 1, 2000) .setMediaSources(firstMediaSource) .setActionSchedule(actionSchedule) .build() .start(/* doPrepare= */ false) .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {1, 2, 2}, currentWindowIndices); + assertArrayEquals(new int[] {1, 2, 2}, currentMediaItemIndices); assertArrayEquals(new long[] {2000, 2000, 2000}, currentPositions); assertArrayEquals(new long[] {2000, 2000, 2000}, bufferedPositions); } @Test public void setMediaSources_whenEmpty_invalidInitialSeek_correctMasking() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] currentMediaItemIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; final long[] currentPositions = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; final long[] bufferedPositions = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; ActionSchedule actionSchedule = @@ -6163,12 +6167,12 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); currentPositions[0] = player.getCurrentPosition(); bufferedPositions[0] = player.getBufferedPosition(); - // Increase current window index. + // Increase current media item index. player.addMediaSource(/* index= */ 0, new FakeMediaSource()); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); currentPositions[1] = player.getCurrentPosition(); bufferedPositions[1] = player.getBufferedPosition(); } @@ -6179,7 +6183,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[2] = player.getCurrentWindowIndex(); + currentMediaItemIndices[2] = player.getCurrentMediaItemIndex(); currentPositions[2] = player.getCurrentPosition(); bufferedPositions[2] = player.getBufferedPosition(); } @@ -6187,21 +6191,21 @@ public final class ExoPlayerTest { .waitForPlaybackState(Player.STATE_ENDED) .build(); new ExoPlayerTestRunner.Builder(context) - .initialSeek(/* windowIndex= */ 1, 2000) + .initialSeek(/* mediaItemIndex= */ 1, 2000) .setMediaSources(new FakeMediaSource()) .setActionSchedule(actionSchedule) .build() .start(/* doPrepare= */ false) .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {0, 1, 1}, currentWindowIndices); + assertArrayEquals(new int[] {0, 1, 1}, currentMediaItemIndices); assertArrayEquals(new long[] {0, 0, 0}, currentPositions); assertArrayEquals(new long[] {0, 0, 0}, bufferedPositions); } @Test - public void setMediaSources_correctMaskingWindowIndex() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + public void setMediaSources_correctMaskingMediaItemIndex() throws Exception { + final int[] currentMediaItemIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .waitForTimelineChanged() @@ -6209,10 +6213,10 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); - // Increase current window index. + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); + // Increase current media item index. player.addMediaSource(/* index= */ 0, new FakeMediaSource()); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); } }) .waitForTimelineChanged() @@ -6220,7 +6224,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[2] = player.getCurrentWindowIndex(); + currentMediaItemIndices[2] = player.getCurrentMediaItemIndex(); } }) .build(); @@ -6231,7 +6235,7 @@ public final class ExoPlayerTest { .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {0, 1, 1}, currentWindowIndices); + assertArrayEquals(new int[] {0, 1, 1}, currentMediaItemIndices); } @Test @@ -6288,7 +6292,7 @@ public final class ExoPlayerTest { .start(/* doPrepare= */ false) .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - // Expect reset of masking to first window. + // Expect reset of masking to first media item. exoPlayerTestRunner.assertPlaybackStatesEqual(Player.STATE_ENDED); assertArrayEquals( new int[] {Player.STATE_IDLE, Player.STATE_IDLE, Player.STATE_IDLE, Player.STATE_IDLE}, @@ -6324,14 +6328,14 @@ public final class ExoPlayerTest { .build(); ExoPlayerTestRunner exoPlayerTestRunner = new ExoPlayerTestRunner.Builder(context) - .initialSeek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET) + .initialSeek(/* mediaItemIndex= */ 1, /* positionMs= */ C.TIME_UNSET) .setMediaSources(new ConcatenatingMediaSource()) .setActionSchedule(actionSchedule) .build() .start(/* doPrepare= */ false) .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - // Expect reset of masking to first window. + // Expect reset of masking to first media item. exoPlayerTestRunner.assertPlaybackStatesEqual( Player.STATE_BUFFERING, Player.STATE_READY, Player.STATE_ENDED); assertArrayEquals(new int[] {Player.STATE_IDLE}, maskingPlaybackStates); @@ -6366,7 +6370,7 @@ public final class ExoPlayerTest { .start(/* doPrepare= */ false) .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - // Expect reset of masking to first window. + // Expect reset of masking to first media item. exoPlayerTestRunner.assertPlaybackStatesEqual( Player.STATE_BUFFERING, Player.STATE_READY, Player.STATE_ENDED); assertArrayEquals(new int[] {Player.STATE_IDLE}, maskingPlaybackStates); @@ -6402,7 +6406,7 @@ public final class ExoPlayerTest { .start(/* doPrepare= */ false) .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - // Expect reset of masking to first window. + // Expect reset of masking to first media item. exoPlayerTestRunner.assertPlaybackStatesEqual( Player.STATE_BUFFERING, Player.STATE_READY, Player.STATE_ENDED); assertArrayEquals(new int[] {Player.STATE_IDLE}, maskingPlaybackStates); @@ -6474,7 +6478,7 @@ public final class ExoPlayerTest { .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - // Expect reset of masking to first window. + // Expect reset of masking to first media item. exoPlayerTestRunner.assertPlaybackStatesEqual( Player.STATE_ENDED, Player.STATE_BUFFERING, @@ -6519,14 +6523,14 @@ public final class ExoPlayerTest { .build(); ExoPlayerTestRunner exoPlayerTestRunner = new ExoPlayerTestRunner.Builder(context) - .initialSeek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET) + .initialSeek(/* mediaItemIndex= */ 1, /* positionMs= */ C.TIME_UNSET) .setMediaSources(new ConcatenatingMediaSource()) .setActionSchedule(actionSchedule) .build() .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - // Expect reset of masking to first window. + // Expect reset of masking to first media item. exoPlayerTestRunner.assertPlaybackStatesEqual(Player.STATE_ENDED); assertArrayEquals(new int[] {Player.STATE_ENDED}, maskingPlaybackStates); exoPlayerTestRunner.assertTimelineChangeReasonsEqual( @@ -6562,7 +6566,7 @@ public final class ExoPlayerTest { .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - // Expect reset of masking to first window. + // Expect reset of masking to first media item. exoPlayerTestRunner.assertPlaybackStatesEqual( Player.STATE_BUFFERING, Player.STATE_READY, Player.STATE_ENDED); assertArrayEquals(new int[] {Player.STATE_ENDED}, maskingPlaybackStates); @@ -6601,7 +6605,7 @@ public final class ExoPlayerTest { .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - // Expect reset of masking to first window. + // Expect reset of masking to first media item. exoPlayerTestRunner.assertPlaybackStatesEqual( Player.STATE_BUFFERING, Player.STATE_READY, Player.STATE_ENDED); assertArrayEquals(new int[] {Player.STATE_ENDED}, maskingPlaybackStates); @@ -6635,7 +6639,8 @@ public final class ExoPlayerTest { } }) .waitForPlaybackState(Player.STATE_ENDED) - .setMediaSources(/* windowIndex= */ 0, /* positionMs= */ C.TIME_UNSET, firstMediaSource) + .setMediaSources( + /* mediaItemIndex= */ 0, /* positionMs= */ C.TIME_UNSET, firstMediaSource) .waitForPlaybackState(Player.STATE_READY) .executeRunnable( new PlayerRunnable() { @@ -6649,7 +6654,8 @@ public final class ExoPlayerTest { } }) .waitForPlaybackState(Player.STATE_ENDED) - .setMediaSources(/* windowIndex= */ 0, /* positionMs= */ C.TIME_UNSET, firstMediaSource) + .setMediaSources( + /* mediaItemIndex= */ 0, /* positionMs= */ C.TIME_UNSET, firstMediaSource) .waitForPlaybackState(Player.STATE_READY) .executeRunnable( new PlayerRunnable() { @@ -6662,7 +6668,8 @@ public final class ExoPlayerTest { } }) .waitForPlaybackState(Player.STATE_READY) - .setMediaSources(/* windowIndex= */ 0, /* positionMs= */ C.TIME_UNSET, firstMediaSource) + .setMediaSources( + /* mediaItemIndex= */ 0, /* positionMs= */ C.TIME_UNSET, firstMediaSource) .waitForPlaybackState(Player.STATE_READY) .executeRunnable( new PlayerRunnable() { @@ -6686,7 +6693,7 @@ public final class ExoPlayerTest { .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - // Expect reset of masking to first window. + // Expect reset of masking to first media item. exoPlayerTestRunner.assertPlaybackStatesEqual( Player.STATE_BUFFERING, Player.STATE_READY, // Ready after initial prepare. @@ -6747,7 +6754,8 @@ public final class ExoPlayerTest { } }) .waitForTimelineChanged() - .setMediaSources(/* windowIndex= */ 0, /* positionMs= */ C.TIME_UNSET, firstMediaSource) + .setMediaSources( + /* mediaItemIndex= */ 0, /* positionMs= */ C.TIME_UNSET, firstMediaSource) .waitForPlaybackState(Player.STATE_READY) .play() .waitForPlaybackState(Player.STATE_ENDED) @@ -6755,14 +6763,14 @@ public final class ExoPlayerTest { ExoPlayerTestRunner exoPlayerTestRunner = new ExoPlayerTestRunner.Builder(context) .setExpectedPlayerEndedCount(/* expectedPlayerEndedCount= */ 2) - .initialSeek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET) + .initialSeek(/* mediaItemIndex= */ 1, /* positionMs= */ C.TIME_UNSET) .setMediaSources(new ConcatenatingMediaSource()) .setActionSchedule(actionSchedule) .build() .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - // Expect reset of masking to first window. + // Expect reset of masking to first media item. exoPlayerTestRunner.assertPlaybackStatesEqual( Player.STATE_ENDED, // Empty source has been prepared. Player.STATE_BUFFERING, // After setting another source. @@ -6798,7 +6806,7 @@ public final class ExoPlayerTest { .build(); new ExoPlayerTestRunner.Builder(context) .skipSettingMediaSources() - .initialSeek(/* windowIndex= */ 0, /* positionMs= */ 2000) + .initialSeek(/* mediaItemIndex= */ 0, /* positionMs= */ 2000) .setActionSchedule(actionSchedule) .build() .start(/* doPrepare= */ false) @@ -6810,8 +6818,8 @@ public final class ExoPlayerTest { @Test public void addMediaSources_skipSettingMediaItems_validInitialSeek_correctMasking() throws Exception { - final int[] currentWindowIndices = new int[5]; - Arrays.fill(currentWindowIndices, C.INDEX_UNSET); + final int[] currentMediaItemIndices = new int[5]; + Arrays.fill(currentMediaItemIndices, C.INDEX_UNSET); final long[] currentPositions = new long[3]; Arrays.fill(currentPositions, C.TIME_UNSET); final long[] bufferedPositions = new long[3]; @@ -6825,18 +6833,18 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); // If the timeline is empty masking variables are used. currentPositions[0] = player.getCurrentPosition(); bufferedPositions[0] = player.getBufferedPosition(); player.addMediaSource(/* index= */ 0, new ConcatenatingMediaSource()); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); player.addMediaSource( /* index= */ 0, new FakeMediaSource(new FakeTimeline(/* windowCount= */ 2))); - currentWindowIndices[2] = player.getCurrentWindowIndex(); + currentMediaItemIndices[2] = player.getCurrentMediaItemIndex(); player.addMediaSource(/* index= */ 0, new FakeMediaSource()); - currentWindowIndices[3] = player.getCurrentWindowIndex(); + currentMediaItemIndices[3] = player.getCurrentMediaItemIndex(); // With a non-empty timeline, we mask the periodId in the playback info. currentPositions[1] = player.getCurrentPosition(); bufferedPositions[1] = player.getBufferedPosition(); @@ -6848,7 +6856,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[4] = player.getCurrentWindowIndex(); + currentMediaItemIndices[4] = player.getCurrentMediaItemIndex(); // Finally original playbackInfo coming from EPII is used. currentPositions[2] = player.getCurrentPosition(); bufferedPositions[2] = player.getBufferedPosition(); @@ -6857,13 +6865,13 @@ public final class ExoPlayerTest { .build(); new ExoPlayerTestRunner.Builder(context) .skipSettingMediaSources() - .initialSeek(/* windowIndex= */ 1, 2000) + .initialSeek(/* mediaItemIndex= */ 1, 2000) .setActionSchedule(actionSchedule) .build() .start(/* doPrepare= */ false) .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {1, 1, 1, 2, 2}, currentWindowIndices); + assertArrayEquals(new int[] {1, 1, 1, 2, 2}, currentMediaItemIndices); assertThat(currentPositions[0]).isEqualTo(2000); assertThat(currentPositions[1]).isEqualTo(2000); assertThat(currentPositions[2]).isAtLeast(2000); @@ -6874,9 +6882,9 @@ public final class ExoPlayerTest { @Test public void - testAddMediaSources_skipSettingMediaItems_invalidInitialSeek_correctMaskingWindowIndex() + testAddMediaSources_skipSettingMediaItems_invalidInitialSeek_correctMaskingMediaItemIndex() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] currentMediaItemIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) // Wait for initial seek to be fully handled by internal player. @@ -6886,9 +6894,9 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); player.addMediaSource(new FakeMediaSource()); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); } }) .prepare() @@ -6897,28 +6905,28 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[2] = player.getCurrentWindowIndex(); + currentMediaItemIndices[2] = player.getCurrentMediaItemIndex(); } }) .build(); new ExoPlayerTestRunner.Builder(context) .skipSettingMediaSources() - .initialSeek(/* windowIndex= */ 1, C.TIME_UNSET) + .initialSeek(/* mediaItemIndex= */ 1, C.TIME_UNSET) .setActionSchedule(actionSchedule) .build() .start(/* doPrepare= */ false) .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {1, 0, 0}, currentWindowIndices); + assertArrayEquals(new int[] {1, 0, 0}, currentMediaItemIndices); } @Test - public void moveMediaItems_correctMaskingWindowIndex() throws Exception { + public void moveMediaItems_correctMaskingMediaItemIndex() throws Exception { Timeline timeline = new FakeTimeline(); MediaSource firstMediaSource = new FakeMediaSource(timeline); MediaSource secondMediaSource = new FakeMediaSource(timeline); MediaSource thirdMediaSource = new FakeMediaSource(timeline); - final int[] currentWindowIndices = { + final int[] currentMediaItemIndices = { C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET }; ActionSchedule actionSchedule = @@ -6930,7 +6938,7 @@ public final class ExoPlayerTest { public void run(ExoPlayer player) { // Move the current item down in the playlist. player.moveMediaItems(/* fromIndex= */ 0, /* toIndex= */ 2, /* newIndex= */ 1); - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); } }) .executeRunnable( @@ -6939,17 +6947,17 @@ public final class ExoPlayerTest { public void run(ExoPlayer player) { // Move the current item up in the playlist. player.moveMediaItems(/* fromIndex= */ 1, /* toIndex= */ 3, /* newIndex= */ 0); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); } }) - .seek(/* windowIndex= */ 2, C.TIME_UNSET) + .seek(/* mediaItemIndex= */ 2, C.TIME_UNSET) .executeRunnable( new PlayerRunnable() { @Override public void run(ExoPlayer player) { // Move items from before to behind the current item. player.moveMediaItems(/* fromIndex= */ 0, /* toIndex= */ 2, /* newIndex= */ 1); - currentWindowIndices[2] = player.getCurrentWindowIndex(); + currentMediaItemIndices[2] = player.getCurrentMediaItemIndex(); } }) .executeRunnable( @@ -6958,7 +6966,7 @@ public final class ExoPlayerTest { public void run(ExoPlayer player) { // Move items from behind to before the current item. player.moveMediaItems(/* fromIndex= */ 1, /* toIndex= */ 3, /* newIndex= */ 0); - currentWindowIndices[3] = player.getCurrentWindowIndex(); + currentMediaItemIndices[3] = player.getCurrentMediaItemIndex(); } }) .executeRunnable( @@ -6966,20 +6974,20 @@ public final class ExoPlayerTest { @Override public void run(ExoPlayer player) { // Move items from before to before the current item. - // No change in currentWindowIndex. + // No change in currentMediaItemIndex. player.moveMediaItems(/* fromIndex= */ 0, /* toIndex= */ 1, /* newIndex= */ 1); - currentWindowIndices[4] = player.getCurrentWindowIndex(); + currentMediaItemIndices[4] = player.getCurrentMediaItemIndex(); } }) - .seek(/* windowIndex= */ 0, C.TIME_UNSET) + .seek(/* mediaItemIndex= */ 0, C.TIME_UNSET) .executeRunnable( new PlayerRunnable() { @Override public void run(ExoPlayer player) { // Move items from behind to behind the current item. - // No change in currentWindowIndex. + // No change in currentMediaItemIndex. player.moveMediaItems(/* fromIndex= */ 1, /* toIndex= */ 2, /* newIndex= */ 2); - currentWindowIndices[5] = player.getCurrentWindowIndex(); + currentMediaItemIndices[5] = player.getCurrentMediaItemIndex(); } }) .build(); @@ -6990,12 +6998,12 @@ public final class ExoPlayerTest { .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {1, 0, 0, 2, 2, 0}, currentWindowIndices); + assertArrayEquals(new int[] {1, 0, 0, 2, 2, 0}, currentMediaItemIndices); } @Test - public void moveMediaItems_unprepared_correctMaskingWindowIndex() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; + public void moveMediaItems_unprepared_correctMaskingMediaItemIndex() throws Exception { + final int[] currentMediaItemIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .waitForTimelineChanged() @@ -7003,10 +7011,10 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - // Increase current window index. - currentWindowIndices[0] = player.getCurrentWindowIndex(); + // Increase current media item index. + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); player.moveMediaItem(/* currentIndex= */ 0, /* newIndex= */ 1); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); } }) .prepare() @@ -7015,7 +7023,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[2] = player.getCurrentWindowIndex(); + currentMediaItemIndices[2] = player.getCurrentMediaItemIndex(); } }) .build(); @@ -7026,12 +7034,12 @@ public final class ExoPlayerTest { .start(/* doPrepare= */ false) .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {0, 1, 1}, currentWindowIndices); + assertArrayEquals(new int[] {0, 1, 1}, currentMediaItemIndices); } @Test - public void removeMediaItems_correctMaskingWindowIndex() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; + public void removeMediaItems_correctMaskingMediaItemIndex() throws Exception { + final int[] currentMediaItemIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .waitForPlaybackState(Player.STATE_BUFFERING) @@ -7039,27 +7047,27 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - // Decrease current window index. - currentWindowIndices[0] = player.getCurrentWindowIndex(); + // Decrease current media item index. + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); player.removeMediaItem(/* index= */ 0); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); } }) .build(); new ExoPlayerTestRunner.Builder(context) - .initialSeek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET) + .initialSeek(/* mediaItemIndex= */ 1, /* positionMs= */ C.TIME_UNSET) .setMediaSources(new FakeMediaSource(), new FakeMediaSource()) .setActionSchedule(actionSchedule) .build() .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {1, 0}, currentWindowIndices); + assertArrayEquals(new int[] {1, 0}, currentMediaItemIndices); } @Test public void removeMediaItems_currentItemRemoved_correctMasking() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] currentMediaItemIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; final long[] currentPositions = {C.TIME_UNSET, C.TIME_UNSET}; final long[] bufferedPositions = {C.TIME_UNSET, C.TIME_UNSET}; ActionSchedule actionSchedule = @@ -7070,25 +7078,25 @@ public final class ExoPlayerTest { @Override public void run(ExoPlayer player) { // Remove the current item. - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); currentPositions[0] = player.getCurrentPosition(); bufferedPositions[0] = player.getBufferedPosition(); player.removeMediaItem(/* index= */ 1); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); currentPositions[1] = player.getCurrentPosition(); bufferedPositions[1] = player.getBufferedPosition(); } }) .build(); new ExoPlayerTestRunner.Builder(context) - .initialSeek(/* windowIndex= */ 1, /* positionMs= */ 5000) + .initialSeek(/* mediaItemIndex= */ 1, /* positionMs= */ 5000) .setMediaSources(new FakeMediaSource(), new FakeMediaSource(), new FakeMediaSource()) .setActionSchedule(actionSchedule) .build() .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {1, 1}, currentWindowIndices); + assertArrayEquals(new int[] {1, 1}, currentMediaItemIndices); assertThat(currentPositions[0]).isAtLeast(5000L); assertThat(bufferedPositions[0]).isAtLeast(5000L); assertThat(currentPositions[1]).isEqualTo(0); @@ -7105,8 +7113,8 @@ public final class ExoPlayerTest { MediaSource thirdMediaSource = new FakeMediaSource(thirdTimeline); Timeline fourthTimeline = new FakeTimeline(/* windowCount= */ 1, 3L); MediaSource fourthMediaSource = new FakeMediaSource(fourthTimeline); - final int[] currentWindowIndices = new int[9]; - Arrays.fill(currentWindowIndices, C.INDEX_UNSET); + final int[] currentMediaItemIndices = new int[9]; + Arrays.fill(currentMediaItemIndices, C.INDEX_UNSET); final int[] maskingPlaybackStates = new int[4]; Arrays.fill(maskingPlaybackStates, C.INDEX_UNSET); final long[] currentPositions = new long[3]; @@ -7121,14 +7129,14 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - // Expect the current window index to be 2 after seek. - currentWindowIndices[0] = player.getCurrentWindowIndex(); + // Expect the current media item index to be 2 after seek. + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); currentPositions[0] = player.getCurrentPosition(); bufferedPositions[0] = player.getBufferedPosition(); player.removeMediaItem(/* index= */ 2); - // Expect the current window index to be 0 + // Expect the current media item index to be 0 // (default position of timeline after not finding subsequent period). - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); // Transition to ENDED. maskingPlaybackStates[0] = player.getPlaybackState(); currentPositions[1] = player.getCurrentPosition(); @@ -7140,12 +7148,12 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - // Expects the current window index still on 0. - currentWindowIndices[2] = player.getCurrentWindowIndex(); + // Expects the current media item index still on 0. + currentMediaItemIndices[2] = player.getCurrentMediaItemIndex(); // Insert an item at begin when the playlist is not empty. player.addMediaSource(/* index= */ 0, thirdMediaSource); - // Expects the current window index to be (0 + 1) after insertion at begin. - currentWindowIndices[3] = player.getCurrentWindowIndex(); + // Expects the current media item index to be (0 + 1) after insertion at begin. + currentMediaItemIndices[3] = player.getCurrentMediaItemIndex(); // Remains in ENDED. maskingPlaybackStates[1] = player.getPlaybackState(); currentPositions[2] = player.getCurrentPosition(); @@ -7157,12 +7165,12 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[4] = player.getCurrentWindowIndex(); - // Implicit seek to the current window index, which is out of bounds in new + currentMediaItemIndices[4] = player.getCurrentMediaItemIndex(); + // Implicit seek to the current media item index, which is out of bounds in new // timeline. player.setMediaSource(fourthMediaSource, /* resetPosition= */ false); // 0 after reset. - currentWindowIndices[5] = player.getCurrentWindowIndex(); + currentMediaItemIndices[5] = player.getCurrentMediaItemIndex(); // Invalid seek, so we remain in ENDED. maskingPlaybackStates[2] = player.getPlaybackState(); } @@ -7172,11 +7180,11 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[6] = player.getCurrentWindowIndex(); + currentMediaItemIndices[6] = player.getCurrentMediaItemIndex(); // Explicit seek to (0, C.TIME_UNSET). Player transitions to BUFFERING. player.setMediaSource(fourthMediaSource, /* startPositionMs= */ 5000); // 0 after explicit seek. - currentWindowIndices[7] = player.getCurrentWindowIndex(); + currentMediaItemIndices[7] = player.getCurrentMediaItemIndex(); // Transitions from ENDED to BUFFERING after explicit seek. maskingPlaybackStates[3] = player.getPlaybackState(); } @@ -7186,14 +7194,14 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - // Check whether actual window index is equal masking index from above. - currentWindowIndices[8] = player.getCurrentWindowIndex(); + // Check whether actual media item index is equal masking index from above. + currentMediaItemIndices[8] = player.getCurrentMediaItemIndex(); } }) .build(); ExoPlayerTestRunner exoPlayerTestRunner = new ExoPlayerTestRunner.Builder(context) - .initialSeek(/* windowIndex= */ 2, /* positionMs= */ C.TIME_UNSET) + .initialSeek(/* mediaItemIndex= */ 2, /* positionMs= */ C.TIME_UNSET) .setExpectedPlayerEndedCount(2) .setMediaSources(firstMediaSource, secondMediaSource, thirdMediaSource) .setActionSchedule(actionSchedule) @@ -7201,23 +7209,23 @@ public final class ExoPlayerTest { .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - // Expect reset of masking to first window. + // Expect reset of masking to first media item. exoPlayerTestRunner.assertPlaybackStatesEqual( Player.STATE_BUFFERING, Player.STATE_READY, // Ready after initial prepare. - Player.STATE_ENDED, // ended after removing current window index + Player.STATE_ENDED, // ended after removing current media item index Player.STATE_BUFFERING, // buffers after set items with seek Player.STATE_READY, Player.STATE_ENDED); assertArrayEquals( new int[] { - Player.STATE_ENDED, // ended after removing current window index + Player.STATE_ENDED, // ended after removing current media item index Player.STATE_ENDED, // adding items does not change state Player.STATE_ENDED, // set items with seek to current position. Player.STATE_BUFFERING }, // buffers after set items with seek maskingPlaybackStates); - assertArrayEquals(new int[] {2, 0, 0, 1, 1, 0, 0, 0, 0}, currentWindowIndices); + assertArrayEquals(new int[] {2, 0, 0, 1, 1, 0, 0, 0, 0}, currentMediaItemIndices); assertThat(currentPositions[0]).isEqualTo(0); assertThat(currentPositions[1]).isEqualTo(0); assertThat(currentPositions[2]).isEqualTo(0); @@ -7231,7 +7239,7 @@ public final class ExoPlayerTest { throws Exception { ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) - .seek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET) + .seek(/* mediaItemIndex= */ 1, /* positionMs= */ C.TIME_UNSET) .waitForPendingPlayerCommands() .removeMediaItem(/* index= */ 1) .prepare() @@ -7251,7 +7259,7 @@ public final class ExoPlayerTest { @Test public void clearMediaItems_correctMasking() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; + final int[] currentMediaItemIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; final int[] maskingPlaybackState = {C.INDEX_UNSET}; final long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET}; final long[] bufferedPosition = {C.TIME_UNSET, C.TIME_UNSET}; @@ -7259,16 +7267,16 @@ public final class ExoPlayerTest { new ActionSchedule.Builder(TAG) .pause() .waitForPlaybackState(Player.STATE_BUFFERING) - .playUntilPosition(/* windowIndex= */ 1, /* positionMs= */ 150) + .playUntilPosition(/* mediaItemIndex= */ 1, /* positionMs= */ 150) .executeRunnable( new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); currentPosition[0] = player.getCurrentPosition(); bufferedPosition[0] = player.getBufferedPosition(); player.clearMediaItems(); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); currentPosition[1] = player.getCurrentPosition(); bufferedPosition[1] = player.getBufferedPosition(); maskingPlaybackState[0] = player.getPlaybackState(); @@ -7276,25 +7284,25 @@ public final class ExoPlayerTest { }) .build(); new ExoPlayerTestRunner.Builder(context) - .initialSeek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET) + .initialSeek(/* mediaItemIndex= */ 1, /* positionMs= */ C.TIME_UNSET) .setMediaSources(new FakeMediaSource(), new FakeMediaSource()) .setActionSchedule(actionSchedule) .build() .start() .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertArrayEquals(new int[] {1, 0}, currentWindowIndices); + assertArrayEquals(new int[] {1, 0}, currentMediaItemIndices); assertThat(currentPosition[0]).isAtLeast(150); assertThat(currentPosition[1]).isEqualTo(0); assertThat(bufferedPosition[0]).isAtLeast(150); assertThat(bufferedPosition[1]).isEqualTo(0); - assertArrayEquals(new int[] {1, 0}, currentWindowIndices); + assertArrayEquals(new int[] {1, 0}, currentMediaItemIndices); assertArrayEquals(new int[] {Player.STATE_ENDED}, maskingPlaybackState); } @Test - public void clearMediaItems_unprepared_correctMaskingWindowIndex_notEnded() throws Exception { - final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; + public void clearMediaItems_unprepared_correctMaskingMediaItemIndex_notEnded() throws Exception { + final int[] currentMediaItemIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentStates = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) @@ -7305,10 +7313,10 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - currentWindowIndices[0] = player.getCurrentWindowIndex(); + currentMediaItemIndices[0] = player.getCurrentMediaItemIndex(); currentStates[0] = player.getPlaybackState(); player.clearMediaItems(); - currentWindowIndices[1] = player.getCurrentWindowIndex(); + currentMediaItemIndices[1] = player.getCurrentMediaItemIndex(); currentStates[1] = player.getPlaybackState(); } }) @@ -7323,7 +7331,7 @@ public final class ExoPlayerTest { }) .build(); new ExoPlayerTestRunner.Builder(context) - .initialSeek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET) + .initialSeek(/* mediaItemIndex= */ 1, /* positionMs= */ C.TIME_UNSET) .setMediaSources(new FakeMediaSource(), new FakeMediaSource()) .setActionSchedule(actionSchedule) .build() @@ -7332,7 +7340,7 @@ public final class ExoPlayerTest { .blockUntilEnded(TIMEOUT_MS); assertArrayEquals( new int[] {Player.STATE_IDLE, Player.STATE_IDLE, Player.STATE_ENDED}, currentStates); - assertArrayEquals(new int[] {1, 0}, currentWindowIndices); + assertArrayEquals(new int[] {1, 0}, currentMediaItemIndices); } @Test @@ -7361,7 +7369,7 @@ public final class ExoPlayerTest { AtomicReference timelineAfterError = new AtomicReference<>(); AtomicReference trackInfosAfterError = new AtomicReference<>(); AtomicReference trackSelectionsAfterError = new AtomicReference<>(); - AtomicInteger windowIndexAfterError = new AtomicInteger(); + AtomicInteger mediaItemIndexAfterError = new AtomicInteger(); ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .executeRunnable( @@ -7375,7 +7383,7 @@ public final class ExoPlayerTest { timelineAfterError.set(player.getCurrentTimeline()); trackInfosAfterError.set(player.getCurrentTracksInfo()); trackSelectionsAfterError.set(player.getCurrentTrackSelections()); - windowIndexAfterError.set(player.getCurrentWindowIndex()); + mediaItemIndexAfterError.set(player.getCurrentMediaItemIndex()); } }); } @@ -7402,7 +7410,7 @@ public final class ExoPlayerTest { .blockUntilEnded(TIMEOUT_MS)); assertThat(timelineAfterError.get().getWindowCount()).isEqualTo(1); - assertThat(windowIndexAfterError.get()).isEqualTo(0); + assertThat(mediaItemIndexAfterError.get()).isEqualTo(0); assertThat(trackInfosAfterError.get().getTrackGroupInfos()).hasSize(1); assertThat(trackInfosAfterError.get().getTrackGroupInfos().get(0).getTrackGroup().getFormat(0)) .isEqualTo(ExoPlayerTestRunner.AUDIO_FORMAT); @@ -7414,7 +7422,7 @@ public final class ExoPlayerTest { public void seekToCurrentPosition_inEndedState_switchesToBufferingStateAndContinuesPlayback() throws Exception { MediaSource mediaSource = new FakeMediaSource(new FakeTimeline(/* windowCount = */ 1)); - AtomicInteger windowIndexAfterFinalEndedState = new AtomicInteger(); + AtomicInteger mediaItemIndexAfterFinalEndedState = new AtomicInteger(); ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .waitForPlaybackState(Player.STATE_ENDED) @@ -7432,7 +7440,7 @@ public final class ExoPlayerTest { new PlayerRunnable() { @Override public void run(ExoPlayer player) { - windowIndexAfterFinalEndedState.set(player.getCurrentWindowIndex()); + mediaItemIndexAfterFinalEndedState.set(player.getCurrentMediaItemIndex()); } }) .build(); @@ -7444,7 +7452,7 @@ public final class ExoPlayerTest { .blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilEnded(TIMEOUT_MS); - assertThat(windowIndexAfterFinalEndedState.get()).isEqualTo(1); + assertThat(mediaItemIndexAfterFinalEndedState.get()).isEqualTo(1); } @Test @@ -7458,7 +7466,7 @@ public final class ExoPlayerTest { MediaSource mediaSource = new FakeMediaSource(new FakeTimeline(timelineWindowDefinition)); AtomicInteger playbackStateAfterPause = new AtomicInteger(C.INDEX_UNSET); AtomicLong positionAfterPause = new AtomicLong(C.TIME_UNSET); - AtomicInteger windowIndexAfterPause = new AtomicInteger(C.INDEX_UNSET); + AtomicInteger mediaItemIndexAfterPause = new AtomicInteger(C.INDEX_UNSET); ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .waitForPlayWhenReady(true) @@ -7468,7 +7476,7 @@ public final class ExoPlayerTest { @Override public void run(ExoPlayer player) { playbackStateAfterPause.set(player.getPlaybackState()); - windowIndexAfterPause.set(player.getCurrentWindowIndex()); + mediaItemIndexAfterPause.set(player.getCurrentMediaItemIndex()); positionAfterPause.set(player.getContentPosition()); } }) @@ -7483,7 +7491,7 @@ public final class ExoPlayerTest { .blockUntilEnded(TIMEOUT_MS); assertThat(playbackStateAfterPause.get()).isEqualTo(Player.STATE_READY); - assertThat(windowIndexAfterPause.get()).isEqualTo(0); + assertThat(mediaItemIndexAfterPause.get()).isEqualTo(0); assertThat(positionAfterPause.get()).isEqualTo(10_000); } @@ -7497,7 +7505,7 @@ public final class ExoPlayerTest { MediaSource mediaSource = new FakeMediaSource(new FakeTimeline(timelineWindowDefinition)); AtomicInteger playbackStateAfterPause = new AtomicInteger(C.INDEX_UNSET); AtomicLong positionAfterPause = new AtomicLong(C.TIME_UNSET); - AtomicInteger windowIndexAfterPause = new AtomicInteger(C.INDEX_UNSET); + AtomicInteger mediaItemIndexAfterPause = new AtomicInteger(C.INDEX_UNSET); ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG) .waitForPlayWhenReady(true) @@ -7507,7 +7515,7 @@ public final class ExoPlayerTest { @Override public void run(ExoPlayer player) { playbackStateAfterPause.set(player.getPlaybackState()); - windowIndexAfterPause.set(player.getCurrentWindowIndex()); + mediaItemIndexAfterPause.set(player.getCurrentMediaItemIndex()); positionAfterPause.set(player.getContentPosition()); } }) @@ -7522,7 +7530,7 @@ public final class ExoPlayerTest { .blockUntilEnded(TIMEOUT_MS); assertThat(playbackStateAfterPause.get()).isEqualTo(Player.STATE_ENDED); - assertThat(windowIndexAfterPause.get()).isEqualTo(0); + assertThat(mediaItemIndexAfterPause.get()).isEqualTo(0); assertThat(positionAfterPause.get()).isEqualTo(10_000); } @@ -7856,7 +7864,7 @@ public final class ExoPlayerTest { firstMediaSource.setNewSourceInfo(timelineWithOffsets); // Wait until player transitions to second source (which also has non-zero offsets). runUntilPositionDiscontinuity(player, Player.DISCONTINUITY_REASON_AUTO_TRANSITION); - assertThat(player.getCurrentWindowIndex()).isEqualTo(1); + assertThat(player.getCurrentMediaItemIndex()).isEqualTo(1); player.release(); assertThat(rendererStreamOffsetsUs).hasSize(2); @@ -8112,7 +8120,7 @@ public final class ExoPlayerTest { player.prepare(); runUntilPlaybackState(player, Player.STATE_READY); - player.seekTo(/* windowIndex= */ 1, /* positionMs= */ 2000); + player.seekTo(/* mediaItemIndex= */ 1, /* positionMs= */ 2000); assertThat(reportedMediaItems) .containsExactly(mediaSource1.getMediaItem(), mediaSource2.getMediaItem()) @@ -8144,7 +8152,7 @@ public final class ExoPlayerTest { player.prepare(); runUntilPlaybackState(player, Player.STATE_READY); - player.seekTo(/* windowIndex= */ 0, /* positionMs= */ 2000); + player.seekTo(/* mediaItemIndex= */ 0, /* positionMs= */ 2000); assertThat(reportedMediaItems).containsExactly(mediaSource1.getMediaItem()).inOrder(); assertThat(reportedTransitionReasons) @@ -8381,7 +8389,7 @@ public final class ExoPlayerTest { player.addMediaSources( ImmutableList.of( new FakeMediaSource(), new FakeMediaSource(adTimeline), new FakeMediaSource())); - player.seekTo(/* windowIndex= */ 1, /* positionMs= */ 0); + player.seekTo(/* mediaItemIndex= */ 1, /* positionMs= */ 0); player.prepare(); runUntilPlaybackState(player, Player.STATE_READY); @@ -8461,7 +8469,7 @@ public final class ExoPlayerTest { ExoPlayer player = new TestExoPlayerBuilder(context).build(); player.addMediaSource(new FakeMediaSource(timelineWithUnseekableLiveWindow)); - player.seekTo(/* windowIndex= */ 1, /* positionMs= */ 0); + player.seekTo(/* mediaItemIndex= */ 1, /* positionMs= */ 0); player.prepare(); runUntilPlaybackState(player, Player.STATE_READY); @@ -8517,14 +8525,14 @@ public final class ExoPlayerTest { // Check that there were no other calls to onAvailableCommandsChanged. verify(mockListener).onAvailableCommandsChanged(any()); - player.seekTo(/* windowIndex= */ 1, /* positionMs= */ 0); + player.seekTo(/* mediaItemIndex= */ 1, /* positionMs= */ 0); verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToPreviousAndNextWindow); verify(mockListener, times(2)).onAvailableCommandsChanged(any()); - player.seekTo(/* windowIndex= */ 2, /* positionMs= */ 0); + player.seekTo(/* mediaItemIndex= */ 2, /* positionMs= */ 0); verify(mockListener, times(2)).onAvailableCommandsChanged(any()); - player.seekTo(/* windowIndex= */ 3, /* positionMs= */ 0); + player.seekTo(/* mediaItemIndex= */ 3, /* positionMs= */ 0); verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToPreviousWindow); verify(mockListener, times(3)).onAvailableCommandsChanged(any()); } @@ -8544,7 +8552,7 @@ public final class ExoPlayerTest { ExoPlayer player = new TestExoPlayerBuilder(context).build(); player.addListener(mockListener); - player.seekTo(/* windowIndex= */ 3, /* positionMs= */ 0); + player.seekTo(/* mediaItemIndex= */ 3, /* positionMs= */ 0); player.addMediaSources( ImmutableList.of( new FakeMediaSource(), @@ -8555,14 +8563,14 @@ public final class ExoPlayerTest { // Check that there were no other calls to onAvailableCommandsChanged. verify(mockListener).onAvailableCommandsChanged(any()); - player.seekTo(/* windowIndex= */ 2, /* positionMs= */ 0); + player.seekTo(/* mediaItemIndex= */ 2, /* positionMs= */ 0); verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToPreviousAndNextWindow); verify(mockListener, times(2)).onAvailableCommandsChanged(any()); - player.seekTo(/* windowIndex= */ 1, /* positionMs= */ 0); + player.seekTo(/* mediaItemIndex= */ 1, /* positionMs= */ 0); verify(mockListener, times(2)).onAvailableCommandsChanged(any()); - player.seekTo(/* windowIndex= */ 0, /* positionMs= */ 0); + player.seekTo(/* mediaItemIndex= */ 0, /* positionMs= */ 0); verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToNextWindow); verify(mockListener, times(3)).onAvailableCommandsChanged(any()); } @@ -8577,8 +8585,8 @@ public final class ExoPlayerTest { player.addMediaSources(ImmutableList.of(new FakeMediaSource())); verify(mockListener).onAvailableCommandsChanged(defaultCommands); - player.seekTo(/* windowIndex= */ 0, /* positionMs= */ 200); - player.seekTo(/* windowIndex= */ 0, /* positionMs= */ 100); + player.seekTo(/* mediaItemIndex= */ 0, /* positionMs= */ 200); + player.seekTo(/* mediaItemIndex= */ 0, /* positionMs= */ 100); // Check that there were no other calls to onAvailableCommandsChanged. verify(mockListener).onAvailableCommandsChanged(any()); } @@ -8627,12 +8635,12 @@ public final class ExoPlayerTest { verify(mockListener).onAvailableCommandsChanged(commandsWithSeekInCurrentAndToNextWindow); verify(mockListener, times(2)).onAvailableCommandsChanged(any()); - playUntilStartOfWindow(player, /* windowIndex= */ 1); + playUntilStartOfMediaItem(player, /* mediaItemIndex= */ 1); runUntilPendingCommandsAreFullyHandled(player); verify(mockListener).onAvailableCommandsChanged(commandsWithSeekAnywhere); verify(mockListener, times(3)).onAvailableCommandsChanged(any()); - playUntilStartOfWindow(player, /* windowIndex= */ 2); + playUntilStartOfMediaItem(player, /* mediaItemIndex= */ 2); runUntilPendingCommandsAreFullyHandled(player); verify(mockListener, times(3)).onAvailableCommandsChanged(any()); @@ -8724,7 +8732,7 @@ public final class ExoPlayerTest { ExoPlayer player = new TestExoPlayerBuilder(context).build(); player.addListener(mockListener); - player.seekTo(/* windowIndex= */ 2, /* positionMs= */ 0); + player.seekTo(/* mediaItemIndex= */ 2, /* positionMs= */ 0); player.addMediaSources( ImmutableList.of(new FakeMediaSource(), new FakeMediaSource(), new FakeMediaSource())); verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToPreviousWindow); @@ -8848,7 +8856,7 @@ public final class ExoPlayerTest { .getPeriod(/* periodIndex= */ 1, new Timeline.Period(), /* setIds= */ true) .uid; assertThat(error.mediaPeriodId.periodUid).isEqualTo(period1Uid); - assertThat(player.getCurrentWindowIndex()).isEqualTo(1); + assertThat(player.getCurrentMediaItemIndex()).isEqualTo(1); } @Test @@ -8894,7 +8902,7 @@ public final class ExoPlayerTest { .getPeriod(/* periodIndex= */ 1, new Timeline.Period(), /* setIds= */ true) .uid; assertThat(error.mediaPeriodId.periodUid).isEqualTo(period1Uid); - assertThat(player.getCurrentWindowIndex()).isEqualTo(1); + assertThat(player.getCurrentMediaItemIndex()).isEqualTo(1); } @Test @@ -8957,7 +8965,7 @@ public final class ExoPlayerTest { .getPeriod(/* periodIndex= */ 1, new Timeline.Period(), /* setIds= */ true) .uid; assertThat(error.mediaPeriodId.periodUid).isEqualTo(period1Uid); - assertThat(player.getCurrentWindowIndex()).isEqualTo(1); + assertThat(player.getCurrentMediaItemIndex()).isEqualTo(1); } @Test @@ -8998,7 +9006,7 @@ public final class ExoPlayerTest { .uid; assertThat(error.mediaPeriodId.periodUid).isEqualTo(period1Uid); // Verify test setup by checking that playing period was indeed different. - assertThat(player.getCurrentWindowIndex()).isEqualTo(0); + assertThat(player.getCurrentMediaItemIndex()).isEqualTo(0); } @Test @@ -9137,7 +9145,8 @@ public final class ExoPlayerTest { assertThat(liveOffsetAtStart).isIn(Range.closed(11_900L, 12_100L)); // Play until close to the end of the available live window. - TestPlayerRunHelper.playUntilPosition(player, /* windowIndex= */ 0, /* positionMs= */ 999_000); + TestPlayerRunHelper.playUntilPosition( + player, /* mediaItemIndex= */ 0, /* positionMs= */ 999_000); long liveOffsetAtEnd = player.getCurrentLiveOffset(); player.release(); @@ -9183,7 +9192,8 @@ public final class ExoPlayerTest { TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY); long liveOffsetAtStart = player.getCurrentLiveOffset(); // Play until close to the end of the available live window. - TestPlayerRunHelper.playUntilPosition(player, /* windowIndex= */ 0, /* positionMs= */ 999_000); + TestPlayerRunHelper.playUntilPosition( + player, /* mediaItemIndex= */ 0, /* positionMs= */ 999_000); long liveOffsetAtEnd = player.getCurrentLiveOffset(); player.release(); @@ -9231,7 +9241,8 @@ public final class ExoPlayerTest { // Seek to a live offset of 2 seconds. player.seekTo(18_000); // Play until close to the end of the available live window. - TestPlayerRunHelper.playUntilPosition(player, /* windowIndex= */ 0, /* positionMs= */ 999_000); + TestPlayerRunHelper.playUntilPosition( + player, /* mediaItemIndex= */ 0, /* positionMs= */ 999_000); long liveOffsetAtEnd = player.getCurrentLiveOffset(); player.release(); @@ -9295,11 +9306,13 @@ public final class ExoPlayerTest { assertThat(liveOffsetAtStart).isIn(Range.closed(11_900L, 12_100L)); // Play a bit and update configuration. - TestPlayerRunHelper.playUntilPosition(player, /* windowIndex= */ 0, /* positionMs= */ 55_000); + TestPlayerRunHelper.playUntilPosition( + player, /* mediaItemIndex= */ 0, /* positionMs= */ 55_000); fakeMediaSource.setNewSourceInfo(updatedTimeline); // Play until close to the end of the available live window. - TestPlayerRunHelper.playUntilPosition(player, /* windowIndex= */ 0, /* positionMs= */ 999_000); + TestPlayerRunHelper.playUntilPosition( + player, /* mediaItemIndex= */ 0, /* positionMs= */ 999_000); long liveOffsetAtEnd = player.getCurrentLiveOffset(); player.release(); @@ -9361,7 +9374,8 @@ public final class ExoPlayerTest { player.setPlaybackParameters(new PlaybackParameters(/* speed */ 2.0f)); // Play until close to the end of the available live window. - TestPlayerRunHelper.playUntilPosition(player, /* windowIndex= */ 0, /* positionMs= */ 999_000); + TestPlayerRunHelper.playUntilPosition( + player, /* mediaItemIndex= */ 0, /* positionMs= */ 999_000); long liveOffsetAtEnd = player.getCurrentLiveOffset(); player.release(); @@ -9409,7 +9423,8 @@ public final class ExoPlayerTest { TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY); // Play until close to the end of the available live window. - TestPlayerRunHelper.playUntilPosition(player, /* windowIndex= */ 1, /* positionMs= */ 999_000); + TestPlayerRunHelper.playUntilPosition( + player, /* mediaItemIndex= */ 1, /* positionMs= */ 999_000); long liveOffsetAtEnd = player.getCurrentLiveOffset(); player.release(); @@ -9473,9 +9488,10 @@ public final class ExoPlayerTest { TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY); // Seek to default position in second stream. - player.seekToNextWindow(); + player.seekToNextMediaItem(); // Play until close to the end of the available live window. - TestPlayerRunHelper.playUntilPosition(player, /* windowIndex= */ 1, /* positionMs= */ 999_000); + TestPlayerRunHelper.playUntilPosition( + player, /* mediaItemIndex= */ 1, /* positionMs= */ 999_000); long liveOffsetAtEnd = player.getCurrentLiveOffset(); player.release(); @@ -9539,9 +9555,10 @@ public final class ExoPlayerTest { TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY); // Seek to specific position in second stream (at 2 seconds live offset). - player.seekTo(/* windowIndex= */ 1, /* positionMs= */ 18_000); + player.seekTo(/* mediaItemIndex= */ 1, /* positionMs= */ 18_000); // Play until close to the end of the available live window. - TestPlayerRunHelper.playUntilPosition(player, /* windowIndex= */ 1, /* positionMs= */ 999_000); + TestPlayerRunHelper.playUntilPosition( + player, /* mediaItemIndex= */ 1, /* positionMs= */ 999_000); long liveOffsetAtEnd = player.getCurrentLiveOffset(); player.release(); @@ -9582,7 +9599,8 @@ public final class ExoPlayerTest { TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY); long playbackStartTimeMs = fakeClock.elapsedRealtime(); - TestPlayerRunHelper.playUntilPosition(player, /* windowIndex= */ 0, /* positionMs= */ 999_000); + TestPlayerRunHelper.playUntilPosition( + player, /* mediaItemIndex= */ 0, /* positionMs= */ 999_000); long playbackEndTimeMs = fakeClock.elapsedRealtime(); player.release(); @@ -9623,7 +9641,8 @@ public final class ExoPlayerTest { assertThat(liveOffsetAtStart).isIn(Range.closed(11_900L, 12_100L)); // Play until close to the end of the available live window. - TestPlayerRunHelper.playUntilPosition(player, /* windowIndex= */ 0, /* positionMs= */ 999_000); + TestPlayerRunHelper.playUntilPosition( + player, /* mediaItemIndex= */ 0, /* positionMs= */ 999_000); long liveOffsetAtEnd = player.getCurrentLiveOffset(); player.release(); @@ -9761,7 +9780,7 @@ public final class ExoPlayerTest { TestPlayerRunHelper.runUntilPositionDiscontinuity( player, Player.DISCONTINUITY_REASON_AUTO_TRANSITION); player.addMediaSource(secondMediaSource); - player.seekTo(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET); + player.seekTo(/* mediaItemIndex= */ 1, /* positionMs= */ C.TIME_UNSET); player.play(); TestPlayerRunHelper.runUntilPositionDiscontinuity( player, Player.DISCONTINUITY_REASON_AUTO_TRANSITION); @@ -9838,7 +9857,7 @@ public final class ExoPlayerTest { inOrder .verify(listener) .onMediaItemTransition(any(), eq(Player.MEDIA_ITEM_TRANSITION_REASON_AUTO)); - // Last auto transition from window 0 to window 1 not caused by repeat mode. + // Last auto transition from media item 0 to media item 1 not caused by repeat mode. inOrder .verify(listener) .onPositionDiscontinuity(any(), any(), eq(Player.DISCONTINUITY_REASON_AUTO_TRANSITION)); @@ -10014,7 +10033,7 @@ public final class ExoPlayerTest { player.setMediaSource(new FakeMediaSource(new FakeTimeline(adTimeline))); player.prepare(); - TestPlayerRunHelper.playUntilPosition(player, /* windowIndex= */ 0, /* positionMs= */ 1000); + TestPlayerRunHelper.playUntilPosition(player, /* mediaItemIndex= */ 0, /* positionMs= */ 1000); player.seekTo(/* positionMs= */ 8_000); player.play(); TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED); @@ -10138,7 +10157,7 @@ public final class ExoPlayerTest { ArgumentCaptor.forClass(Player.PositionInfo.class); Window window = new Window(); InOrder inOrder = Mockito.inOrder(listener); - // from first to second window + // from first to second media item inOrder .verify(listener) .onPositionDiscontinuity( @@ -10164,7 +10183,7 @@ public final class ExoPlayerTest { assertThat(newPosition.getValue().contentPositionMs).isEqualTo(0); assertThat(newPosition.getValue().adGroupIndex).isEqualTo(-1); assertThat(newPosition.getValue().adIndexInAdGroup).isEqualTo(-1); - // from second window to third + // from second media item to third inOrder .verify(listener) .onPositionDiscontinuity( @@ -10190,7 +10209,7 @@ public final class ExoPlayerTest { assertThat(newPosition.getValue().contentPositionMs).isEqualTo(0); assertThat(newPosition.getValue().adGroupIndex).isEqualTo(-1); assertThat(newPosition.getValue().adIndexInAdGroup).isEqualTo(-1); - // from third window content to post roll ad + // from third media item content to post roll ad @Nullable Object lastNewWindowUid = newPosition.getValue().windowUid; inOrder .verify(listener) @@ -10211,7 +10230,7 @@ public final class ExoPlayerTest { assertThat(newPosition.getValue().contentPositionMs).isEqualTo(20_000); assertThat(newPosition.getValue().adGroupIndex).isEqualTo(0); assertThat(newPosition.getValue().adIndexInAdGroup).isEqualTo(0); - // from third window post roll to third window content end + // from third media item post roll to third media item content end lastNewWindowUid = newPosition.getValue().windowUid; inOrder .verify(listener) @@ -10233,7 +10252,7 @@ public final class ExoPlayerTest { assertThat(newPosition.getValue().contentPositionMs).isEqualTo(19_999); assertThat(newPosition.getValue().adGroupIndex).isEqualTo(-1); assertThat(newPosition.getValue().adIndexInAdGroup).isEqualTo(-1); - // from third window content end to fourth window pre roll ad + // from third media item content end to fourth media item pre roll ad lastNewWindowUid = newPosition.getValue().windowUid; inOrder .verify(listener) @@ -10258,7 +10277,7 @@ public final class ExoPlayerTest { assertThat(newPosition.getValue().contentPositionMs).isEqualTo(0); assertThat(newPosition.getValue().adGroupIndex).isEqualTo(0); assertThat(newPosition.getValue().adIndexInAdGroup).isEqualTo(0); - // from fourth window pre roll ad to fourth window content + // from fourth media item pre roll ad to fourth media item content lastNewWindowUid = newPosition.getValue().windowUid; inOrder .verify(listener) @@ -10316,7 +10335,7 @@ public final class ExoPlayerTest { player.prepare(); TestPlayerRunHelper.playUntilPosition( - player, /* windowIndex= */ 0, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); + player, /* mediaItemIndex= */ 0, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); player.setMediaSources(ImmutableList.of(secondMediaSource, secondMediaSource)); player.play(); TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED); @@ -10438,11 +10457,11 @@ public final class ExoPlayerTest { player.prepare(); TestPlayerRunHelper.playUntilPosition( - player, /* windowIndex= */ 1, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); + player, /* mediaItemIndex= */ 1, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); player.removeMediaItem(/* index= */ 1); player.seekTo(/* positionMs= */ 0); TestPlayerRunHelper.playUntilPosition( - player, /* windowIndex= */ 0, /* positionMs= */ 2 * C.MILLIS_PER_SECOND); + player, /* mediaItemIndex= */ 0, /* positionMs= */ 2 * C.MILLIS_PER_SECOND); // Removing the last item resets the position to 0 with an empty timeline. player.removeMediaItem(0); TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED); @@ -10527,7 +10546,7 @@ public final class ExoPlayerTest { player.prepare(); TestPlayerRunHelper.playUntilPosition( - player, /* windowIndex= */ 1, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); + player, /* mediaItemIndex= */ 1, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); concatenatingMediaSource.removeMediaSource(1); TestPlayerRunHelper.runUntilPendingCommandsAreFullyHandled(player); concatenatingMediaSource.removeMediaSource(1); @@ -10600,9 +10619,9 @@ public final class ExoPlayerTest { player.prepare(); TestPlayerRunHelper.playUntilPosition( - player, /* windowIndex= */ 1, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); + player, /* mediaItemIndex= */ 1, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); concatenatingMediaSource.removeMediaSource(1); - player.seekTo(/* windowIndex= */ 0, /* positionMs= */ 1234); + player.seekTo(/* mediaItemIndex= */ 0, /* positionMs= */ 1234); TestPlayerRunHelper.runUntilPendingCommandsAreFullyHandled(player); concatenatingMediaSource.removeMediaSource(0); player.play(); @@ -10718,9 +10737,9 @@ public final class ExoPlayerTest { player.prepare(); TestPlayerRunHelper.playUntilPosition( - player, /* windowIndex= */ 0, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); + player, /* mediaItemIndex= */ 0, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); player.seekTo(/* positionMs= */ 7 * C.MILLIS_PER_SECOND); - player.seekTo(/* windowIndex= */ 1, /* positionMs= */ C.MILLIS_PER_SECOND); + player.seekTo(/* mediaItemIndex= */ 1, /* positionMs= */ C.MILLIS_PER_SECOND); player.play(); TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED); @@ -10763,7 +10782,7 @@ public final class ExoPlayerTest { player.addListener(listener); player.seekTo(/* positionMs= */ 7 * C.MILLIS_PER_SECOND); - player.seekTo(/* windowIndex= */ 1, /* positionMs= */ C.MILLIS_PER_SECOND); + player.seekTo(/* mediaItemIndex= */ 1, /* positionMs= */ C.MILLIS_PER_SECOND); player.seekTo(/* positionMs= */ 5 * C.MILLIS_PER_SECOND); ArgumentCaptor oldPosition = @@ -10797,7 +10816,7 @@ public final class ExoPlayerTest { assertThat(newPositions.get(1).mediaItemIndex).isEqualTo(1); assertThat(newPositions.get(1).positionMs).isEqualTo(1_000); assertThat(newPositions.get(1).contentPositionMs).isEqualTo(1_000); - // a seek from masked seek position to another masked position within window + // a seek from masked seek position to another masked position within media item assertThat(oldPositions.get(2).windowUid).isNull(); assertThat(oldPositions.get(2).mediaItemIndex).isEqualTo(1); assertThat(oldPositions.get(2).mediaItem).isNull(); @@ -10825,7 +10844,7 @@ public final class ExoPlayerTest { player.prepare(); TestPlayerRunHelper.playUntilPosition( - player, /* windowIndex= */ 0, /* positionMs= */ 2 * C.DEFAULT_SEEK_BACK_INCREMENT_MS); + player, /* mediaItemIndex= */ 0, /* positionMs= */ 2 * C.DEFAULT_SEEK_BACK_INCREMENT_MS); player.seekBack(); ArgumentCaptor oldPosition = @@ -10872,7 +10891,7 @@ public final class ExoPlayerTest { player.prepare(); TestPlayerRunHelper.playUntilPosition( - player, /* windowIndex= */ 0, /* positionMs= */ C.DEFAULT_SEEK_BACK_INCREMENT_MS / 2); + player, /* mediaItemIndex= */ 0, /* positionMs= */ C.DEFAULT_SEEK_BACK_INCREMENT_MS / 2); player.seekBack(); assertThat(player.getCurrentPosition()).isEqualTo(0); @@ -10943,11 +10962,11 @@ public final class ExoPlayerTest { public void seekToPrevious_withPreviousWindowAndCloseToStart_seeksToPreviousWindow() { ExoPlayer player = new TestExoPlayerBuilder(context).build(); player.addMediaSources(ImmutableList.of(new FakeMediaSource(), new FakeMediaSource())); - player.seekTo(/* windowIndex= */ 1, C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS); + player.seekTo(/* mediaItemIndex= */ 1, C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS); player.seekToPrevious(); - assertThat(player.getCurrentWindowIndex()).isEqualTo(0); + assertThat(player.getCurrentMediaItemIndex()).isEqualTo(0); assertThat(player.getCurrentPosition()).isEqualTo(0); player.release(); @@ -10957,11 +10976,11 @@ public final class ExoPlayerTest { public void seekToPrevious_notCloseToStart_seeksToZero() { ExoPlayer player = new TestExoPlayerBuilder(context).build(); player.addMediaSources(ImmutableList.of(new FakeMediaSource(), new FakeMediaSource())); - player.seekTo(/* windowIndex= */ 1, C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS + 1); + player.seekTo(/* mediaItemIndex= */ 1, C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS + 1); player.seekToPrevious(); - assertThat(player.getCurrentWindowIndex()).isEqualTo(1); + assertThat(player.getCurrentMediaItemIndex()).isEqualTo(1); assertThat(player.getCurrentPosition()).isEqualTo(0); player.release(); @@ -10974,7 +10993,7 @@ public final class ExoPlayerTest { player.seekToNext(); - assertThat(player.getCurrentWindowIndex()).isEqualTo(1); + assertThat(player.getCurrentMediaItemIndex()).isEqualTo(1); assertThat(player.getCurrentPosition()).isEqualTo(0); player.release(); @@ -11004,7 +11023,7 @@ public final class ExoPlayerTest { player.seekTo(/* positionMs = */ 0); player.seekToNext(); - assertThat(player.getCurrentWindowIndex()).isEqualTo(0); + assertThat(player.getCurrentMediaItemIndex()).isEqualTo(0); assertThat(player.getCurrentPosition()).isEqualTo(500); player.release(); @@ -11019,7 +11038,7 @@ public final class ExoPlayerTest { player.prepare(); TestPlayerRunHelper.playUntilPosition( - player, /* windowIndex= */ 0, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); + player, /* mediaItemIndex= */ 0, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); player.stop(); verify(listener, never()).onPositionDiscontinuity(any(), any(), anyInt()); @@ -11037,7 +11056,7 @@ public final class ExoPlayerTest { player.prepare(); TestPlayerRunHelper.playUntilPosition( - player, /* windowIndex= */ 0, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); + player, /* mediaItemIndex= */ 0, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); player.stop(/* reset= */ true); ArgumentCaptor oldPosition = @@ -11081,13 +11100,13 @@ public final class ExoPlayerTest { player.setMediaSource(mediaSource); player.prepare(); - TestPlayerRunHelper.playUntilPosition(player, /* windowIndex= */ 1, /* positionMs= */ 2000); - player.seekTo(/* windowIndex= */ 1, /* positionMs= */ 2122); + TestPlayerRunHelper.playUntilPosition(player, /* mediaItemIndex= */ 1, /* positionMs= */ 2000); + player.seekTo(/* mediaItemIndex= */ 1, /* positionMs= */ 2122); // This causes a DISCONTINUITY_REASON_REMOVE between pending operations that needs to be // cancelled by the seek below. mediaSource.setNewSourceInfo(timeline2); player.play(); - player.seekTo(/* windowIndex= */ 0, /* positionMs= */ 2222); + player.seekTo(/* mediaItemIndex= */ 0, /* positionMs= */ 2222); TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED); ArgumentCaptor oldPosition = @@ -11186,7 +11205,7 @@ public final class ExoPlayerTest { .send(); player.setMediaSource(mediaSource); player.prepare(); - playUntilPosition(player, /* windowIndex= */ 0, /* positionMs= */ 40_000); + playUntilPosition(player, /* mediaItemIndex= */ 0, /* positionMs= */ 40_000); player.release(); // Assert that the renderer hasn't been reset despite the inserted ad group. @@ -11225,7 +11244,7 @@ public final class ExoPlayerTest { player.prepare(); TestPlayerRunHelper.playUntilPosition( - player, /* windowIndex= */ 0, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); + player, /* mediaItemIndex= */ 0, /* positionMs= */ 5 * C.MILLIS_PER_SECOND); player.stop(); shadowOf(Looper.getMainLooper()).idle(); @@ -11370,18 +11389,18 @@ public final class ExoPlayerTest { private static final class PositionGrabbingMessageTarget extends PlayerTarget { - public int windowIndex; + public int mediaItemIndex; public long positionMs; public int messageCount; public PositionGrabbingMessageTarget() { - windowIndex = C.INDEX_UNSET; + mediaItemIndex = C.INDEX_UNSET; positionMs = C.POSITION_UNSET; } @Override public void handleMessage(ExoPlayer player, int messageType, @Nullable Object message) { - windowIndex = player.getCurrentWindowIndex(); + mediaItemIndex = player.getCurrentMediaItemIndex(); positionMs = player.getCurrentPosition(); messageCount++; } diff --git a/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/FakeExoPlayer.java b/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/FakeExoPlayer.java index e44b74a964..c27f353aa7 100644 --- a/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/FakeExoPlayer.java +++ b/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/FakeExoPlayer.java @@ -279,7 +279,7 @@ import androidx.media3.test.utils.StubExoPlayer; timeline.getPeriod(0, period).getAdDurationUs(adGroupIndex, adIndexInAdGroup); return Util.usToMs(adDurationUs); } else { - return timeline.getWindow(getCurrentWindowIndex(), window).getDurationMs(); + return timeline.getWindow(getCurrentMediaItemIndex(), window).getDurationMs(); } } diff --git a/libraries/session/src/main/java/androidx/media3/session/MediaController.java b/libraries/session/src/main/java/androidx/media3/session/MediaController.java index 0f28f141f0..54953f52ca 100644 --- a/libraries/session/src/main/java/androidx/media3/session/MediaController.java +++ b/libraries/session/src/main/java/androidx/media3/session/MediaController.java @@ -1238,7 +1238,7 @@ public class MediaController implements Player { Timeline timeline = getCurrentTimeline(); return timeline.isEmpty() ? null - : timeline.getWindow(getCurrentWindowIndex(), window).mediaItem; + : timeline.getWindow(getCurrentMediaItemIndex(), window).mediaItem; } @Override diff --git a/libraries/session/src/main/java/androidx/media3/session/PlayerNotificationManager.java b/libraries/session/src/main/java/androidx/media3/session/PlayerNotificationManager.java index a39b5f5049..3f9bfc91b1 100644 --- a/libraries/session/src/main/java/androidx/media3/session/PlayerNotificationManager.java +++ b/libraries/session/src/main/java/androidx/media3/session/PlayerNotificationManager.java @@ -607,9 +607,9 @@ public class PlayerNotificationManager { public static final String ACTION_PLAY = "androidx.media3.ui.notification.play"; /** The action which pauses playback. */ public static final String ACTION_PAUSE = "androidx.media3.ui.notification.pause"; - /** The action which skips to the previous window. */ + /** The action which skips to the previous media item. */ public static final String ACTION_PREVIOUS = "androidx.media3.ui.notification.prev"; - /** The action which skips to the next window. */ + /** The action which skips to the next media item. */ public static final String ACTION_NEXT = "androidx.media3.ui.notification.next"; /** The action which fast forwards. */ public static final String ACTION_FAST_FORWARD = "androidx.media3.ui.notification.ffwd"; @@ -1097,7 +1097,7 @@ public class PlayerNotificationManager { * *
      *
    • The media is {@link Player#isPlaying() actively playing}. - *
    • The media is not {@link Player#isCurrentWindowDynamic() dynamically changing its + *
    • The media is not {@link Player#isCurrentMediaItemDynamic() dynamically changing its * duration} (like for example a live stream). *
    • The media is not {@link Player#isPlayingAd() interrupted by an ad}. *
    • The media is played at {@link Player#getPlaybackParameters() regular speed}. @@ -1255,7 +1255,7 @@ public class PlayerNotificationManager { && useChronometer && player.isPlaying() && !player.isPlayingAd() - && !player.isCurrentWindowDynamic() + && !player.isCurrentMediaItemDynamic() && player.getPlaybackParameters().speed == 1f) { builder .setWhen(System.currentTimeMillis() - player.getContentPosition()) @@ -1533,7 +1533,7 @@ public class PlayerNotificationManager { if (player.getPlaybackState() == Player.STATE_IDLE) { player.prepare(); } else if (player.getPlaybackState() == Player.STATE_ENDED) { - player.seekToDefaultPosition(player.getCurrentWindowIndex()); + player.seekToDefaultPosition(player.getCurrentMediaItemIndex()); } player.play(); } else if (ACTION_PAUSE.equals(action)) { diff --git a/libraries/session/src/main/java/androidx/media3/session/PlayerWrapper.java b/libraries/session/src/main/java/androidx/media3/session/PlayerWrapper.java index bf4c45b38f..c9ceca0f89 100644 --- a/libraries/session/src/main/java/androidx/media3/session/PlayerWrapper.java +++ b/libraries/session/src/main/java/androidx/media3/session/PlayerWrapper.java @@ -728,7 +728,7 @@ import java.util.List; | PlaybackStateCompat.ACTION_SET_REPEAT_MODE | PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE | PlaybackStateCompat.ACTION_SET_CAPTIONING_ENABLED; - long queueItemId = MediaUtils.convertToQueueItemId(getCurrentWindowIndex()); + long queueItemId = MediaUtils.convertToQueueItemId(getCurrentMediaItemIndex()); PlaybackStateCompat.Builder builder = new PlaybackStateCompat.Builder() .setState( @@ -807,7 +807,7 @@ import java.util.List; public PositionInfo createPositionInfoForBundling() { return new PositionInfo( /* windowUid= */ null, - getCurrentWindowIndex(), + getCurrentMediaItemIndex(), /* periodUid= */ null, getCurrentMediaItem(), getCurrentPeriodIndex(), diff --git a/libraries/session/src/test/java/androidx/media3/session/PlayerWrapperTest.java b/libraries/session/src/test/java/androidx/media3/session/PlayerWrapperTest.java index b15c3b1a13..85e26f4cc3 100644 --- a/libraries/session/src/test/java/androidx/media3/session/PlayerWrapperTest.java +++ b/libraries/session/src/test/java/androidx/media3/session/PlayerWrapperTest.java @@ -73,7 +73,7 @@ public class PlayerWrapperTest { when(player.getContentDuration()).thenReturn(testContentDurationMs); when(player.getContentPosition()).thenReturn(testContentPositionMs); when(player.getContentBufferedPosition()).thenReturn(testContentBufferedPositionMs); - when(player.getCurrentWindowIndex()).thenReturn(testmediaItemIndex); + when(player.getCurrentMediaItemIndex()).thenReturn(testmediaItemIndex); when(player.getCurrentPeriodIndex()).thenReturn(testPeriodIndex); SessionPositionInfo sessionPositionInfo = playerWrapper.createSessionPositionInfoForBundling(); diff --git a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerListenerTest.java b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerListenerTest.java index 802c7fcbb2..100ed12dce 100644 --- a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerListenerTest.java +++ b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerListenerTest.java @@ -392,7 +392,7 @@ public class MediaControllerListenerTest { boolean testIsPlayingAd = true; int testCurrentAdGroupIndex = 2; int testCurrentAdIndexInAdGroup = 6; - int testWindowIndex = 1; + int testMediaItemIndex = 1; int testPeriodIndex = 2; controller = controllerTestRule.createController(remoteSession.getToken()); @@ -410,7 +410,7 @@ public class MediaControllerListenerTest { AtomicBoolean isPlayingAdRef = new AtomicBoolean(); AtomicInteger currentAdGroupIndexRef = new AtomicInteger(); AtomicInteger currentAdIndexInAdGroupRef = new AtomicInteger(); - AtomicInteger currentWindowIndexRef = new AtomicInteger(); + AtomicInteger currentMediaItemIndexRef = new AtomicInteger(); AtomicInteger currentPeriodIndexRef = new AtomicInteger(); threadTestRule .getHandler() @@ -435,7 +435,7 @@ public class MediaControllerListenerTest { isPlayingAdRef.set(controller.isPlayingAd()); currentAdGroupIndexRef.set(controller.getCurrentAdGroupIndex()); currentAdIndexInAdGroupRef.set(controller.getCurrentAdIndexInAdGroup()); - currentWindowIndexRef.set(controller.getCurrentWindowIndex()); + currentMediaItemIndexRef.set(controller.getCurrentMediaItemIndex()); currentPeriodIndexRef.set(controller.getCurrentPeriodIndex()); latch.countDown(); } @@ -455,7 +455,7 @@ public class MediaControllerListenerTest { .setIsPlayingAd(testIsPlayingAd) .setCurrentAdGroupIndex(testCurrentAdGroupIndex) .setCurrentAdIndexInAdGroup(testCurrentAdIndexInAdGroup) - .setCurrentMediaItemIndex(testWindowIndex) + .setCurrentMediaItemIndex(testMediaItemIndex) .setCurrentPeriodIndex(testPeriodIndex) .build(); remoteSession.setPlayer(playerConfig); @@ -473,7 +473,7 @@ public class MediaControllerListenerTest { assertThat(isPlayingAdRef.get()).isEqualTo(testIsPlayingAd); assertThat(currentAdGroupIndexRef.get()).isEqualTo(testCurrentAdGroupIndex); assertThat(currentAdIndexInAdGroupRef.get()).isEqualTo(testCurrentAdIndexInAdGroup); - assertThat(currentWindowIndexRef.get()).isEqualTo(testWindowIndex); + assertThat(currentMediaItemIndexRef.get()).isEqualTo(testMediaItemIndex); assertThat(currentPeriodIndexRef.get()).isEqualTo(testPeriodIndex); } @@ -836,8 +836,8 @@ public class MediaControllerListenerTest { public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) { shuffleModeEnabledFromParamRef.set(shuffleModeEnabled); shuffleModeEnabledFromGetterRef.set(controller.getShuffleModeEnabled()); - previousIndexRef.set(controller.getPreviousWindowIndex()); - nextIndexRef.set(controller.getNextWindowIndex()); + previousIndexRef.set(controller.getPreviousMediaItemIndex()); + nextIndexRef.set(controller.getNextMediaItemIndex()); latch.countDown(); } }; @@ -876,8 +876,8 @@ public class MediaControllerListenerTest { public void onRepeatModeChanged(@RepeatMode int repeatMode) { repeatModeFromParamRef.set(repeatMode); repeatModeFromGetterRef.set(controller.getRepeatMode()); - previousIndexRef.set(controller.getPreviousWindowIndex()); - nextIndexRef.set(controller.getNextWindowIndex()); + previousIndexRef.set(controller.getPreviousMediaItemIndex()); + nextIndexRef.set(controller.getNextMediaItemIndex()); latch.countDown(); } }; @@ -1352,7 +1352,7 @@ public class MediaControllerListenerTest { PositionInfo testOldPosition = new PositionInfo( /* windowUid= */ null, - /* windowIndex= */ 2, + /* mediaItemIndex= */ 2, new MediaItem.Builder().setMediaId("media-id-2").build(), /* periodUid= */ null, /* periodIndex= */ C.INDEX_UNSET, @@ -1363,7 +1363,7 @@ public class MediaControllerListenerTest { PositionInfo testNewPosition = new PositionInfo( /* windowUid= */ null, - /* windowIndex= */ 3, + /* mediaItemIndex= */ 3, new MediaItem.Builder().setMediaId("media-id-3").build(), /* periodUid= */ null, /* periodIndex= */ C.INDEX_UNSET, @@ -1418,7 +1418,7 @@ public class MediaControllerListenerTest { PositionInfo newPositionInfo = new PositionInfo( /* windowUid= */ null, - /* windowIndex= */ C.INDEX_UNSET, + /* mediaItemIndex= */ C.INDEX_UNSET, /* mediaItem= */ null, /* periodUid= */ null, /* periodIndex= */ C.INDEX_UNSET, diff --git a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerMediaSessionCompatCallbackAggregationTest.java b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerMediaSessionCompatCallbackAggregationTest.java index 38aa0b0b74..f090ca8b9c 100644 --- a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerMediaSessionCompatCallbackAggregationTest.java +++ b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerMediaSessionCompatCallbackAggregationTest.java @@ -188,7 +188,7 @@ public class MediaControllerMediaSessionCompatCallbackAggregationTest { threadTestRule.getHandler().postAndSync(controller::getCurrentTimeline); assertThat(currentTimeline).isEqualTo(timelineRef.get()); int currentMediaItemIndex = - threadTestRule.getHandler().postAndSync(controller::getCurrentWindowIndex); + threadTestRule.getHandler().postAndSync(controller::getCurrentMediaItemIndex); assertThat(currentMediaItemIndex).isEqualTo(testMediaItemIndex); MediaItem currentMediaItem = threadTestRule.getHandler().postAndSync(controller::getCurrentMediaItem); @@ -292,7 +292,7 @@ public class MediaControllerMediaSessionCompatCallbackAggregationTest { threadTestRule.getHandler().postAndSync(controller::getCurrentTimeline); assertThat(currentTimeline).isEqualTo(timelineRef.get()); int currentMediaItemIndex = - threadTestRule.getHandler().postAndSync(controller::getCurrentWindowIndex); + threadTestRule.getHandler().postAndSync(controller::getCurrentMediaItemIndex); assertThat(currentMediaItemIndex).isEqualTo(testMediaItemIndex); MediaItem currentMediaItem = threadTestRule.getHandler().postAndSync(controller::getCurrentMediaItem); @@ -384,7 +384,7 @@ public class MediaControllerMediaSessionCompatCallbackAggregationTest { threadTestRule.getHandler().postAndSync(controller::getCurrentTimeline); assertThat(currentTimeline).isEqualTo(timelineRef.get()); int currentMediaItemIndex = - threadTestRule.getHandler().postAndSync(controller::getCurrentWindowIndex); + threadTestRule.getHandler().postAndSync(controller::getCurrentMediaItemIndex); assertThat(currentMediaItemIndex).isEqualTo(testMediaItemIndex); MediaItem currentMediaItem = threadTestRule.getHandler().postAndSync(controller::getCurrentMediaItem); @@ -483,7 +483,7 @@ public class MediaControllerMediaSessionCompatCallbackAggregationTest { threadTestRule.getHandler().postAndSync(controller::getCurrentTimeline); assertThat(currentTimeline).isEqualTo(timelineRef.get()); int currentMediaItemIndex = - threadTestRule.getHandler().postAndSync(controller::getCurrentWindowIndex); + threadTestRule.getHandler().postAndSync(controller::getCurrentMediaItemIndex); assertThat(currentMediaItemIndex).isEqualTo(testMediaItemIndex); MediaItem currentMediaItem = threadTestRule.getHandler().postAndSync(controller::getCurrentMediaItem); diff --git a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerStateMaskingWithMediaSessionCompatTest.java b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerStateMaskingWithMediaSessionCompatTest.java index 2c58b49e3d..e0c56563f7 100644 --- a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerStateMaskingWithMediaSessionCompatTest.java +++ b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerStateMaskingWithMediaSessionCompatTest.java @@ -416,7 +416,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { } @Test - public void seekTo_withNewWindowIndex() throws Exception { + public void seekTo_withNewMediaItemIndex() throws Exception { List mediaItems = MediaTestUtils.createMediaItems(3); List queue = MediaUtils.convertToQueueItemList(mediaItems); long initialPosition = 8_000; @@ -543,7 +543,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { } @Test - public void seekTo_seekBackwardWithinSameWindow_resetsBufferedPosition() throws Exception { + public void seekTo_seekBackwardWithinSameMediaItem_resetsBufferedPosition() throws Exception { long initialPosition = 8_000L; long initialBufferedPosition = 9_200L; int initialIndex = 0; @@ -621,7 +621,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { } @Test - public void seekTo_seekForwardWithinSameWindow_keepsTheBufferedPosition() throws Exception { + public void seekTo_seekForwardWithinSameMediaItem_keepsTheBufferedPosition() throws Exception { long initialPosition = 8_000L; long initialBufferedPosition = 9_200L; int initialIndex = 0; @@ -703,12 +703,12 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { List mediaItems = MediaTestUtils.createMediaItems("a", "b", "c"); List queue = MediaUtils.convertToQueueItemList(mediaItems); long testPosition = 200L; - int testCurrentWindowIndex = 1; - MediaItem testCurrentMediaItem = mediaItems.get(testCurrentWindowIndex); + int testCurrentMediaItemIndex = 1; + MediaItem testCurrentMediaItem = mediaItems.get(testCurrentMediaItemIndex); session.setPlaybackState( new PlaybackStateCompat.Builder() .setState(PlaybackStateCompat.STATE_PAUSED, testPosition, /* playbackSpeed= */ 1.0f) - .setActiveQueueItemId(queue.get(testCurrentWindowIndex).getQueueId()) + .setActiveQueueItemId(queue.get(testCurrentMediaItemIndex).getQueueId()) .build()); session.setQueue(queue); List newMediaItems = MediaTestUtils.createMediaItems("A", "B"); @@ -741,7 +741,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { }; threadTestRule.getHandler().postAndSync(() -> controller.addListener(listener)); - AtomicInteger currentWindowIndexRef = new AtomicInteger(); + AtomicInteger currentMediaItemIndexRef = new AtomicInteger(); AtomicReference currentMediaItemRef = new AtomicReference<>(); AtomicReference timelineFromGetterRef = new AtomicReference<>(); threadTestRule @@ -749,7 +749,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { .postAndSync( () -> { controller.addMediaItems(testAddIndex, newMediaItems); - currentWindowIndexRef.set(controller.getCurrentWindowIndex()); + currentMediaItemIndexRef.set(controller.getCurrentMediaItemIndex()); currentMediaItemRef.set(controller.getCurrentMediaItem()); timelineFromGetterRef.set(controller.getCurrentTimeline()); }); @@ -758,22 +758,23 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { MediaTestUtils.assertTimelineContains(timelineFromParamRef.get(), testMediaItems); assertThat(timelineChangedReasonRef.get()).isEqualTo(TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED); assertThat(onEventsRef.get()).isEqualTo(testEvents); - assertThat(currentWindowIndexRef.get()).isEqualTo(testCurrentWindowIndex); + assertThat(currentMediaItemIndexRef.get()).isEqualTo(testCurrentMediaItemIndex); assertThat(currentMediaItemRef.get()).isEqualTo(testCurrentMediaItem); MediaTestUtils.assertTimelineContains(timelineFromGetterRef.get(), testMediaItems); } @Test - public void addMediaItems_beforeCurrentWindowIndex_shiftsCurrentWindowIndex() throws Exception { + public void addMediaItems_beforeCurrentMediaItemIndex_shiftsCurrentMediaItemIndex() + throws Exception { List mediaItems = MediaTestUtils.createMediaItems("a", "b", "c"); List queue = MediaUtils.convertToQueueItemList(mediaItems); long testPosition = 200L; - int initialWindowIndex = 2; - MediaItem testCurrentMediaItem = mediaItems.get(initialWindowIndex); + int initialMediaItemIndex = 2; + MediaItem testCurrentMediaItem = mediaItems.get(initialMediaItemIndex); session.setPlaybackState( new PlaybackStateCompat.Builder() .setState(PlaybackStateCompat.STATE_PAUSED, testPosition, /* playbackSpeed= */ 1.0f) - .setActiveQueueItemId(queue.get(initialWindowIndex).getQueueId()) + .setActiveQueueItemId(queue.get(initialMediaItemIndex).getQueueId()) .build()); session.setQueue(queue); List newMediaItems = MediaTestUtils.createMediaItems("A", "B"); @@ -781,7 +782,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { List testMediaItems = new ArrayList<>(); testMediaItems.addAll(mediaItems); testMediaItems.addAll(testAddIndex, newMediaItems); - int testCurrentWindowIndex = testMediaItems.indexOf(testCurrentMediaItem); + int testCurrentMediaItemIndex = testMediaItems.indexOf(testCurrentMediaItem); Events testEvents = new Events(new FlagSet.Builder().addAll(EVENT_TIMELINE_CHANGED).build()); MediaController controller = controllerTestRule.createController(session.getSessionToken()); @@ -807,7 +808,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { }; threadTestRule.getHandler().postAndSync(() -> controller.addListener(listener)); - AtomicInteger currentWindowIndexRef = new AtomicInteger(); + AtomicInteger currentMediaItemIndexRef = new AtomicInteger(); AtomicReference currentMediaItemRef = new AtomicReference<>(); AtomicReference timelineFromGetterRef = new AtomicReference<>(); threadTestRule @@ -815,7 +816,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { .postAndSync( () -> { controller.addMediaItems(testAddIndex, newMediaItems); - currentWindowIndexRef.set(controller.getCurrentWindowIndex()); + currentMediaItemIndexRef.set(controller.getCurrentMediaItemIndex()); currentMediaItemRef.set(controller.getCurrentMediaItem()); timelineFromGetterRef.set(controller.getCurrentTimeline()); }); @@ -824,7 +825,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { MediaTestUtils.assertTimelineContains(timelineFromParamRef.get(), testMediaItems); assertThat(timelineChangedReasonRef.get()).isEqualTo(TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED); assertThat(onEventsRef.get()).isEqualTo(testEvents); - assertThat(currentWindowIndexRef.get()).isEqualTo(testCurrentWindowIndex); + assertThat(currentMediaItemIndexRef.get()).isEqualTo(testCurrentMediaItemIndex); assertThat(currentMediaItemRef.get()).isEqualTo(testCurrentMediaItem); MediaTestUtils.assertTimelineContains(timelineFromGetterRef.get(), testMediaItems); } @@ -834,12 +835,12 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { List mediaItems = MediaTestUtils.createMediaItems(5); List queue = MediaUtils.convertToQueueItemList(mediaItems); long testPosition = 200L; - int testCurrentWindowIndex = 0; - MediaItem testCurrentMediaItem = mediaItems.get(testCurrentWindowIndex); + int testCurrentMediaItemIndex = 0; + MediaItem testCurrentMediaItem = mediaItems.get(testCurrentMediaItemIndex); session.setPlaybackState( new PlaybackStateCompat.Builder() .setState(PlaybackStateCompat.STATE_PAUSED, testPosition, /* playbackSpeed= */ 1.0f) - .setActiveQueueItemId(queue.get(testCurrentWindowIndex).getQueueId()) + .setActiveQueueItemId(queue.get(testCurrentMediaItemIndex).getQueueId()) .build()); session.setQueue(queue); int fromIndex = 1; @@ -871,7 +872,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { }; threadTestRule.getHandler().postAndSync(() -> controller.addListener(listener)); - AtomicInteger currentWindowIndexRef = new AtomicInteger(); + AtomicInteger currentMediaItemIndexRef = new AtomicInteger(); AtomicReference currentMediaItemRef = new AtomicReference<>(); AtomicReference timelineFromGetterRef = new AtomicReference<>(); threadTestRule @@ -879,7 +880,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { .postAndSync( () -> { controller.removeMediaItems(fromIndex, toIndex); - currentWindowIndexRef.set(controller.getCurrentWindowIndex()); + currentMediaItemIndexRef.set(controller.getCurrentMediaItemIndex()); currentMediaItemRef.set(controller.getCurrentMediaItem()); timelineFromGetterRef.set(controller.getCurrentTimeline()); }); @@ -888,30 +889,30 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { MediaTestUtils.assertTimelineContains(timelineFromParamRef.get(), testMediaItems); assertThat(timelineChangedReasonRef.get()).isEqualTo(TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED); assertThat(onEventsRef.get()).isEqualTo(testEvents); - assertThat(currentWindowIndexRef.get()).isEqualTo(testCurrentWindowIndex); + assertThat(currentMediaItemIndexRef.get()).isEqualTo(testCurrentMediaItemIndex); assertThat(currentMediaItemRef.get()).isEqualTo(testCurrentMediaItem); MediaTestUtils.assertTimelineContains(timelineFromGetterRef.get(), testMediaItems); } @Test - public void removeMediaItems_beforeCurrentWindowIndex_shiftsCurrentWindowIndex() + public void removeMediaItems_beforeCurrentMediaItemIndex_shiftsCurrentMediaItemIndex() throws Exception { List mediaItems = MediaTestUtils.createMediaItems(5); List queue = MediaUtils.convertToQueueItemList(mediaItems); long testPosition = 200L; - int initialWindowIndex = 4; - MediaItem testCurrentMediaItem = mediaItems.get(initialWindowIndex); + int initialMediaItemIndex = 4; + MediaItem testCurrentMediaItem = mediaItems.get(initialMediaItemIndex); session.setPlaybackState( new PlaybackStateCompat.Builder() .setState(PlaybackStateCompat.STATE_PAUSED, testPosition, /* playbackSpeed= */ 1.0f) - .setActiveQueueItemId(queue.get(initialWindowIndex).getQueueId()) + .setActiveQueueItemId(queue.get(initialMediaItemIndex).getQueueId()) .build()); session.setQueue(queue); int testFromIndex = 1; int testToIndex = 3; List testMediaItems = new ArrayList<>(mediaItems.subList(0, testFromIndex)); testMediaItems.addAll(mediaItems.subList(testToIndex, mediaItems.size())); - int testCurrentWindowIndex = testMediaItems.indexOf(testCurrentMediaItem); + int testCurrentMediaItemIndex = testMediaItems.indexOf(testCurrentMediaItem); Events testEvents = new Events(new FlagSet.Builder().addAll(EVENT_TIMELINE_CHANGED).build()); MediaController controller = controllerTestRule.createController(session.getSessionToken()); @@ -937,7 +938,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { }; threadTestRule.getHandler().postAndSync(() -> controller.addListener(listener)); - AtomicInteger currentWindowIndexRef = new AtomicInteger(); + AtomicInteger currentMediaItemIndexRef = new AtomicInteger(); AtomicReference currentMediaItemRef = new AtomicReference<>(); AtomicReference timelineFromGetterRef = new AtomicReference<>(); threadTestRule @@ -945,7 +946,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { .postAndSync( () -> { controller.removeMediaItems(testFromIndex, testToIndex); - currentWindowIndexRef.set(controller.getCurrentWindowIndex()); + currentMediaItemIndexRef.set(controller.getCurrentMediaItemIndex()); currentMediaItemRef.set(controller.getCurrentMediaItem()); timelineFromGetterRef.set(controller.getCurrentTimeline()); }); @@ -954,7 +955,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { MediaTestUtils.assertTimelineContains(timelineFromParamRef.get(), testMediaItems); assertThat(timelineChangedReasonRef.get()).isEqualTo(TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED); assertThat(onEventsRef.get()).isEqualTo(testEvents); - assertThat(currentWindowIndexRef.get()).isEqualTo(testCurrentWindowIndex); + assertThat(currentMediaItemIndexRef.get()).isEqualTo(testCurrentMediaItemIndex); assertThat(currentMediaItemRef.get()).isEqualTo(testCurrentMediaItem); MediaTestUtils.assertTimelineContains(timelineFromGetterRef.get(), testMediaItems); } @@ -964,19 +965,19 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { List mediaItems = MediaTestUtils.createMediaItems(5); List queue = MediaUtils.convertToQueueItemList(mediaItems); long testPosition = 200L; - int initialWindowIndex = 2; - MediaItem testCurrentMediaItem = mediaItems.get(initialWindowIndex); + int initialMediaItemIndex = 2; + MediaItem testCurrentMediaItem = mediaItems.get(initialMediaItemIndex); session.setPlaybackState( new PlaybackStateCompat.Builder() .setState(PlaybackStateCompat.STATE_PAUSED, testPosition, /* playbackSpeed= */ 1.0f) - .setActiveQueueItemId(queue.get(initialWindowIndex).getQueueId()) + .setActiveQueueItemId(queue.get(initialMediaItemIndex).getQueueId()) .build()); session.setQueue(queue); int testFromIndex = 1; int testToIndex = 3; List testMediaItems = new ArrayList<>(mediaItems.subList(0, testFromIndex)); testMediaItems.addAll(mediaItems.subList(testToIndex, mediaItems.size())); - int testCurrentWindowIndex = testFromIndex; + int testCurrentMediaItemIndex = testFromIndex; Events testEvents = new Events(new FlagSet.Builder().addAll(EVENT_TIMELINE_CHANGED).build()); MediaController controller = controllerTestRule.createController(session.getSessionToken()); @@ -1002,14 +1003,14 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { }; threadTestRule.getHandler().postAndSync(() -> controller.addListener(listener)); - AtomicInteger currentWindowIndexRef = new AtomicInteger(); + AtomicInteger currentMediaItemIndexRef = new AtomicInteger(); AtomicReference timelineFromGetterRef = new AtomicReference<>(); threadTestRule .getHandler() .postAndSync( () -> { controller.removeMediaItems(testFromIndex, testToIndex); - currentWindowIndexRef.set(controller.getCurrentWindowIndex()); + currentMediaItemIndexRef.set(controller.getCurrentMediaItemIndex()); timelineFromGetterRef.set(controller.getCurrentTimeline()); }); @@ -1017,7 +1018,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { MediaTestUtils.assertTimelineContains(timelineFromParamRef.get(), testMediaItems); assertThat(timelineChangedReasonRef.get()).isEqualTo(TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED); assertThat(onEventsRef.get()).isEqualTo(testEvents); - assertThat(currentWindowIndexRef.get()).isEqualTo(testCurrentWindowIndex); + assertThat(currentMediaItemIndexRef.get()).isEqualTo(testCurrentMediaItemIndex); MediaTestUtils.assertTimelineContains(timelineFromGetterRef.get(), testMediaItems); } @@ -1026,12 +1027,12 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { List mediaItems = MediaTestUtils.createMediaItems(5); List queue = MediaUtils.convertToQueueItemList(mediaItems); long testPosition = 200L; - int testCurrentWindowIndex = 0; - MediaItem testCurrentMediaItem = mediaItems.get(testCurrentWindowIndex); + int testCurrentMediaItemIndex = 0; + MediaItem testCurrentMediaItem = mediaItems.get(testCurrentMediaItemIndex); session.setPlaybackState( new PlaybackStateCompat.Builder() .setState(PlaybackStateCompat.STATE_PAUSED, testPosition, /* playbackSpeed= */ 1.0f) - .setActiveQueueItemId(queue.get(testCurrentWindowIndex).getQueueId()) + .setActiveQueueItemId(queue.get(testCurrentMediaItemIndex).getQueueId()) .build()); session.setQueue(queue); int testFromIndex = 1; @@ -1064,7 +1065,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { }; threadTestRule.getHandler().postAndSync(() -> controller.addListener(listener)); - AtomicInteger currentWindowIndexRef = new AtomicInteger(); + AtomicInteger currentMediaItemIndexRef = new AtomicInteger(); AtomicReference currentMediaItemRef = new AtomicReference<>(); AtomicReference timelineFromGetterRef = new AtomicReference<>(); threadTestRule @@ -1072,7 +1073,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { .postAndSync( () -> { controller.moveMediaItems(testFromIndex, testToIndex, testNewIndex); - currentWindowIndexRef.set(controller.getCurrentWindowIndex()); + currentMediaItemIndexRef.set(controller.getCurrentMediaItemIndex()); currentMediaItemRef.set(controller.getCurrentMediaItem()); timelineFromGetterRef.set(controller.getCurrentTimeline()); }); @@ -1081,7 +1082,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { MediaTestUtils.assertTimelineContains(timelineFromParamRef.get(), testMediaItems); assertThat(timelineChangedReasonRef.get()).isEqualTo(TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED); assertThat(onEventsRef.get()).isEqualTo(testEvents); - assertThat(currentWindowIndexRef.get()).isEqualTo(testCurrentWindowIndex); + assertThat(currentMediaItemIndexRef.get()).isEqualTo(testCurrentMediaItemIndex); assertThat(currentMediaItemRef.get()).isEqualTo(testCurrentMediaItem); MediaTestUtils.assertTimelineContains(timelineFromGetterRef.get(), testMediaItems); } @@ -1091,11 +1092,11 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { List mediaItems = MediaTestUtils.createMediaItems(5); List queue = MediaUtils.convertToQueueItemList(mediaItems); long testPosition = 200L; - int initialCurrentWindowIndex = 1; + int initialCurrentMediaItemIndex = 1; session.setPlaybackState( new PlaybackStateCompat.Builder() .setState(PlaybackStateCompat.STATE_PAUSED, testPosition, /* playbackSpeed= */ 1.0f) - .setActiveQueueItemId(queue.get(initialCurrentWindowIndex).getQueueId()) + .setActiveQueueItemId(queue.get(initialCurrentMediaItemIndex).getQueueId()) .build()); session.setQueue(queue); int testFromIndex = 1; @@ -1106,7 +1107,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { Events testEvents = new Events(new FlagSet.Builder().addAll(EVENT_TIMELINE_CHANGED).build()); // The item at testToIndex becomes current media item after removed, // and it remains as current media item when removed items are inserted back. - int testCurrentWindowIndex = testMediaItems.indexOf(mediaItems.get(testToIndex)); + int testCurrentMediaItemIndex = testMediaItems.indexOf(mediaItems.get(testToIndex)); MediaController controller = controllerTestRule.createController(session.getSessionToken()); CountDownLatch latch = new CountDownLatch(2); @@ -1131,14 +1132,14 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { }; threadTestRule.getHandler().postAndSync(() -> controller.addListener(listener)); - AtomicInteger currentWindowIndexRef = new AtomicInteger(); + AtomicInteger currentMediaItemIndexRef = new AtomicInteger(); AtomicReference timelineFromGetterRef = new AtomicReference<>(); threadTestRule .getHandler() .postAndSync( () -> { controller.moveMediaItems(testFromIndex, testToIndex, testNewIndex); - currentWindowIndexRef.set(controller.getCurrentWindowIndex()); + currentMediaItemIndexRef.set(controller.getCurrentMediaItemIndex()); timelineFromGetterRef.set(controller.getCurrentTimeline()); }); @@ -1146,7 +1147,7 @@ public class MediaControllerStateMaskingWithMediaSessionCompatTest { MediaTestUtils.assertTimelineContains(timelineFromParamRef.get(), testMediaItems); assertThat(timelineChangedReasonRef.get()).isEqualTo(TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED); assertThat(onEventsRef.get()).isEqualTo(testEvents); - assertThat(currentWindowIndexRef.get()).isEqualTo(testCurrentWindowIndex); + assertThat(currentMediaItemIndexRef.get()).isEqualTo(testCurrentMediaItemIndex); MediaTestUtils.assertTimelineContains(timelineFromGetterRef.get(), testMediaItems); } } diff --git a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerWithMediaSessionCompatTest.java b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerWithMediaSessionCompatTest.java index d31f00b895..886091efe2 100644 --- a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerWithMediaSessionCompatTest.java +++ b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerWithMediaSessionCompatTest.java @@ -624,76 +624,77 @@ public class MediaControllerWithMediaSessionCompatTest { } @Test - public void seekToDefaultPosition_withWindowIndex_updatesExpectedWindowIndex() throws Exception { + public void seekToDefaultPosition_withMediaItemIndex_updatesExpectedMediaItemIndex() + throws Exception { List testList = MediaTestUtils.createMediaItems(3); List testQueue = MediaUtils.convertToQueueItemList(testList); session.setQueue(testQueue); session.setPlaybackState(/* state= */ null); - int testWindowIndex = 2; + int testMediaItemIndex = 2; MediaController controller = controllerTestRule.createController(session.getSessionToken()); CountDownLatch latch = new CountDownLatch(1); - AtomicInteger currentWindowIndexRef = new AtomicInteger(); + AtomicInteger currentMediaItemIndexRef = new AtomicInteger(); Player.Listener listener = new Player.Listener() { @Override public void onPositionDiscontinuity( PositionInfo oldPosition, PositionInfo newPosition, @DiscontinuityReason int reason) { - currentWindowIndexRef.set(controller.getCurrentWindowIndex()); + currentMediaItemIndexRef.set(controller.getCurrentMediaItemIndex()); latch.countDown(); } }; threadTestRule.getHandler().postAndSync(() -> controller.addListener(listener)); threadTestRule .getHandler() - .postAndSync(() -> controller.seekToDefaultPosition(testWindowIndex)); + .postAndSync(() -> controller.seekToDefaultPosition(testMediaItemIndex)); session.setPlaybackState( new PlaybackStateCompat.Builder() - .setActiveQueueItemId(testQueue.get(testWindowIndex).getQueueId()) + .setActiveQueueItemId(testQueue.get(testMediaItemIndex).getQueueId()) .build()); assertThat(latch.await(TIMEOUT_MS, MILLISECONDS)).isTrue(); - assertThat(currentWindowIndexRef.get()).isEqualTo(testWindowIndex); + assertThat(currentMediaItemIndexRef.get()).isEqualTo(testMediaItemIndex); } @Test - public void seekTo_withWindowIndex_updatesExpectedWindowIndex() throws Exception { + public void seekTo_withMediaItemIndex_updatesExpectedMediaItemIndex() throws Exception { List testList = MediaTestUtils.createMediaItems(3); List testQueue = MediaUtils.convertToQueueItemList(testList); session.setQueue(testQueue); session.setPlaybackState(/* state= */ null); long testPositionMs = 23L; - int testWindowIndex = 2; + int testMediaItemIndex = 2; MediaController controller = controllerTestRule.createController(session.getSessionToken()); CountDownLatch latch = new CountDownLatch(1); - AtomicInteger windowIndexFromParamRef = new AtomicInteger(); - AtomicInteger windowIndexFromGetterRef = new AtomicInteger(); + AtomicInteger mediaItemIndexFromParamRef = new AtomicInteger(); + AtomicInteger mediaItemIndexFromGetterRef = new AtomicInteger(); Player.Listener listener = new Player.Listener() { @Override public void onPositionDiscontinuity( PositionInfo oldPosition, PositionInfo newPosition, @DiscontinuityReason int reason) { - windowIndexFromParamRef.set(newPosition.mediaItemIndex); - windowIndexFromGetterRef.set(controller.getCurrentWindowIndex()); + mediaItemIndexFromParamRef.set(newPosition.mediaItemIndex); + mediaItemIndexFromGetterRef.set(controller.getCurrentMediaItemIndex()); latch.countDown(); } }; threadTestRule.getHandler().postAndSync(() -> controller.addListener(listener)); threadTestRule .getHandler() - .postAndSync(() -> controller.seekTo(testWindowIndex, testPositionMs)); + .postAndSync(() -> controller.seekTo(testMediaItemIndex, testPositionMs)); session.setPlaybackState( new PlaybackStateCompat.Builder() - .setActiveQueueItemId(testQueue.get(testWindowIndex).getQueueId()) + .setActiveQueueItemId(testQueue.get(testMediaItemIndex).getQueueId()) .build()); assertThat(latch.await(TIMEOUT_MS, MILLISECONDS)).isTrue(); - assertThat(windowIndexFromParamRef.get()).isEqualTo(testWindowIndex); - assertThat(windowIndexFromGetterRef.get()).isEqualTo(testWindowIndex); + assertThat(mediaItemIndexFromParamRef.get()).isEqualTo(testMediaItemIndex); + assertThat(mediaItemIndexFromGetterRef.get()).isEqualTo(testMediaItemIndex); } @Test @@ -790,7 +791,7 @@ public class MediaControllerWithMediaSessionCompatTest { } @Test - public void getCurrentWindowIndex_withInvalidQueueIdWithMetadata_returnsEndOfList() + public void getCurrentMediaItemIndex_withInvalidQueueIdWithMetadata_returnsEndOfList() throws Exception { List testList = MediaTestUtils.createMediaItems(3); List testQueue = MediaUtils.convertToQueueItemList(testList); @@ -801,8 +802,9 @@ public class MediaControllerWithMediaSessionCompatTest { session.setMetadata(testMetadataCompat); MediaController controller = controllerTestRule.createController(session.getSessionToken()); - int windowIndex = threadTestRule.getHandler().postAndSync(controller::getCurrentWindowIndex); - assertThat(windowIndex).isEqualTo(testList.size()); + int mediaItemIndex = + threadTestRule.getHandler().postAndSync(controller::getCurrentMediaItemIndex); + assertThat(mediaItemIndex).isEqualTo(testList.size()); } @Test @@ -942,7 +944,8 @@ public class MediaControllerWithMediaSessionCompatTest { session.setPlaybackState(builder.build()); assertThat(latch.await(TIMEOUT_MS, MILLISECONDS)).isTrue(); - int currentIndex = threadTestRule.getHandler().postAndSync(controller::getCurrentWindowIndex); + int currentIndex = + threadTestRule.getHandler().postAndSync(controller::getCurrentMediaItemIndex); assertThat(currentIndex).isEqualTo(newItemIndex); MediaTestUtils.assertMediaIdEquals(testList.get(newItemIndex), itemRef.get()); assertThat(mediaItemTransitionReasonRef.get()).isEqualTo(MEDIA_ITEM_TRANSITION_REASON_AUTO); diff --git a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionAndControllerTest.java b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionAndControllerTest.java index 91507aed88..fc98957f43 100644 --- a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionAndControllerTest.java +++ b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionAndControllerTest.java @@ -93,9 +93,9 @@ public class MediaSessionAndControllerTest { MainLooperTestRule.runOnMainSync(() -> player.notifyPlaybackStateChanged(state)); controller.seekTo(0); MainLooperTestRule.runOnMainSync(() -> player.notifyPlaybackStateChanged(state)); - controller.seekToNextWindow(); + controller.seekToNextMediaItem(); MainLooperTestRule.runOnMainSync(() -> player.notifyPlaybackStateChanged(state)); - controller.seekToPreviousWindow(); + controller.seekToPreviousMediaItem(); } }); } diff --git a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MockPlayerTest.java b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MockPlayerTest.java index a5887c861b..8fc8b456ed 100644 --- a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MockPlayerTest.java +++ b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MockPlayerTest.java @@ -295,14 +295,14 @@ public class MockPlayerTest { } @Test - public void seekToPreviousWindow() { - player.seekToPreviousWindow(); + public void seekToPreviousMediaItem() { + player.seekToPreviousMediaItem(); assertThat(player.seekToPreviousMediaItemCalled).isTrue(); } @Test - public void seekToNextWindow() { - player.seekToNextWindow(); + public void seekToNextMediaItem() { + player.seekToNextMediaItem(); assertThat(player.seekToNextMediaItemCalled).isTrue(); } diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/Action.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/Action.java index 1eddca47e4..8fee51860e 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/Action.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/Action.java @@ -123,7 +123,7 @@ public abstract class Action { /** Calls {@link Player#seekTo(long)} or {@link Player#seekTo(int, long)}. */ public static final class Seek extends Action { - @Nullable private final Integer windowIndex; + @Nullable private final Integer mediaItemIndex; private final long positionMs; private final boolean catchIllegalSeekException; @@ -135,7 +135,7 @@ public abstract class Action { */ public Seek(String tag, long positionMs) { super(tag, "Seek:" + positionMs); - this.windowIndex = null; + this.mediaItemIndex = null; this.positionMs = positionMs; catchIllegalSeekException = false; } @@ -144,14 +144,15 @@ public abstract class Action { * Action calls {@link Player#seekTo(int, long)}. * * @param tag A tag to use for logging. - * @param windowIndex The window to seek to. + * @param mediaItemIndex The media item to seek to. * @param positionMs The seek position. * @param catchIllegalSeekException Whether {@link IllegalSeekPositionException} should be * silently caught or not. */ - public Seek(String tag, int windowIndex, long positionMs, boolean catchIllegalSeekException) { + public Seek( + String tag, int mediaItemIndex, long positionMs, boolean catchIllegalSeekException) { super(tag, "Seek:" + positionMs); - this.windowIndex = windowIndex; + this.mediaItemIndex = mediaItemIndex; this.positionMs = positionMs; this.catchIllegalSeekException = catchIllegalSeekException; } @@ -160,10 +161,10 @@ public abstract class Action { protected void doActionImpl( ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { try { - if (windowIndex == null) { + if (mediaItemIndex == null) { player.seekTo(positionMs); } else { - player.seekTo(windowIndex, positionMs); + player.seekTo(mediaItemIndex, positionMs); } } catch (IllegalSeekPositionException e) { if (!catchIllegalSeekException) { @@ -176,20 +177,20 @@ public abstract class Action { /** Calls {@link ExoPlayer#setMediaSources(List, int, long)}. */ public static final class SetMediaItems extends Action { - private final int windowIndex; + private final int mediaItemIndex; private final long positionMs; private final MediaSource[] mediaSources; /** * @param tag A tag to use for logging. - * @param windowIndex The window index to start playback from. + * @param mediaItemIndex The media item index to start playback from. * @param positionMs The position in milliseconds to start playback from. * @param mediaSources The media sources to populate the playlist with. */ public SetMediaItems( - String tag, int windowIndex, long positionMs, MediaSource... mediaSources) { + String tag, int mediaItemIndex, long positionMs, MediaSource... mediaSources) { super(tag, "SetMediaItems"); - this.windowIndex = windowIndex; + this.mediaItemIndex = mediaItemIndex; this.positionMs = positionMs; this.mediaSources = mediaSources; } @@ -197,7 +198,7 @@ public abstract class Action { @Override protected void doActionImpl( ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { - player.setMediaSources(Arrays.asList(mediaSources), windowIndex, positionMs); + player.setMediaSources(Arrays.asList(mediaSources), mediaItemIndex, positionMs); } } @@ -555,7 +556,7 @@ public abstract class Action { public static final class SendMessages extends Action { private final Target target; - private final int windowIndex; + private final int mediaItemIndex; private final long positionMs; private final boolean deleteAfterDelivery; @@ -568,7 +569,7 @@ public abstract class Action { this( tag, target, - /* windowIndex= */ C.INDEX_UNSET, + /* mediaItemIndex= */ C.INDEX_UNSET, positionMs, /* deleteAfterDelivery= */ true); } @@ -576,16 +577,20 @@ public abstract class Action { /** * @param tag A tag to use for logging. * @param target A message target. - * @param windowIndex The window index at which the message should be sent, or {@link - * C#INDEX_UNSET} for the current window. + * @param mediaItemIndex The media item index at which the message should be sent, or {@link + * C#INDEX_UNSET} for the current media item. * @param positionMs The position at which the message should be sent, in milliseconds. * @param deleteAfterDelivery Whether the message will be deleted after delivery. */ public SendMessages( - String tag, Target target, int windowIndex, long positionMs, boolean deleteAfterDelivery) { + String tag, + Target target, + int mediaItemIndex, + long positionMs, + boolean deleteAfterDelivery) { super(tag, "SendMessages"); this.target = target; - this.windowIndex = windowIndex; + this.mediaItemIndex = mediaItemIndex; this.positionMs = positionMs; this.deleteAfterDelivery = deleteAfterDelivery; } @@ -597,8 +602,8 @@ public abstract class Action { ((PlayerTarget) target).setPlayer(player); } PlayerMessage message = player.createMessage(target); - if (windowIndex != C.INDEX_UNSET) { - message.setPosition(windowIndex, positionMs); + if (mediaItemIndex != C.INDEX_UNSET) { + message.setPosition(mediaItemIndex, positionMs); } else { message.setPosition(positionMs); } @@ -663,17 +668,17 @@ public abstract class Action { */ public static final class PlayUntilPosition extends Action { - private final int windowIndex; + private final int mediaItemIndex; private final long positionMs; /** * @param tag A tag to use for logging. - * @param windowIndex The window index at which the player should be paused again. - * @param positionMs The position in that window at which the player should be paused again. + * @param mediaItemIndex The media item index at which the player should be paused again. + * @param positionMs The position in that media item at which the player should be paused again. */ - public PlayUntilPosition(String tag, int windowIndex, long positionMs) { - super(tag, "PlayUntilPosition:" + windowIndex + ":" + positionMs); - this.windowIndex = windowIndex; + public PlayUntilPosition(String tag, int mediaItemIndex, long positionMs) { + super(tag, "PlayUntilPosition:" + mediaItemIndex + ":" + positionMs); + this.mediaItemIndex = mediaItemIndex; this.positionMs = positionMs; } @@ -706,7 +711,7 @@ public abstract class Action { // Ignore. } }) - .setPosition(windowIndex, positionMs) + .setPosition(mediaItemIndex, positionMs) .send(); if (nextAction != null) { // Schedule another message on this test thread to continue action schedule. @@ -714,7 +719,7 @@ public abstract class Action { .createMessage( (messageType, payload) -> nextAction.schedule(player, trackSelector, surface, handler)) - .setPosition(windowIndex, positionMs) + .setPosition(mediaItemIndex, positionMs) .setLooper(applicationLooper) .send(); } diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/ActionSchedule.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/ActionSchedule.java index bbfbf30da5..60d3daeb8f 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/ActionSchedule.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/ActionSchedule.java @@ -163,24 +163,25 @@ public final class ActionSchedule { /** * Schedules a seek action. * - * @param windowIndex The window to seek to. + * @param mediaItemIndex The media item to seek to. * @param positionMs The seek position. * @return The builder, for convenience. */ - public Builder seek(int windowIndex, long positionMs) { - return apply(new Seek(tag, windowIndex, positionMs, /* catchIllegalSeekException= */ false)); + public Builder seek(int mediaItemIndex, long positionMs) { + return apply( + new Seek(tag, mediaItemIndex, positionMs, /* catchIllegalSeekException= */ false)); } /** * Schedules a seek action to be executed. * - * @param windowIndex The window to seek to. + * @param mediaItemIndex The media item to seek to. * @param positionMs The seek position. * @param catchIllegalSeekException Whether an illegal seek position should be caught or not. * @return The builder, for convenience. */ - public Builder seek(int windowIndex, long positionMs, boolean catchIllegalSeekException) { - return apply(new Seek(tag, windowIndex, positionMs, catchIllegalSeekException)); + public Builder seek(int mediaItemIndex, long positionMs, boolean catchIllegalSeekException) { + return apply(new Seek(tag, mediaItemIndex, positionMs, catchIllegalSeekException)); } /** @@ -249,23 +250,23 @@ public final class ActionSchedule { * Schedules a play action, waits until the player reaches the specified position, and pauses * the player again. * - * @param windowIndex The window index at which the player should be paused again. - * @param positionMs The position in that window at which the player should be paused again. + * @param mediaItemIndex The media item index at which the player should be paused again. + * @param positionMs The position in that media item at which the player should be paused again. * @return The builder, for convenience. */ - public Builder playUntilPosition(int windowIndex, long positionMs) { - return apply(new PlayUntilPosition(tag, windowIndex, positionMs)); + public Builder playUntilPosition(int mediaItemIndex, long positionMs) { + return apply(new PlayUntilPosition(tag, mediaItemIndex, positionMs)); } /** - * Schedules a play action, waits until the player reaches the start of the specified window, - * and pauses the player again. + * Schedules a play action, waits until the player reaches the start of the specified media + * item, and pauses the player again. * - * @param windowIndex The window index at which the player should be paused again. + * @param mediaItemIndex The media item index at which the player should be paused again. * @return The builder, for convenience. */ - public Builder playUntilStartOfWindow(int windowIndex) { - return apply(new PlayUntilPosition(tag, windowIndex, /* positionMs= */ 0)); + public Builder playUntilStartOfMediaItem(int mediaItemIndex) { + return apply(new PlayUntilPosition(tag, mediaItemIndex, /* positionMs= */ 0)); } /** @@ -325,16 +326,16 @@ public final class ActionSchedule { /** * Schedules a set media items action to be executed. * - * @param windowIndex The window index to start playback from or {@link C#INDEX_UNSET} if the - * playback position should not be reset. + * @param mediaItemIndex The media item index to start playback from or {@link C#INDEX_UNSET} if + * the playback position should not be reset. * @param positionMs The position in milliseconds from where playback should start. If {@link - * C#TIME_UNSET} is passed the default position is used. In any case, if {@code windowIndex} - * is set to {@link C#INDEX_UNSET} the position is not reset at all and this parameter is - * ignored. + * C#TIME_UNSET} is passed the default position is used. In any case, if {@code + * mediaItemIndex} is set to {@link C#INDEX_UNSET} the position is not reset at all and this + * parameter is ignored. * @return The builder, for convenience. */ - public Builder setMediaSources(int windowIndex, long positionMs, MediaSource... sources) { - return apply(new Action.SetMediaItems(tag, windowIndex, positionMs, sources)); + public Builder setMediaSources(int mediaItemIndex, long positionMs, MediaSource... sources) { + return apply(new Action.SetMediaItems(tag, mediaItemIndex, positionMs, sources)); } /** @@ -356,7 +357,10 @@ public final class ActionSchedule { public Builder setMediaSources(MediaSource... mediaSources) { return apply( new Action.SetMediaItems( - tag, /* windowIndex= */ C.INDEX_UNSET, /* positionMs= */ C.TIME_UNSET, mediaSources)); + tag, + /* mediaItemIndex= */ C.INDEX_UNSET, + /* positionMs= */ C.TIME_UNSET, + mediaSources)); } /** * Schedules a add media items action to be executed. @@ -449,8 +453,8 @@ public final class ActionSchedule { /** * Schedules sending a {@link PlayerMessage}. * - * @param positionMs The position in the current window at which the message should be sent, in - * milliseconds. + * @param positionMs The position in the current media item at which the message should be sent, + * in milliseconds. * @return The builder, for convenience. */ public Builder sendMessage(Target target, long positionMs) { @@ -461,27 +465,28 @@ public final class ActionSchedule { * Schedules sending a {@link PlayerMessage}. * * @param target A message target. - * @param windowIndex The window index at which the message should be sent. + * @param mediaItemIndex The media item index at which the message should be sent. * @param positionMs The position at which the message should be sent, in milliseconds. * @return The builder, for convenience. */ - public Builder sendMessage(Target target, int windowIndex, long positionMs) { + public Builder sendMessage(Target target, int mediaItemIndex, long positionMs) { return apply( - new SendMessages(tag, target, windowIndex, positionMs, /* deleteAfterDelivery= */ true)); + new SendMessages( + tag, target, mediaItemIndex, positionMs, /* deleteAfterDelivery= */ true)); } /** * Schedules to send a {@link PlayerMessage}. * * @param target A message target. - * @param windowIndex The window index at which the message should be sent. + * @param mediaItemIndex The media item index at which the message should be sent. * @param positionMs The position at which the message should be sent, in milliseconds. * @param deleteAfterDelivery Whether the message will be deleted after delivery. * @return The builder, for convenience. */ public Builder sendMessage( - Target target, int windowIndex, long positionMs, boolean deleteAfterDelivery) { - return apply(new SendMessages(tag, target, windowIndex, positionMs, deleteAfterDelivery)); + Target target, int mediaItemIndex, long positionMs, boolean deleteAfterDelivery) { + return apply(new SendMessages(tag, target, mediaItemIndex, positionMs, deleteAfterDelivery)); } /** diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/ExoPlayerTestRunner.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/ExoPlayerTestRunner.java index 613ffabcd4..3bf7bc3866 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/ExoPlayerTestRunner.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/ExoPlayerTestRunner.java @@ -87,7 +87,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul private AnalyticsListener analyticsListener; private Integer expectedPlayerEndedCount; private boolean pauseAtEndOfMediaItems; - private int initialWindowIndex; + private int initialMediaItemIndex; private long initialPositionMs; private boolean skipSettingMediaSources; @@ -95,7 +95,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul testPlayerBuilder = new TestExoPlayerBuilder(context); mediaSources = new ArrayList<>(); supportedFormats = new Format[] {VIDEO_FORMAT}; - initialWindowIndex = C.INDEX_UNSET; + initialMediaItemIndex = C.INDEX_UNSET; initialPositionMs = C.TIME_UNSET; } @@ -135,12 +135,12 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul /** * Seeks before setting the media sources and preparing the player. * - * @param windowIndex The window index to seek to. + * @param mediaItemIndex The media item index to seek to. * @param positionMs The position in milliseconds to seek to. * @return This builder. */ - public Builder initialSeek(int windowIndex, long positionMs) { - this.initialWindowIndex = windowIndex; + public Builder initialSeek(int mediaItemIndex, long positionMs) { + this.initialMediaItemIndex = mediaItemIndex; this.initialPositionMs = positionMs; return this; } @@ -345,7 +345,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul testPlayerBuilder, mediaSources, skipSettingMediaSources, - initialWindowIndex, + initialMediaItemIndex, initialPositionMs, surface, actionSchedule, @@ -359,7 +359,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul private final TestExoPlayerBuilder playerBuilder; private final List mediaSources; private final boolean skipSettingMediaSources; - private final int initialWindowIndex; + private final int initialMediaItemIndex; private final long initialPositionMs; @Nullable private final Surface surface; @Nullable private final ActionSchedule actionSchedule; @@ -388,7 +388,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul TestExoPlayerBuilder playerBuilder, List mediaSources, boolean skipSettingMediaSources, - int initialWindowIndex, + int initialMediaItemIndex, long initialPositionMs, @Nullable Surface surface, @Nullable ActionSchedule actionSchedule, @@ -399,7 +399,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul this.playerBuilder = playerBuilder; this.mediaSources = mediaSources; this.skipSettingMediaSources = skipSettingMediaSources; - this.initialWindowIndex = initialWindowIndex; + this.initialMediaItemIndex = initialMediaItemIndex; this.initialPositionMs = initialPositionMs; this.surface = surface; this.actionSchedule = actionSchedule; @@ -468,8 +468,8 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul handler, /* callback= */ ExoPlayerTestRunner.this); } - if (initialWindowIndex != C.INDEX_UNSET) { - player.seekTo(initialWindowIndex, initialPositionMs); + if (initialMediaItemIndex != C.INDEX_UNSET) { + player.seekTo(initialMediaItemIndex, initialPositionMs); } if (!skipSettingMediaSources) { player.setMediaSources(mediaSources, /* resetPosition= */ false); diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/StubExoPlayer.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/StubExoPlayer.java index 0b4310bc30..a875c3ab7f 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/StubExoPlayer.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/StubExoPlayer.java @@ -164,7 +164,7 @@ public class StubExoPlayer extends StubPlayer implements ExoPlayer { @Override public void setMediaSources( - List mediaSources, int startWindowIndex, long startPositionMs) { + List mediaSources, int startMediaItemIndex, long startPositionMs) { throw new UnsupportedOperationException(); } diff --git a/libraries/test_utils_robolectric/src/main/java/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.java b/libraries/test_utils_robolectric/src/main/java/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.java index 92e1e128dd..29c3d09c57 100644 --- a/libraries/test_utils_robolectric/src/main/java/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.java +++ b/libraries/test_utils_robolectric/src/main/java/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.java @@ -286,12 +286,12 @@ public class TestPlayerRunHelper { *

      If a playback error occurs it will be thrown wrapped in an {@link IllegalStateException}. * * @param player The {@link Player}. - * @param windowIndex The window. - * @param positionMs The position within the window, in milliseconds. + * @param mediaItemIndex The index of the media item. + * @param positionMs The position within the media item, in milliseconds. * @throws TimeoutException If the {@link RobolectricUtil#DEFAULT_TIMEOUT_MS default timeout} is * exceeded. */ - public static void playUntilPosition(ExoPlayer player, int windowIndex, long positionMs) + public static void playUntilPosition(ExoPlayer player, int mediaItemIndex, long positionMs) throws TimeoutException { verifyMainTestThread(player); Looper applicationLooper = Util.getCurrentOrMainLooper(); @@ -317,7 +317,7 @@ public class TestPlayerRunHelper { // Ignore. } }) - .setPosition(windowIndex, positionMs) + .setPosition(mediaItemIndex, positionMs) .send(); player.play(); runMainLooperUntil(() -> messageHandled.get() || player.getPlayerError() != null); @@ -328,18 +328,19 @@ public class TestPlayerRunHelper { /** * Calls {@link Player#play()}, runs tasks of the main {@link Looper} until the {@code player} - * reaches the specified window or a playback error occurs, and then pauses the {@code player}. + * reaches the specified media item or a playback error occurs, and then pauses the {@code + * player}. * *

      If a playback error occurs it will be thrown wrapped in an {@link IllegalStateException}. * * @param player The {@link Player}. - * @param windowIndex The window. + * @param mediaItemIndex The index of the media item. * @throws TimeoutException If the {@link RobolectricUtil#DEFAULT_TIMEOUT_MS default timeout} is * exceeded. */ - public static void playUntilStartOfWindow(ExoPlayer player, int windowIndex) + public static void playUntilStartOfMediaItem(ExoPlayer player, int mediaItemIndex) throws TimeoutException { - playUntilPosition(player, windowIndex, /* positionMs= */ 0); + playUntilPosition(player, mediaItemIndex, /* positionMs= */ 0); } /** diff --git a/libraries/ui/src/main/java/androidx/media3/ui/PlayerControlView.java b/libraries/ui/src/main/java/androidx/media3/ui/PlayerControlView.java index 74b50f29a4..46d7c9d7f2 100644 --- a/libraries/ui/src/main/java/androidx/media3/ui/PlayerControlView.java +++ b/libraries/ui/src/main/java/androidx/media3/ui/PlayerControlView.java @@ -952,7 +952,7 @@ public class PlayerControlView extends FrameLayout { int adGroupCount = 0; Timeline timeline = player.getCurrentTimeline(); if (!timeline.isEmpty()) { - int currentWindowIndex = player.getCurrentWindowIndex(); + int currentWindowIndex = player.getCurrentMediaItemIndex(); int firstWindowIndex = multiWindowTimeBar ? 0 : currentWindowIndex; int lastWindowIndex = multiWindowTimeBar ? timeline.getWindowCount() - 1 : currentWindowIndex; for (int i = firstWindowIndex; i <= lastWindowIndex; i++) { @@ -1112,7 +1112,7 @@ public class PlayerControlView extends FrameLayout { windowIndex++; } } else { - windowIndex = player.getCurrentWindowIndex(); + windowIndex = player.getCurrentMediaItemIndex(); } seekTo(player, windowIndex, positionMs); updateProgress(); @@ -1230,7 +1230,7 @@ public class PlayerControlView extends FrameLayout { if (state == Player.STATE_IDLE) { player.prepare(); } else if (state == Player.STATE_ENDED) { - seekTo(player, player.getCurrentWindowIndex(), C.TIME_UNSET); + seekTo(player, player.getCurrentMediaItemIndex(), C.TIME_UNSET); } player.play(); } diff --git a/libraries/ui/src/main/java/androidx/media3/ui/PlayerNotificationManager.java b/libraries/ui/src/main/java/androidx/media3/ui/PlayerNotificationManager.java index 14cfb77b4f..b56e465418 100644 --- a/libraries/ui/src/main/java/androidx/media3/ui/PlayerNotificationManager.java +++ b/libraries/ui/src/main/java/androidx/media3/ui/PlayerNotificationManager.java @@ -607,9 +607,9 @@ public class PlayerNotificationManager { public static final String ACTION_PLAY = "androidx.media3.ui.notification.play"; /** The action which pauses playback. */ public static final String ACTION_PAUSE = "androidx.media3.ui.notification.pause"; - /** The action which skips to the previous window. */ + /** The action which skips to the previous media item. */ public static final String ACTION_PREVIOUS = "androidx.media3.ui.notification.prev"; - /** The action which skips to the next window. */ + /** The action which skips to the next media item. */ public static final String ACTION_NEXT = "androidx.media3.ui.notification.next"; /** The action which fast forwards. */ public static final String ACTION_FAST_FORWARD = "androidx.media3.ui.notification.ffwd"; @@ -1097,7 +1097,7 @@ public class PlayerNotificationManager { * *

        *
      • The media is {@link Player#isPlaying() actively playing}. - *
      • The media is not {@link Player#isCurrentWindowDynamic() dynamically changing its + *
      • The media is not {@link Player#isCurrentMediaItemDynamic() dynamically changing its * duration} (like for example a live stream). *
      • The media is not {@link Player#isPlayingAd() interrupted by an ad}. *
      • The media is played at {@link Player#getPlaybackParameters() regular speed}. @@ -1255,7 +1255,7 @@ public class PlayerNotificationManager { && useChronometer && player.isPlaying() && !player.isPlayingAd() - && !player.isCurrentWindowDynamic() + && !player.isCurrentMediaItemDynamic() && player.getPlaybackParameters().speed == 1f) { builder .setWhen(System.currentTimeMillis() - player.getContentPosition()) @@ -1533,7 +1533,7 @@ public class PlayerNotificationManager { if (player.getPlaybackState() == Player.STATE_IDLE) { player.prepare(); } else if (player.getPlaybackState() == Player.STATE_ENDED) { - player.seekToDefaultPosition(player.getCurrentWindowIndex()); + player.seekToDefaultPosition(player.getCurrentMediaItemIndex()); } player.play(); } else if (ACTION_PAUSE.equals(action)) { diff --git a/libraries/ui/src/main/java/androidx/media3/ui/PlayerView.java b/libraries/ui/src/main/java/androidx/media3/ui/PlayerView.java index 7e42990aba..323b4bdf5c 100644 --- a/libraries/ui/src/main/java/androidx/media3/ui/PlayerView.java +++ b/libraries/ui/src/main/java/androidx/media3/ui/PlayerView.java @@ -1504,8 +1504,8 @@ public class PlayerView extends FrameLayout implements AdViewProvider { if (lastPeriodIndexWithTracks != C.INDEX_UNSET) { int lastWindowIndexWithTracks = timeline.getPeriod(lastPeriodIndexWithTracks, period).windowIndex; - if (player.getCurrentWindowIndex() == lastWindowIndexWithTracks) { - // We're in the same window. Suppress the update. + if (player.getCurrentMediaItemIndex() == lastWindowIndexWithTracks) { + // We're in the same media item. Suppress the update. return; } } diff --git a/libraries/ui/src/main/java/androidx/media3/ui/StyledPlayerControlView.java b/libraries/ui/src/main/java/androidx/media3/ui/StyledPlayerControlView.java index 23841e6e0c..20a7ef5475 100644 --- a/libraries/ui/src/main/java/androidx/media3/ui/StyledPlayerControlView.java +++ b/libraries/ui/src/main/java/androidx/media3/ui/StyledPlayerControlView.java @@ -1271,7 +1271,7 @@ public class StyledPlayerControlView extends FrameLayout { int adGroupCount = 0; Timeline timeline = player.getCurrentTimeline(); if (!timeline.isEmpty()) { - int currentWindowIndex = player.getCurrentWindowIndex(); + int currentWindowIndex = player.getCurrentMediaItemIndex(); int firstWindowIndex = multiWindowTimeBar ? 0 : currentWindowIndex; int lastWindowIndex = multiWindowTimeBar ? timeline.getWindowCount() - 1 : currentWindowIndex; for (int i = firstWindowIndex; i <= lastWindowIndex; i++) { @@ -1455,7 +1455,7 @@ public class StyledPlayerControlView extends FrameLayout { windowIndex++; } } else { - windowIndex = player.getCurrentWindowIndex(); + windowIndex = player.getCurrentMediaItemIndex(); } seekTo(player, windowIndex, positionMs); updateProgress(); @@ -1618,13 +1618,12 @@ public class StyledPlayerControlView extends FrameLayout { } } - @SuppressWarnings("deprecation") private void dispatchPlay(Player player) { @State int state = player.getPlaybackState(); if (state == Player.STATE_IDLE) { player.prepare(); } else if (state == Player.STATE_ENDED) { - seekTo(player, player.getCurrentWindowIndex(), C.TIME_UNSET); + seekTo(player, player.getCurrentMediaItemIndex(), C.TIME_UNSET); } player.play(); } diff --git a/libraries/ui/src/main/java/androidx/media3/ui/StyledPlayerView.java b/libraries/ui/src/main/java/androidx/media3/ui/StyledPlayerView.java index ce513de3e1..62ac7f19f4 100644 --- a/libraries/ui/src/main/java/androidx/media3/ui/StyledPlayerView.java +++ b/libraries/ui/src/main/java/androidx/media3/ui/StyledPlayerView.java @@ -1543,8 +1543,8 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider { if (lastPeriodIndexWithTracks != C.INDEX_UNSET) { int lastWindowIndexWithTracks = timeline.getPeriod(lastPeriodIndexWithTracks, period).windowIndex; - if (player.getCurrentWindowIndex() == lastWindowIndexWithTracks) { - // We're in the same window. Suppress the update. + if (player.getCurrentMediaItemIndex() == lastWindowIndexWithTracks) { + // We're in the same media item. Suppress the update. return; } } diff --git a/libraries/ui_leanback/src/main/java/androidx/media3/ui/leanback/LeanbackPlayerAdapter.java b/libraries/ui_leanback/src/main/java/androidx/media3/ui/leanback/LeanbackPlayerAdapter.java index bd4f901c4c..e08a1f0909 100644 --- a/libraries/ui_leanback/src/main/java/androidx/media3/ui/leanback/LeanbackPlayerAdapter.java +++ b/libraries/ui_leanback/src/main/java/androidx/media3/ui/leanback/LeanbackPlayerAdapter.java @@ -143,7 +143,7 @@ public final class LeanbackPlayerAdapter extends PlayerAdapter implements Runnab if (player.getPlaybackState() == Player.STATE_IDLE) { player.prepare(); } else if (player.getPlaybackState() == Player.STATE_ENDED) { - player.seekToDefaultPosition(player.getCurrentWindowIndex()); + player.seekToDefaultPosition(player.getCurrentMediaItemIndex()); } if (player.isCommandAvailable(Player.COMMAND_PLAY_PAUSE)) { player.play();