Commit ad39f389 by ibaker Committed by bachinger

Update most Player parameter & doc references from Window to MediaItem

Only deprecated references remain.

Usages of the deprecated methods will be migrated in a follow-up change.

#minor-release

PiperOrigin-RevId: 405927141
parent 62855649
...@@ -324,10 +324,9 @@ public final class CastPlayer extends BasePlayer { ...@@ -324,10 +324,9 @@ public final class CastPlayer extends BasePlayer {
} }
@Override @Override
public void setMediaItems( public void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs) {
List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs) {
setMediaItemsInternal( setMediaItemsInternal(
toMediaQueueItems(mediaItems), startWindowIndex, startPositionMs, repeatMode.value); toMediaQueueItems(mediaItems), startIndex, startPositionMs, repeatMode.value);
} }
@Override @Override
...@@ -438,23 +437,23 @@ public final class CastPlayer extends BasePlayer { ...@@ -438,23 +437,23 @@ public final class CastPlayer extends BasePlayer {
// don't implement onPositionDiscontinuity(). // don't implement onPositionDiscontinuity().
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void seekTo(int windowIndex, long positionMs) { public void seekTo(int mediaItemIndex, long positionMs) {
MediaStatus mediaStatus = getMediaStatus(); MediaStatus mediaStatus = getMediaStatus();
// We assume the default position is 0. There is no support for seeking to the default position // We assume the default position is 0. There is no support for seeking to the default position
// in RemoteMediaClient. // in RemoteMediaClient.
positionMs = positionMs != C.TIME_UNSET ? positionMs : 0; positionMs = positionMs != C.TIME_UNSET ? positionMs : 0;
if (mediaStatus != null) { if (mediaStatus != null) {
if (getCurrentWindowIndex() != windowIndex) { if (getCurrentWindowIndex() != mediaItemIndex) {
remoteMediaClient remoteMediaClient
.queueJumpToItem( .queueJumpToItem(
(int) currentTimeline.getPeriod(windowIndex, period).uid, positionMs, null) (int) currentTimeline.getPeriod(mediaItemIndex, period).uid, positionMs, null)
.setResultCallback(seekResultCallback); .setResultCallback(seekResultCallback);
} else { } else {
remoteMediaClient.seek(positionMs).setResultCallback(seekResultCallback); remoteMediaClient.seek(positionMs).setResultCallback(seekResultCallback);
} }
PositionInfo oldPosition = getCurrentPositionInfo(); PositionInfo oldPosition = getCurrentPositionInfo();
pendingSeekCount++; pendingSeekCount++;
pendingSeekWindowIndex = windowIndex; pendingSeekWindowIndex = mediaItemIndex;
pendingSeekPositionMs = positionMs; pendingSeekPositionMs = positionMs;
PositionInfo newPosition = getCurrentPositionInfo(); PositionInfo newPosition = getCurrentPositionInfo();
listeners.queueEvent( listeners.queueEvent(
...@@ -466,7 +465,7 @@ public final class CastPlayer extends BasePlayer { ...@@ -466,7 +465,7 @@ public final class CastPlayer extends BasePlayer {
if (oldPosition.mediaItemIndex != newPosition.mediaItemIndex) { if (oldPosition.mediaItemIndex != newPosition.mediaItemIndex) {
// TODO(internal b/182261884): queue `onMediaItemTransition` event when the media item is // TODO(internal b/182261884): queue `onMediaItemTransition` event when the media item is
// repeated. // repeated.
MediaItem mediaItem = getCurrentTimeline().getWindow(windowIndex, window).mediaItem; MediaItem mediaItem = getCurrentTimeline().getWindow(mediaItemIndex, window).mediaItem;
listeners.queueEvent( listeners.queueEvent(
Player.EVENT_MEDIA_ITEM_TRANSITION, Player.EVENT_MEDIA_ITEM_TRANSITION,
listener -> listener ->
......
...@@ -122,8 +122,8 @@ public abstract class BasePlayer implements Player { ...@@ -122,8 +122,8 @@ public abstract class BasePlayer implements Player {
} }
@Override @Override
public final void seekToDefaultPosition(int windowIndex) { public final void seekToDefaultPosition(int mediaItemIndex) {
seekTo(windowIndex, /* positionMs= */ C.TIME_UNSET); seekTo(mediaItemIndex, /* positionMs= */ C.TIME_UNSET);
} }
@Override @Override
......
...@@ -69,9 +69,8 @@ public class ForwardingPlayer implements Player { ...@@ -69,9 +69,8 @@ public class ForwardingPlayer implements Player {
} }
@Override @Override
public void setMediaItems( public void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs) {
List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs) { player.setMediaItems(mediaItems, startIndex, startPositionMs);
player.setMediaItems(mediaItems, startWindowIndex, startPositionMs);
} }
@Override @Override
...@@ -226,8 +225,8 @@ public class ForwardingPlayer implements Player { ...@@ -226,8 +225,8 @@ public class ForwardingPlayer implements Player {
} }
@Override @Override
public void seekToDefaultPosition(int windowIndex) { public void seekToDefaultPosition(int mediaItemIndex) {
player.seekToDefaultPosition(windowIndex); player.seekToDefaultPosition(mediaItemIndex);
} }
@Override @Override
...@@ -236,8 +235,8 @@ public class ForwardingPlayer implements Player { ...@@ -236,8 +235,8 @@ public class ForwardingPlayer implements Player {
} }
@Override @Override
public void seekTo(int windowIndex, long positionMs) { public void seekTo(int mediaItemIndex, long positionMs) {
player.seekTo(windowIndex, positionMs); player.seekTo(mediaItemIndex, positionMs);
} }
@Override @Override
......
...@@ -1507,16 +1507,16 @@ public interface Player { ...@@ -1507,16 +1507,16 @@ public interface Player {
* Clears the playlist and adds the specified {@link MediaItem MediaItems}. * Clears the playlist and adds the specified {@link MediaItem MediaItems}.
* *
* @param mediaItems The new {@link MediaItem MediaItems}. * @param mediaItems The new {@link MediaItem MediaItems}.
* @param startWindowIndex The window index to start playback from. If {@link C#INDEX_UNSET} is * @param startIndex The {@link MediaItem} index to start playback from. If {@link C#INDEX_UNSET}
* passed, the current position is not reset. * is passed, the current position is not reset.
* @param startPositionMs The position in milliseconds to start playback from. If {@link * @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 * C#TIME_UNSET} is passed, the default position of the given {@link MediaItem} is used. In
* {@code startWindowIndex} is set to {@link C#INDEX_UNSET}, this parameter is ignored and the * any case, if {@code startIndex} is set to {@link C#INDEX_UNSET}, this parameter is ignored
* position is not reset at all. * and the position is not reset at all.
* @throws IllegalSeekPositionException If the provided {@code startWindowIndex} is not within the * @throws IllegalSeekPositionException If the provided {@code startIndex} is not within the
* bounds of the list of media items. * bounds of the list of media items.
*/ */
void setMediaItems(List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs); void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs);
/** /**
* Clears the playlist, adds the specified {@link MediaItem} and resets the position to the * Clears the playlist, adds the specified {@link MediaItem} and resets the position to the
...@@ -1643,9 +1643,9 @@ public interface Player { ...@@ -1643,9 +1643,9 @@ public interface Player {
* Listener#onAvailableCommandsChanged(Commands)} to get an update when the available commands * Listener#onAvailableCommandsChanged(Commands)} to get an update when the available commands
* change. * change.
* *
* <p>Executing a command that is not available (for example, calling {@link #seekToNextWindow()} * <p>Executing a command that is not available (for example, calling {@link
* if {@link #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM} is unavailable) will neither throw an exception nor * #seekToNextMediaItem()} if {@link #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM} is unavailable) will
* generate a {@link #getPlayerError()} player error}. * neither throw an exception nor generate a {@link #getPlayerError()} player error}.
* *
* <p>{@link #COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM} and {@link #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM} * <p>{@link #COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM} and {@link #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM}
* are unavailable if there is no such {@link MediaItem}. * are unavailable if there is no such {@link MediaItem}.
...@@ -1750,14 +1750,14 @@ public interface Player { ...@@ -1750,14 +1750,14 @@ public interface Player {
int getRepeatMode(); int getRepeatMode();
/** /**
* Sets whether shuffling of windows is enabled. * Sets whether shuffling of media items is enabled.
* *
* @param shuffleModeEnabled Whether shuffling is enabled. * @param shuffleModeEnabled Whether shuffling is enabled.
*/ */
void setShuffleModeEnabled(boolean shuffleModeEnabled); void setShuffleModeEnabled(boolean shuffleModeEnabled);
/** /**
* Returns whether shuffling of windows is enabled. * Returns whether shuffling of media items is enabled.
* *
* @see Listener#onShuffleModeEnabledChanged(boolean) * @see Listener#onShuffleModeEnabledChanged(boolean)
*/ */
...@@ -1772,42 +1772,42 @@ public interface Player { ...@@ -1772,42 +1772,42 @@ public interface Player {
boolean isLoading(); boolean isLoading();
/** /**
* Seeks to the default position associated with the current window. The position can depend on * Seeks to the default position associated with the current {@link MediaItem}. The position can
* the type of media being played. For live streams it will typically be the live edge of the * depend on the type of media being played. For live streams it will typically be the live edge.
* window. For other streams it will typically be the start of the window. * For other streams it will typically be the start.
*/ */
void seekToDefaultPosition(); void seekToDefaultPosition();
/** /**
* Seeks to the default position associated with the specified window. The position can depend on * Seeks to the default position associated with the specified {@link MediaItem}. The position can
* the type of media being played. For live streams it will typically be the live edge of the * depend on the type of media being played. For live streams it will typically be the live edge.
* window. For other streams it will typically be the start of the window. * For other streams it will typically be the start.
* *
* @param windowIndex The index of the window whose associated default position should be seeked * @param mediaItemIndex The index of the {@link MediaItem} whose associated default position
* to. * should be seeked to.
* @throws IllegalSeekPositionException If the player has a non-empty timeline and the provided * @throws IllegalSeekPositionException If the player has a non-empty timeline and the provided
* {@code windowIndex} is not within the bounds of the current timeline. * {@code mediaItemIndex} is not within the bounds of the current timeline.
*/ */
void seekToDefaultPosition(int windowIndex); void seekToDefaultPosition(int mediaItemIndex);
/** /**
* Seeks to a position specified in milliseconds in the current window. * Seeks to a position specified in milliseconds in the current {@link MediaItem}.
* *
* @param positionMs The seek position in the current window, or {@link C#TIME_UNSET} to seek to * @param positionMs The seek position in the current {@link MediaItem}, or {@link C#TIME_UNSET}
* the window's default position. * to seek to the media item's default position.
*/ */
void seekTo(long positionMs); void seekTo(long positionMs);
/** /**
* Seeks to a position specified in milliseconds in the specified window. * Seeks to a position specified in milliseconds in the specified {@link MediaItem}.
* *
* @param windowIndex The index of the window. * @param mediaItemIndex The index of the {@link MediaItem}.
* @param positionMs The seek position in the specified window, or {@link C#TIME_UNSET} to seek to * @param positionMs The seek position in the specified {@link MediaItem}, or {@link C#TIME_UNSET}
* the window's default position. * to seek to the media item's default position.
* @throws IllegalSeekPositionException If the player has a non-empty timeline and the provided * @throws IllegalSeekPositionException If the player has a non-empty timeline and the provided
* {@code windowIndex} is not within the bounds of the current timeline. * {@code mediaItemIndex} is not within the bounds of the current timeline.
*/ */
void seekTo(int windowIndex, long positionMs); void seekTo(int mediaItemIndex, long positionMs);
/** /**
* Returns the {@link #seekBack()} increment. * Returns the {@link #seekBack()} increment.
...@@ -1817,7 +1817,9 @@ public interface Player { ...@@ -1817,7 +1817,9 @@ public interface Player {
*/ */
long getSeekBackIncrement(); long getSeekBackIncrement();
/** Seeks back in the current window by {@link #getSeekBackIncrement()} milliseconds. */ /**
* Seeks back in the current {@link MediaItem} by {@link #getSeekBackIncrement()} milliseconds.
*/
void seekBack(); void seekBack();
/** /**
...@@ -1828,7 +1830,10 @@ public interface Player { ...@@ -1828,7 +1830,10 @@ public interface Player {
*/ */
long getSeekForwardIncrement(); long getSeekForwardIncrement();
/** Seeks forward in the current window by {@link #getSeekForwardIncrement()} milliseconds. */ /**
* Seeks forward in the current {@link MediaItem} by {@link #getSeekForwardIncrement()}
* milliseconds.
*/
void seekForward(); void seekForward();
/** @deprecated Use {@link #hasPreviousMediaItem()} instead. */ /** @deprecated Use {@link #hasPreviousMediaItem()} instead. */
...@@ -1908,8 +1913,8 @@ public interface Player { ...@@ -1908,8 +1913,8 @@ public interface Player {
boolean hasNextWindow(); boolean hasNextWindow();
/** /**
* Returns whether a next window exists, which may depend on the current repeat mode and whether * Returns whether a next {@link MediaItem} exists, which may depend on the current repeat mode
* shuffle mode is enabled. * and whether shuffle mode is enabled.
* *
* <p>Note: When the repeat mode is {@link #REPEAT_MODE_ONE}, this method behaves the same as when * <p>Note: When the repeat mode is {@link #REPEAT_MODE_ONE}, this method behaves the same as when
* the current repeat mode is {@link #REPEAT_MODE_OFF}. See {@link #REPEAT_MODE_ONE} for more * the current repeat mode is {@link #REPEAT_MODE_OFF}. See {@link #REPEAT_MODE_ONE} for more
...@@ -1926,9 +1931,9 @@ public interface Player { ...@@ -1926,9 +1931,9 @@ public interface Player {
void seekToNextWindow(); void seekToNextWindow();
/** /**
* Seeks to the default position of the next window, which may depend on the current repeat mode * Seeks to the default position of the next {@link MediaItem}, which may depend on the current
* and whether shuffle mode is enabled. Does nothing if {@link #hasNextMediaItem()} is {@code * repeat mode and whether shuffle mode is enabled. Does nothing if {@link #hasNextMediaItem()} is
* false}. * {@code false}.
* *
* <p>Note: When the repeat mode is {@link #REPEAT_MODE_ONE}, this method behaves the same as when * <p>Note: When the repeat mode is {@link #REPEAT_MODE_ONE}, this method behaves the same as when
* the current repeat mode is {@link #REPEAT_MODE_OFF}. See {@link #REPEAT_MODE_ONE} for more * the current repeat mode is {@link #REPEAT_MODE_OFF}. See {@link #REPEAT_MODE_ONE} for more
...@@ -1944,8 +1949,8 @@ public interface Player { ...@@ -1944,8 +1949,8 @@ public interface Player {
* <li>If the timeline is empty or seeking is not possible, does nothing. * <li>If the timeline is empty or seeking is not possible, does nothing.
* <li>Otherwise, if {@link #hasNextMediaItem() a next media item exists}, seeks to the default * <li>Otherwise, if {@link #hasNextMediaItem() a next media item exists}, seeks to the default
* position of the next {@link MediaItem}. * position of the next {@link MediaItem}.
* <li>Otherwise, if the current window is {@link #isCurrentMediaItemLive() live} and has not * <li>Otherwise, if the current {@link MediaItem} is {@link #isCurrentMediaItemLive() live} and
* ended, seeks to the live edge of the current {@link MediaItem}. * has not ended, seeks to the live edge of the current {@link MediaItem}.
* <li>Otherwise, does nothing. * <li>Otherwise, does nothing.
* </ul> * </ul>
*/ */
......
...@@ -408,9 +408,8 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -408,9 +408,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
} }
@Override @Override
public void setMediaItems( public void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs) {
List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs) { setMediaSources(createMediaSources(mediaItems), startIndex, startPositionMs);
setMediaSources(createMediaSources(mediaItems), startWindowIndex, startPositionMs);
} }
public void setMediaSource(MediaSource mediaSource) { public void setMediaSource(MediaSource mediaSource) {
...@@ -642,10 +641,11 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -642,10 +641,11 @@ import java.util.concurrent.CopyOnWriteArraySet;
} }
@Override @Override
public void seekTo(int windowIndex, long positionMs) { public void seekTo(int mediaItemIndex, long positionMs) {
Timeline timeline = playbackInfo.timeline; Timeline timeline = playbackInfo.timeline;
if (windowIndex < 0 || (!timeline.isEmpty() && windowIndex >= timeline.getWindowCount())) { if (mediaItemIndex < 0
throw new IllegalSeekPositionException(timeline, windowIndex, positionMs); || (!timeline.isEmpty() && mediaItemIndex >= timeline.getWindowCount())) {
throw new IllegalSeekPositionException(timeline, mediaItemIndex, positionMs);
} }
pendingOperationAcks++; pendingOperationAcks++;
if (isPlayingAd()) { if (isPlayingAd()) {
...@@ -668,8 +668,8 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -668,8 +668,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
maskTimelineAndPosition( maskTimelineAndPosition(
newPlaybackInfo, newPlaybackInfo,
timeline, timeline,
getPeriodPositionOrMaskWindowPosition(timeline, windowIndex, positionMs)); getPeriodPositionOrMaskWindowPosition(timeline, mediaItemIndex, positionMs));
internalPlayer.seekTo(timeline, windowIndex, C.msToUs(positionMs)); internalPlayer.seekTo(timeline, mediaItemIndex, C.msToUs(positionMs));
updatePlaybackInfo( updatePlaybackInfo(
newPlaybackInfo, newPlaybackInfo,
/* ignored */ TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, /* ignored */ TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
......
...@@ -1086,10 +1086,9 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -1086,10 +1086,9 @@ public class SimpleExoPlayer extends BasePlayer
} }
@Override @Override
public void setMediaItems( public void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs) {
List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs) {
verifyApplicationThread(); verifyApplicationThread();
player.setMediaItems(mediaItems, startWindowIndex, startPositionMs); player.setMediaItems(mediaItems, startIndex, startPositionMs);
} }
@Override @Override
...@@ -1235,10 +1234,10 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -1235,10 +1234,10 @@ public class SimpleExoPlayer extends BasePlayer
} }
@Override @Override
public void seekTo(int windowIndex, long positionMs) { public void seekTo(int mediaItemIndex, long positionMs) {
verifyApplicationThread(); verifyApplicationThread();
analyticsCollector.notifySeekStarted(); analyticsCollector.notifySeekStarted();
player.seekTo(windowIndex, positionMs); player.seekTo(mediaItemIndex, positionMs);
} }
@Override @Override
......
...@@ -206,8 +206,7 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer { ...@@ -206,8 +206,7 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
} }
@Override @Override
public void setMediaItems( public void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs) {
List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
...@@ -398,7 +397,7 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer { ...@@ -398,7 +397,7 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
} }
@Override @Override
public void seekTo(int windowIndex, long positionMs) { public void seekTo(int mediaItemIndex, long positionMs) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment