Rename fastForward/rewind to seekForward/Back in Player

This matches the Javadoc better.

PiperOrigin-RevId: 383228021
This commit is contained in:
kimvde 2021-07-06 09:51:37 +01:00 committed by kim-vde
parent a632acc1d0
commit 15c565c7d7
12 changed files with 255 additions and 250 deletions

View File

@ -4,7 +4,7 @@
* Core Library: * Core Library:
* Add `needsReconfiguration` API to the `MediaCodecAdapter` interface. * Add `needsReconfiguration` API to the `MediaCodecAdapter` interface.
* Add `fastForward` and `rewind` methods to `Player`. * Add `seekForward` and `seekBack` methods to `Player`.
* Make `Player` depend on the new `PlaybackException` class instead of * Make `Player` depend on the new `PlaybackException` class instead of
`ExoPlaybackException`: `ExoPlaybackException`:
* `Player.getPlayerError` now returns a `PlaybackException`. * `Player.getPlayerError` now returns a `PlaybackException`.

View File

@ -94,8 +94,8 @@ public final class CastPlayer extends BasePlayer {
COMMAND_PREPARE_STOP, COMMAND_PREPARE_STOP,
COMMAND_SEEK_TO_DEFAULT_POSITION, COMMAND_SEEK_TO_DEFAULT_POSITION,
COMMAND_SEEK_TO_MEDIA_ITEM, COMMAND_SEEK_TO_MEDIA_ITEM,
COMMAND_SET_FAST_FORWARD_INCREMENT, COMMAND_SET_SEEK_FORWARD_INCREMENT,
COMMAND_SET_REWIND_INCREMENT, COMMAND_SET_SEEK_BACK_INCREMENT,
COMMAND_SET_REPEAT_MODE, COMMAND_SET_REPEAT_MODE,
COMMAND_GET_CURRENT_MEDIA_ITEM, COMMAND_GET_CURRENT_MEDIA_ITEM,
COMMAND_GET_MEDIA_ITEMS, COMMAND_GET_MEDIA_ITEMS,
@ -144,8 +144,8 @@ public final class CastPlayer extends BasePlayer {
private int pendingSeekWindowIndex; private int pendingSeekWindowIndex;
private long pendingSeekPositionMs; private long pendingSeekPositionMs;
@Nullable private PositionInfo pendingMediaItemRemovalPosition; @Nullable private PositionInfo pendingMediaItemRemovalPosition;
private long fastForwardIncrementMs; private long seekForwardIncrementMs;
private long rewindIncrementMs; private long seekBackIncrementMs;
/** /**
* Creates a new cast player that uses a {@link DefaultMediaItemConverter}. * Creates a new cast player that uses a {@link DefaultMediaItemConverter}.
@ -183,8 +183,8 @@ public final class CastPlayer extends BasePlayer {
availableCommands = new Commands.Builder().addAll(PERMANENT_AVAILABLE_COMMANDS).build(); availableCommands = new Commands.Builder().addAll(PERMANENT_AVAILABLE_COMMANDS).build();
pendingSeekWindowIndex = C.INDEX_UNSET; pendingSeekWindowIndex = C.INDEX_UNSET;
pendingSeekPositionMs = C.TIME_UNSET; pendingSeekPositionMs = C.TIME_UNSET;
fastForwardIncrementMs = DEFAULT_FAST_FORWARD_INCREMENT_MS; seekForwardIncrementMs = DEFAULT_SEEK_FORWARD_INCREMENT_MS;
rewindIncrementMs = DEFAULT_REWIND_INCREMENT_MS; seekBackIncrementMs = DEFAULT_SEEK_BACK_INCREMENT_MS;
SessionManager sessionManager = castContext.getSessionManager(); SessionManager sessionManager = castContext.getSessionManager();
sessionManager.addSessionManagerListener(statusListener, CastSession.class); sessionManager.addSessionManagerListener(statusListener, CastSession.class);
@ -419,37 +419,37 @@ public final class CastPlayer extends BasePlayer {
} }
@Override @Override
public void setFastForwardIncrement(long fastForwardIncrementMs) { public void setSeekForwardIncrement(long seekForwardIncrementMs) {
checkArgument(fastForwardIncrementMs > 0); checkArgument(seekForwardIncrementMs > 0);
if (this.fastForwardIncrementMs != fastForwardIncrementMs) { if (this.seekForwardIncrementMs != seekForwardIncrementMs) {
this.fastForwardIncrementMs = fastForwardIncrementMs; this.seekForwardIncrementMs = seekForwardIncrementMs;
listeners.queueEvent( listeners.queueEvent(
Player.EVENT_FAST_FORWARD_INCREMENT_CHANGED, Player.EVENT_SEEK_FORWARD_INCREMENT_CHANGED,
listener -> listener.onFastForwardIncrementChanged(fastForwardIncrementMs)); listener -> listener.onSeekForwardIncrementChanged(seekForwardIncrementMs));
listeners.flushEvents(); listeners.flushEvents();
} }
} }
@Override @Override
public long getFastForwardIncrement() { public long getSeekForwardIncrement() {
return fastForwardIncrementMs; return seekForwardIncrementMs;
} }
@Override @Override
public void setRewindIncrement(long rewindIncrementMs) { public void setSeekBackIncrement(long seekBackIncrementMs) {
checkArgument(rewindIncrementMs > 0); checkArgument(seekBackIncrementMs > 0);
if (this.rewindIncrementMs != rewindIncrementMs) { if (this.seekBackIncrementMs != seekBackIncrementMs) {
this.rewindIncrementMs = rewindIncrementMs; this.seekBackIncrementMs = seekBackIncrementMs;
listeners.queueEvent( listeners.queueEvent(
Player.EVENT_REWIND_INCREMENT_CHANGED, Player.EVENT_SEEK_BACK_INCREMENT_CHANGED,
listener -> listener.onRewindIncrementChanged(rewindIncrementMs)); listener -> listener.onSeekBackIncrementChanged(seekBackIncrementMs));
listeners.flushEvents(); listeners.flushEvents();
} }
} }
@Override @Override
public long getRewindIncrement() { public long getSeekBackIncrement() {
return rewindIncrementMs; return seekBackIncrementMs;
} }
@Override @Override

View File

@ -17,7 +17,6 @@ package com.google.android.exoplayer2.ext.cast;
import static com.google.android.exoplayer2.Player.COMMAND_ADJUST_DEVICE_VOLUME; import static com.google.android.exoplayer2.Player.COMMAND_ADJUST_DEVICE_VOLUME;
import static com.google.android.exoplayer2.Player.COMMAND_CHANGE_MEDIA_ITEMS; import static com.google.android.exoplayer2.Player.COMMAND_CHANGE_MEDIA_ITEMS;
import static com.google.android.exoplayer2.Player.COMMAND_FAST_FORWARD;
import static com.google.android.exoplayer2.Player.COMMAND_GET_AUDIO_ATTRIBUTES; import static com.google.android.exoplayer2.Player.COMMAND_GET_AUDIO_ATTRIBUTES;
import static com.google.android.exoplayer2.Player.COMMAND_GET_CURRENT_MEDIA_ITEM; import static com.google.android.exoplayer2.Player.COMMAND_GET_CURRENT_MEDIA_ITEM;
import static com.google.android.exoplayer2.Player.COMMAND_GET_DEVICE_VOLUME; import static com.google.android.exoplayer2.Player.COMMAND_GET_DEVICE_VOLUME;
@ -27,23 +26,24 @@ import static com.google.android.exoplayer2.Player.COMMAND_GET_TEXT;
import static com.google.android.exoplayer2.Player.COMMAND_GET_VOLUME; import static com.google.android.exoplayer2.Player.COMMAND_GET_VOLUME;
import static com.google.android.exoplayer2.Player.COMMAND_PLAY_PAUSE; import static com.google.android.exoplayer2.Player.COMMAND_PLAY_PAUSE;
import static com.google.android.exoplayer2.Player.COMMAND_PREPARE_STOP; import static com.google.android.exoplayer2.Player.COMMAND_PREPARE_STOP;
import static com.google.android.exoplayer2.Player.COMMAND_REWIND; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_BACK;
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_FORWARD;
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM;
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_DEFAULT_POSITION; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_DEFAULT_POSITION;
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_MEDIA_ITEM; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_MEDIA_ITEM;
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM;
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM;
import static com.google.android.exoplayer2.Player.COMMAND_SET_DEVICE_VOLUME; import static com.google.android.exoplayer2.Player.COMMAND_SET_DEVICE_VOLUME;
import static com.google.android.exoplayer2.Player.COMMAND_SET_FAST_FORWARD_INCREMENT;
import static com.google.android.exoplayer2.Player.COMMAND_SET_MEDIA_ITEMS_METADATA; import static com.google.android.exoplayer2.Player.COMMAND_SET_MEDIA_ITEMS_METADATA;
import static com.google.android.exoplayer2.Player.COMMAND_SET_REPEAT_MODE; import static com.google.android.exoplayer2.Player.COMMAND_SET_REPEAT_MODE;
import static com.google.android.exoplayer2.Player.COMMAND_SET_REWIND_INCREMENT; import static com.google.android.exoplayer2.Player.COMMAND_SET_SEEK_BACK_INCREMENT;
import static com.google.android.exoplayer2.Player.COMMAND_SET_SEEK_FORWARD_INCREMENT;
import static com.google.android.exoplayer2.Player.COMMAND_SET_SHUFFLE_MODE; import static com.google.android.exoplayer2.Player.COMMAND_SET_SHUFFLE_MODE;
import static com.google.android.exoplayer2.Player.COMMAND_SET_SPEED_AND_PITCH; import static com.google.android.exoplayer2.Player.COMMAND_SET_SPEED_AND_PITCH;
import static com.google.android.exoplayer2.Player.COMMAND_SET_VIDEO_SURFACE; import static com.google.android.exoplayer2.Player.COMMAND_SET_VIDEO_SURFACE;
import static com.google.android.exoplayer2.Player.COMMAND_SET_VOLUME; import static com.google.android.exoplayer2.Player.COMMAND_SET_VOLUME;
import static com.google.android.exoplayer2.Player.DEFAULT_FAST_FORWARD_INCREMENT_MS; import static com.google.android.exoplayer2.Player.DEFAULT_SEEK_BACK_INCREMENT_MS;
import static com.google.android.exoplayer2.Player.DEFAULT_REWIND_INCREMENT_MS; import static com.google.android.exoplayer2.Player.DEFAULT_SEEK_FORWARD_INCREMENT_MS;
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_REMOVE; import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_REMOVE;
import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED; import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
@ -1107,30 +1107,30 @@ public class CastPlayerTest {
} }
@Test @Test
public void setFastForwardIncrement_notifiesFastForwardIncrementChanged() { public void setSeekForwardIncrement_notifiesSeekForwardIncrementChanged() {
long fastForwardIncrementMs = 1000; long seekForwardIncrementMs = 1000;
castPlayer.setFastForwardIncrement(fastForwardIncrementMs); castPlayer.setSeekForwardIncrement(seekForwardIncrementMs);
verify(mockListener).onFastForwardIncrementChanged(fastForwardIncrementMs); verify(mockListener).onSeekForwardIncrementChanged(seekForwardIncrementMs);
assertThat(castPlayer.getFastForwardIncrement()).isEqualTo(fastForwardIncrementMs); assertThat(castPlayer.getSeekForwardIncrement()).isEqualTo(seekForwardIncrementMs);
} }
@Test @Test
@SuppressWarnings("deprecation") // Mocks deprecated method used by the CastPlayer. @SuppressWarnings("deprecation") // Mocks deprecated method used by the CastPlayer.
public void fastForward_notifiesPositionDiscontinuity() { public void seekForward_notifiesPositionDiscontinuity() {
when(mockRemoteMediaClient.seek(anyLong())).thenReturn(mockPendingResult); when(mockRemoteMediaClient.seek(anyLong())).thenReturn(mockPendingResult);
int[] mediaQueueItemIds = new int[] {1}; int[] mediaQueueItemIds = new int[] {1};
List<MediaItem> mediaItems = createMediaItems(mediaQueueItemIds); List<MediaItem> mediaItems = createMediaItems(mediaQueueItemIds);
int currentItemId = 1; int currentItemId = 1;
int[] streamTypes = new int[] {MediaInfo.STREAM_TYPE_BUFFERED}; int[] streamTypes = new int[] {MediaInfo.STREAM_TYPE_BUFFERED};
long[] durationsMs = new long[] {2 * DEFAULT_FAST_FORWARD_INCREMENT_MS}; long[] durationsMs = new long[] {2 * DEFAULT_SEEK_FORWARD_INCREMENT_MS};
long positionMs = 0; long positionMs = 0;
castPlayer.addMediaItems(mediaItems); castPlayer.addMediaItems(mediaItems);
updateTimeLine( updateTimeLine(
mediaItems, mediaQueueItemIds, currentItemId, streamTypes, durationsMs, positionMs); mediaItems, mediaQueueItemIds, currentItemId, streamTypes, durationsMs, positionMs);
castPlayer.fastForward(); castPlayer.seekForward();
Player.PositionInfo oldPosition = Player.PositionInfo oldPosition =
new Player.PositionInfo( new Player.PositionInfo(
@ -1148,8 +1148,8 @@ public class CastPlayerTest {
/* windowIndex= */ 0, /* windowIndex= */ 0,
/* periodUid= */ 1, /* periodUid= */ 1,
/* periodIndex= */ 0, /* periodIndex= */ 0,
/* positionMs= */ DEFAULT_FAST_FORWARD_INCREMENT_MS, /* positionMs= */ DEFAULT_SEEK_FORWARD_INCREMENT_MS,
/* contentPositionMs= */ DEFAULT_FAST_FORWARD_INCREMENT_MS, /* contentPositionMs= */ DEFAULT_SEEK_FORWARD_INCREMENT_MS,
/* adGroupIndex= */ C.INDEX_UNSET, /* adGroupIndex= */ C.INDEX_UNSET,
/* adIndexInAdGroup= */ C.INDEX_UNSET); /* adIndexInAdGroup= */ C.INDEX_UNSET);
InOrder inOrder = Mockito.inOrder(mockListener); InOrder inOrder = Mockito.inOrder(mockListener);
@ -1163,30 +1163,30 @@ public class CastPlayerTest {
} }
@Test @Test
public void setRewindIncrement_notifiesRewindIncrementChanged() { public void setSeekBackIncrement_notifiesSeekBackIncrementChanged() {
long rewindIncrementMs = 1000; long seekBackIncrementMs = 1000;
castPlayer.setRewindIncrement(rewindIncrementMs); castPlayer.setSeekBackIncrement(seekBackIncrementMs);
verify(mockListener).onRewindIncrementChanged(rewindIncrementMs); verify(mockListener).onSeekBackIncrementChanged(seekBackIncrementMs);
assertThat(castPlayer.getRewindIncrement()).isEqualTo(rewindIncrementMs); assertThat(castPlayer.getSeekBackIncrement()).isEqualTo(seekBackIncrementMs);
} }
@Test @Test
@SuppressWarnings("deprecation") // Mocks deprecated method used by the CastPlayer. @SuppressWarnings("deprecation") // Mocks deprecated method used by the CastPlayer.
public void rewind_notifiesPositionDiscontinuity() { public void seekBack_notifiesPositionDiscontinuity() {
when(mockRemoteMediaClient.seek(anyLong())).thenReturn(mockPendingResult); when(mockRemoteMediaClient.seek(anyLong())).thenReturn(mockPendingResult);
int[] mediaQueueItemIds = new int[] {1}; int[] mediaQueueItemIds = new int[] {1};
List<MediaItem> mediaItems = createMediaItems(mediaQueueItemIds); List<MediaItem> mediaItems = createMediaItems(mediaQueueItemIds);
int currentItemId = 1; int currentItemId = 1;
int[] streamTypes = new int[] {MediaInfo.STREAM_TYPE_BUFFERED}; int[] streamTypes = new int[] {MediaInfo.STREAM_TYPE_BUFFERED};
long[] durationsMs = new long[] {3 * DEFAULT_REWIND_INCREMENT_MS}; long[] durationsMs = new long[] {3 * DEFAULT_SEEK_BACK_INCREMENT_MS};
long positionMs = 2 * DEFAULT_REWIND_INCREMENT_MS; long positionMs = 2 * DEFAULT_SEEK_BACK_INCREMENT_MS;
castPlayer.addMediaItems(mediaItems); castPlayer.addMediaItems(mediaItems);
updateTimeLine( updateTimeLine(
mediaItems, mediaQueueItemIds, currentItemId, streamTypes, durationsMs, positionMs); mediaItems, mediaQueueItemIds, currentItemId, streamTypes, durationsMs, positionMs);
castPlayer.rewind(); castPlayer.seekBack();
Player.PositionInfo oldPosition = Player.PositionInfo oldPosition =
new Player.PositionInfo( new Player.PositionInfo(
@ -1194,8 +1194,8 @@ public class CastPlayerTest {
/* windowIndex= */ 0, /* windowIndex= */ 0,
/* periodUid= */ 1, /* periodUid= */ 1,
/* periodIndex= */ 0, /* periodIndex= */ 0,
/* positionMs= */ 2 * DEFAULT_REWIND_INCREMENT_MS, /* positionMs= */ 2 * DEFAULT_SEEK_BACK_INCREMENT_MS,
/* contentPositionMs= */ 2 * DEFAULT_REWIND_INCREMENT_MS, /* contentPositionMs= */ 2 * DEFAULT_SEEK_BACK_INCREMENT_MS,
/* adGroupIndex= */ C.INDEX_UNSET, /* adGroupIndex= */ C.INDEX_UNSET,
/* adIndexInAdGroup= */ C.INDEX_UNSET); /* adIndexInAdGroup= */ C.INDEX_UNSET);
Player.PositionInfo newPosition = Player.PositionInfo newPosition =
@ -1204,8 +1204,8 @@ public class CastPlayerTest {
/* windowIndex= */ 0, /* windowIndex= */ 0,
/* periodUid= */ 1, /* periodUid= */ 1,
/* periodIndex= */ 0, /* periodIndex= */ 0,
/* positionMs= */ DEFAULT_REWIND_INCREMENT_MS, /* positionMs= */ DEFAULT_SEEK_BACK_INCREMENT_MS,
/* contentPositionMs= */ DEFAULT_REWIND_INCREMENT_MS, /* contentPositionMs= */ DEFAULT_SEEK_BACK_INCREMENT_MS,
/* adGroupIndex= */ C.INDEX_UNSET, /* adGroupIndex= */ C.INDEX_UNSET,
/* adIndexInAdGroup= */ C.INDEX_UNSET); /* adIndexInAdGroup= */ C.INDEX_UNSET);
InOrder inOrder = Mockito.inOrder(mockListener); InOrder inOrder = Mockito.inOrder(mockListener);
@ -1233,10 +1233,10 @@ public class CastPlayerTest {
assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM)).isTrue(); assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM)).isTrue();
assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM)).isFalse(); assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM)).isFalse();
assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)).isTrue(); assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)).isTrue();
assertThat(castPlayer.isCommandAvailable(COMMAND_SET_FAST_FORWARD_INCREMENT)).isTrue(); assertThat(castPlayer.isCommandAvailable(COMMAND_SET_SEEK_FORWARD_INCREMENT)).isTrue();
assertThat(castPlayer.isCommandAvailable(COMMAND_FAST_FORWARD)).isTrue(); assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_FORWARD)).isTrue();
assertThat(castPlayer.isCommandAvailable(COMMAND_SET_REWIND_INCREMENT)).isTrue(); assertThat(castPlayer.isCommandAvailable(COMMAND_SET_SEEK_BACK_INCREMENT)).isTrue();
assertThat(castPlayer.isCommandAvailable(COMMAND_REWIND)).isTrue(); assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_BACK)).isTrue();
assertThat(castPlayer.isCommandAvailable(COMMAND_SET_SPEED_AND_PITCH)).isFalse(); assertThat(castPlayer.isCommandAvailable(COMMAND_SET_SPEED_AND_PITCH)).isFalse();
assertThat(castPlayer.isCommandAvailable(COMMAND_SET_SHUFFLE_MODE)).isFalse(); assertThat(castPlayer.isCommandAvailable(COMMAND_SET_SHUFFLE_MODE)).isFalse();
assertThat(castPlayer.isCommandAvailable(COMMAND_SET_REPEAT_MODE)).isTrue(); assertThat(castPlayer.isCommandAvailable(COMMAND_SET_REPEAT_MODE)).isTrue();
@ -1273,8 +1273,8 @@ public class CastPlayerTest {
/* positionMs= */ C.TIME_UNSET); /* positionMs= */ C.TIME_UNSET);
assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)).isFalse(); assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)).isFalse();
assertThat(castPlayer.isCommandAvailable(COMMAND_FAST_FORWARD)).isFalse(); assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_FORWARD)).isFalse();
assertThat(castPlayer.isCommandAvailable(COMMAND_REWIND)).isFalse(); assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_BACK)).isFalse();
} }
@Test @Test
@ -1687,8 +1687,8 @@ public class CastPlayerTest {
Player.Commands.Builder builder = new Player.Commands.Builder(); Player.Commands.Builder builder = new Player.Commands.Builder();
builder.addAll(CastPlayer.PERMANENT_AVAILABLE_COMMANDS); builder.addAll(CastPlayer.PERMANENT_AVAILABLE_COMMANDS);
builder.add(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM); builder.add(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM);
builder.add(COMMAND_FAST_FORWARD); builder.add(COMMAND_SEEK_FORWARD);
builder.add(COMMAND_REWIND); builder.add(COMMAND_SEEK_BACK);
builder.addAll(additionalCommands); builder.addAll(additionalCommands);
return builder.build(); return builder.build();
} }

View File

@ -122,13 +122,13 @@ public abstract class BasePlayer implements Player {
} }
@Override @Override
public final void fastForward() { public final void seekForward() {
seekToOffset(getFastForwardIncrement()); seekToOffset(getSeekForwardIncrement());
} }
@Override @Override
public final void rewind() { public final void seekBack() {
seekToOffset(-getRewindIncrement()); seekToOffset(-getSeekBackIncrement());
} }
@Override @Override
@ -267,8 +267,8 @@ public abstract class BasePlayer implements Player {
.addIf(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, hasNext() && !isPlayingAd()) .addIf(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, hasNext() && !isPlayingAd())
.addIf(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, hasPrevious() && !isPlayingAd()) .addIf(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, hasPrevious() && !isPlayingAd())
.addIf(COMMAND_SEEK_TO_MEDIA_ITEM, !isPlayingAd()) .addIf(COMMAND_SEEK_TO_MEDIA_ITEM, !isPlayingAd())
.addIf(COMMAND_FAST_FORWARD, isCurrentWindowSeekable() && !isPlayingAd()) .addIf(COMMAND_SEEK_FORWARD, isCurrentWindowSeekable() && !isPlayingAd())
.addIf(COMMAND_REWIND, isCurrentWindowSeekable() && !isPlayingAd()) .addIf(COMMAND_SEEK_BACK, isCurrentWindowSeekable() && !isPlayingAd())
.build(); .build();
} }

View File

@ -248,33 +248,33 @@ public class ForwardingPlayer implements Player {
} }
@Override @Override
public void setFastForwardIncrement(long fastForwardIncrementMs) { public void setSeekForwardIncrement(long seekForwardIncrementMs) {
player.setFastForwardIncrement(fastForwardIncrementMs); player.setSeekForwardIncrement(seekForwardIncrementMs);
} }
@Override @Override
public long getFastForwardIncrement() { public long getSeekForwardIncrement() {
return player.getFastForwardIncrement(); return player.getSeekForwardIncrement();
} }
@Override @Override
public void fastForward() { public void seekForward() {
player.fastForward(); player.seekForward();
} }
@Override @Override
public void setRewindIncrement(long rewindIncrementMs) { public void setSeekBackIncrement(long seekBackIncrementMs) {
player.setRewindIncrement(rewindIncrementMs); player.setSeekBackIncrement(seekBackIncrementMs);
} }
@Override @Override
public long getRewindIncrement() { public long getSeekBackIncrement() {
return player.getRewindIncrement(); return player.getSeekBackIncrement();
} }
@Override @Override
public void rewind() { public void seekBack() {
player.rewind(); player.seekBack();
} }
@Override @Override
@ -707,13 +707,13 @@ public class ForwardingPlayer implements Player {
} }
@Override @Override
public void onFastForwardIncrementChanged(long fastForwardIncrementMs) { public void onSeekForwardIncrementChanged(long seekForwardIncrementMs) {
eventListener.onFastForwardIncrementChanged(fastForwardIncrementMs); eventListener.onSeekForwardIncrementChanged(seekForwardIncrementMs);
} }
@Override @Override
public void onRewindIncrementChanged(long rewindIncrementMs) { public void onSeekBackIncrementChanged(long seekBackIncrementMs) {
eventListener.onRewindIncrementChanged(rewindIncrementMs); eventListener.onSeekBackIncrementChanged(seekBackIncrementMs);
} }
@Override @Override

View File

@ -324,24 +324,24 @@ public interface Player {
default void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {} default void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {}
/** /**
* Called when the value of {@link #getFastForwardIncrement()} changes. * Called when the value of {@link #getSeekForwardIncrement()} changes.
* *
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with * <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration. * other events that happen in the same {@link Looper} message queue iteration.
* *
* @param fastForwardIncrementMs The {@link #fastForward()} increment, in milliseconds. * @param seekForwardIncrementMs The {@link #seekForward()} increment, in milliseconds.
*/ */
default void onFastForwardIncrementChanged(@IntRange(from = 1) long fastForwardIncrementMs) {} default void onSeekForwardIncrementChanged(@IntRange(from = 1) long seekForwardIncrementMs) {}
/** /**
* Called when the value of {@link #getRewindIncrement()} changes. * Called when the value of {@link #getSeekBackIncrement()} changes.
* *
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with * <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration. * other events that happen in the same {@link Looper} message queue iteration.
* *
* @param rewindIncrementMs The {@link #rewind()} increment, in milliseconds. * @param seekBackIncrementMs The {@link #seekBack()} increment, in milliseconds.
*/ */
default void onRewindIncrementChanged(@IntRange(from = 1) long rewindIncrementMs) {} default void onSeekBackIncrementChanged(@IntRange(from = 1) long seekBackIncrementMs) {}
/** /**
* @deprecated Seeks are processed without delay. Listen to {@link * @deprecated Seeks are processed without delay. Listen to {@link
@ -630,10 +630,10 @@ public interface Player {
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, COMMAND_SEEK_TO_NEXT_MEDIA_ITEM,
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM,
COMMAND_SEEK_TO_MEDIA_ITEM, COMMAND_SEEK_TO_MEDIA_ITEM,
COMMAND_SET_FAST_FORWARD_INCREMENT, COMMAND_SET_SEEK_FORWARD_INCREMENT,
COMMAND_FAST_FORWARD, COMMAND_SEEK_FORWARD,
COMMAND_SET_REWIND_INCREMENT, COMMAND_SET_SEEK_BACK_INCREMENT,
COMMAND_REWIND, COMMAND_SEEK_BACK,
COMMAND_SET_SPEED_AND_PITCH, COMMAND_SET_SPEED_AND_PITCH,
COMMAND_SET_SHUFFLE_MODE, COMMAND_SET_SHUFFLE_MODE,
COMMAND_SET_REPEAT_MODE, COMMAND_SET_REPEAT_MODE,
@ -886,10 +886,10 @@ public interface Player {
default void onMetadata(Metadata metadata) {} default void onMetadata(Metadata metadata) {}
} }
/** The default {@link #fastForward()} increment, in milliseconds. */ /** The default {@link #seekForward()} increment, in milliseconds. */
long DEFAULT_FAST_FORWARD_INCREMENT_MS = 15_000; long DEFAULT_SEEK_FORWARD_INCREMENT_MS = 15_000;
/** The default {@link #rewind()} increment, in milliseconds. */ /** The default {@link #seekBack()} increment, in milliseconds. */
long DEFAULT_REWIND_INCREMENT_MS = 5000; long DEFAULT_SEEK_BACK_INCREMENT_MS = 5000;
/** /**
* Playback state. One of {@link #STATE_IDLE}, {@link #STATE_BUFFERING}, {@link #STATE_READY} or * Playback state. One of {@link #STATE_IDLE}, {@link #STATE_BUFFERING}, {@link #STATE_READY} or
@ -1103,8 +1103,8 @@ public interface Player {
EVENT_AVAILABLE_COMMANDS_CHANGED, EVENT_AVAILABLE_COMMANDS_CHANGED,
EVENT_MEDIA_METADATA_CHANGED, EVENT_MEDIA_METADATA_CHANGED,
EVENT_PLAYLIST_METADATA_CHANGED, EVENT_PLAYLIST_METADATA_CHANGED,
EVENT_FAST_FORWARD_INCREMENT_CHANGED, EVENT_SEEK_FORWARD_INCREMENT_CHANGED,
EVENT_REWIND_INCREMENT_CHANGED EVENT_SEEK_BACK_INCREMENT_CHANGED
}) })
@interface EventFlags {} @interface EventFlags {}
/** {@link #getCurrentTimeline()} changed. */ /** {@link #getCurrentTimeline()} changed. */
@ -1144,25 +1144,26 @@ public interface Player {
int EVENT_MEDIA_METADATA_CHANGED = 15; int EVENT_MEDIA_METADATA_CHANGED = 15;
/** {@link #getPlaylistMetadata()} changed. */ /** {@link #getPlaylistMetadata()} changed. */
int EVENT_PLAYLIST_METADATA_CHANGED = 16; int EVENT_PLAYLIST_METADATA_CHANGED = 16;
/** {@link #getFastForwardIncrement()} changed. */ /** {@link #getSeekForwardIncrement()} changed. */
int EVENT_FAST_FORWARD_INCREMENT_CHANGED = 17; int EVENT_SEEK_FORWARD_INCREMENT_CHANGED = 17;
/** {@link #getRewindIncrement()} changed. */ /** {@link #getSeekBackIncrement()} changed. */
int EVENT_REWIND_INCREMENT_CHANGED = 18; int EVENT_SEEK_BACK_INCREMENT_CHANGED = 18;
/** /**
* Commands that can be executed on a {@code Player}. One of {@link #COMMAND_PLAY_PAUSE}, {@link * Commands that can be executed on a {@code Player}. One of {@link #COMMAND_PLAY_PAUSE}, {@link
* #COMMAND_PREPARE_STOP}, {@link #COMMAND_SEEK_TO_DEFAULT_POSITION}, {@link * #COMMAND_PREPARE_STOP}, {@link #COMMAND_SEEK_TO_DEFAULT_POSITION}, {@link
* #COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM}, {@link #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM}, {@link * #COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM}, {@link #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM}, {@link
* #COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM}, {@link #COMMAND_SEEK_TO_MEDIA_ITEM}, {@link * #COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM}, {@link #COMMAND_SEEK_TO_MEDIA_ITEM}, {@link
* #COMMAND_SET_FAST_FORWARD_INCREMENT}, {@link #COMMAND_FAST_FORWARD}, {@link * #COMMAND_SET_SEEK_FORWARD_INCREMENT}, {@link #COMMAND_SEEK_FORWARD}, {@link
* #COMMAND_SET_REWIND_INCREMENT}, {@link #COMMAND_REWIND}, {@link #COMMAND_SET_SPEED_AND_PITCH}, * #COMMAND_SET_SEEK_BACK_INCREMENT}, {@link #COMMAND_SEEK_BACK}, {@link
* {@link #COMMAND_SET_SHUFFLE_MODE}, {@link #COMMAND_SET_REPEAT_MODE}, {@link * #COMMAND_SET_SPEED_AND_PITCH}, {@link #COMMAND_SET_SHUFFLE_MODE}, {@link
* #COMMAND_GET_CURRENT_MEDIA_ITEM}, {@link #COMMAND_GET_MEDIA_ITEMS}, {@link * #COMMAND_SET_REPEAT_MODE}, {@link #COMMAND_GET_CURRENT_MEDIA_ITEM}, {@link
* #COMMAND_GET_MEDIA_ITEMS_METADATA}, {@link #COMMAND_SET_MEDIA_ITEMS_METADATA}, {@link * #COMMAND_GET_MEDIA_ITEMS}, {@link #COMMAND_GET_MEDIA_ITEMS_METADATA}, {@link
* #COMMAND_CHANGE_MEDIA_ITEMS}, {@link #COMMAND_GET_AUDIO_ATTRIBUTES}, {@link * #COMMAND_SET_MEDIA_ITEMS_METADATA}, {@link #COMMAND_CHANGE_MEDIA_ITEMS}, {@link
* #COMMAND_GET_VOLUME}, {@link #COMMAND_GET_DEVICE_VOLUME}, {@link #COMMAND_SET_VOLUME}, {@link * #COMMAND_GET_AUDIO_ATTRIBUTES}, {@link #COMMAND_GET_VOLUME}, {@link
* #COMMAND_SET_DEVICE_VOLUME}, {@link #COMMAND_ADJUST_DEVICE_VOLUME}, {@link * #COMMAND_GET_DEVICE_VOLUME}, {@link #COMMAND_SET_VOLUME}, {@link #COMMAND_SET_DEVICE_VOLUME},
* #COMMAND_SET_VIDEO_SURFACE} or {@link #COMMAND_GET_TEXT}. * {@link #COMMAND_ADJUST_DEVICE_VOLUME}, {@link #COMMAND_SET_VIDEO_SURFACE} or {@link
* #COMMAND_GET_TEXT}.
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@ -1175,10 +1176,10 @@ public interface Player {
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, COMMAND_SEEK_TO_NEXT_MEDIA_ITEM,
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM,
COMMAND_SEEK_TO_MEDIA_ITEM, COMMAND_SEEK_TO_MEDIA_ITEM,
COMMAND_SET_FAST_FORWARD_INCREMENT, COMMAND_SET_SEEK_FORWARD_INCREMENT,
COMMAND_FAST_FORWARD, COMMAND_SEEK_FORWARD,
COMMAND_SET_REWIND_INCREMENT, COMMAND_SET_SEEK_BACK_INCREMENT,
COMMAND_REWIND, COMMAND_SEEK_BACK,
COMMAND_SET_SPEED_AND_PITCH, COMMAND_SET_SPEED_AND_PITCH,
COMMAND_SET_SHUFFLE_MODE, COMMAND_SET_SHUFFLE_MODE,
COMMAND_SET_REPEAT_MODE, COMMAND_SET_REPEAT_MODE,
@ -1211,14 +1212,14 @@ public interface Player {
int COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM = 6; int COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM = 6;
/** Command to seek anywhere in any window. */ /** Command to seek anywhere in any window. */
int COMMAND_SEEK_TO_MEDIA_ITEM = 7; int COMMAND_SEEK_TO_MEDIA_ITEM = 7;
/** Command to set the fast forward increment. */ /** Command to set the seek forward increment. */
int COMMAND_SET_FAST_FORWARD_INCREMENT = 8; int COMMAND_SET_SEEK_FORWARD_INCREMENT = 8;
/** Command to fast forward into the current window. */ /** Command to seek forward into the current window. */
int COMMAND_FAST_FORWARD = 9; int COMMAND_SEEK_FORWARD = 9;
/** Command to set the rewind increment. */ /** Command to set the seek back increment. */
int COMMAND_SET_REWIND_INCREMENT = 10; int COMMAND_SET_SEEK_BACK_INCREMENT = 10;
/** Command to rewind into the current window. */ /** Command to seek back into the current window. */
int COMMAND_REWIND = 11; int COMMAND_SEEK_BACK = 11;
/** Command to set the playback speed and pitch. */ /** Command to set the playback speed and pitch. */
int COMMAND_SET_SPEED_AND_PITCH = 12; int COMMAND_SET_SPEED_AND_PITCH = 12;
/** Command to enable shuffling. */ /** Command to enable shuffling. */
@ -1625,46 +1626,46 @@ public interface Player {
void seekTo(int windowIndex, long positionMs); void seekTo(int windowIndex, long positionMs);
/** /**
* Sets the {@link #fastForward()} increment. * Sets the {@link #seekForward()} increment.
* *
* @param fastForwardIncrementMs The fast forward increment, in milliseconds. * @param seekForwardIncrementMs The seek forward increment, in milliseconds.
* @throws IllegalArgumentException If {@code fastForwardIncrementMs} is non-positive. * @throws IllegalArgumentException If {@code seekForwardIncrementMs} is non-positive.
*/ */
void setFastForwardIncrement(@IntRange(from = 1) long fastForwardIncrementMs); void setSeekForwardIncrement(@IntRange(from = 1) long seekForwardIncrementMs);
/** /**
* Returns the {@link #fastForward()} increment. * Returns the {@link #seekForward()} increment.
* *
* <p>The default value is {@link #DEFAULT_FAST_FORWARD_INCREMENT_MS}. * <p>The default value is {@link #DEFAULT_SEEK_FORWARD_INCREMENT_MS}.
* *
* @return The fast forward increment, in milliseconds. * @return The seek forward increment, in milliseconds.
* @see Listener#onFastForwardIncrementChanged(long) * @see Listener#onSeekForwardIncrementChanged(long)
*/ */
long getFastForwardIncrement(); long getSeekForwardIncrement();
/** Seeks forward in the current window by {@link #getFastForwardIncrement()} milliseconds. */ /** Seeks forward in the current window by {@link #getSeekForwardIncrement()} milliseconds. */
void fastForward(); void seekForward();
/** /**
* Sets the {@link #rewind()} increment. * Sets the {@link #seekBack()} increment.
* *
* @param rewindIncrementMs The rewind increment, in milliseconds. * @param seekBackIncrementMs The seek back increment, in milliseconds.
* @throws IllegalArgumentException If {@code rewindIncrementMs} is non-positive. * @throws IllegalArgumentException If {@code seekBackIncrementMs} is non-positive.
*/ */
void setRewindIncrement(@IntRange(from = 1) long rewindIncrementMs); void setSeekBackIncrement(@IntRange(from = 1) long seekBackIncrementMs);
/** /**
* Returns the {@link #rewind()} increment. * Returns the {@link #seekBack()} increment.
* *
* <p>The default value is {@link #DEFAULT_REWIND_INCREMENT_MS}. * <p>The default value is {@link #DEFAULT_SEEK_BACK_INCREMENT_MS}.
* *
* @return The rewind increment, in milliseconds. * @return The seek back increment, in milliseconds.
* @see Listener#onRewindIncrementChanged(long) * @see Listener#onSeekBackIncrementChanged(long)
*/ */
long getRewindIncrement(); long getSeekBackIncrement();
/** Seeks back in the current window by {@link #getRewindIncrement()} milliseconds. */ /** Seeks back in the current window by {@link #getSeekBackIncrement()} milliseconds. */
void rewind(); void seekBack();
/** /**
* Returns whether a previous window exists, which may depend on the current repeat mode and * Returns whether a previous window exists, which may depend on the current repeat mode and

View File

@ -104,8 +104,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
private Commands availableCommands; private Commands availableCommands;
private MediaMetadata mediaMetadata; private MediaMetadata mediaMetadata;
private MediaMetadata playlistMetadata; private MediaMetadata playlistMetadata;
private long fastForwardIncrementMs; private long seekForwardIncrementMs;
private long rewindIncrementMs; private long seekBackIncrementMs;
// Playback information when there is no pending seek/set source operation. // Playback information when there is no pending seek/set source operation.
private PlaybackInfo playbackInfo; private PlaybackInfo playbackInfo;
@ -197,8 +197,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
.addAll( .addAll(
COMMAND_PLAY_PAUSE, COMMAND_PLAY_PAUSE,
COMMAND_PREPARE_STOP, COMMAND_PREPARE_STOP,
COMMAND_SET_FAST_FORWARD_INCREMENT, COMMAND_SET_SEEK_FORWARD_INCREMENT,
COMMAND_SET_REWIND_INCREMENT, COMMAND_SET_SEEK_BACK_INCREMENT,
COMMAND_SET_SPEED_AND_PITCH, COMMAND_SET_SPEED_AND_PITCH,
COMMAND_SET_SHUFFLE_MODE, COMMAND_SET_SHUFFLE_MODE,
COMMAND_SET_REPEAT_MODE, COMMAND_SET_REPEAT_MODE,
@ -217,8 +217,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
.build(); .build();
mediaMetadata = MediaMetadata.EMPTY; mediaMetadata = MediaMetadata.EMPTY;
playlistMetadata = MediaMetadata.EMPTY; playlistMetadata = MediaMetadata.EMPTY;
fastForwardIncrementMs = DEFAULT_FAST_FORWARD_INCREMENT_MS; seekForwardIncrementMs = DEFAULT_SEEK_FORWARD_INCREMENT_MS;
rewindIncrementMs = DEFAULT_REWIND_INCREMENT_MS; seekBackIncrementMs = DEFAULT_SEEK_BACK_INCREMENT_MS;
maskingWindowIndex = C.INDEX_UNSET; maskingWindowIndex = C.INDEX_UNSET;
playbackInfoUpdateHandler = clock.createHandler(applicationLooper, /* callback= */ null); playbackInfoUpdateHandler = clock.createHandler(applicationLooper, /* callback= */ null);
playbackInfoUpdateListener = playbackInfoUpdateListener =
@ -720,37 +720,37 @@ import java.util.concurrent.CopyOnWriteArraySet;
} }
@Override @Override
public void setFastForwardIncrement(long fastForwardIncrementMs) { public void setSeekForwardIncrement(long seekForwardIncrementMs) {
checkArgument(fastForwardIncrementMs > 0); checkArgument(seekForwardIncrementMs > 0);
if (this.fastForwardIncrementMs != fastForwardIncrementMs) { if (this.seekForwardIncrementMs != seekForwardIncrementMs) {
this.fastForwardIncrementMs = fastForwardIncrementMs; this.seekForwardIncrementMs = seekForwardIncrementMs;
listeners.queueEvent( listeners.queueEvent(
Player.EVENT_FAST_FORWARD_INCREMENT_CHANGED, Player.EVENT_SEEK_FORWARD_INCREMENT_CHANGED,
listener -> listener.onFastForwardIncrementChanged(fastForwardIncrementMs)); listener -> listener.onSeekForwardIncrementChanged(seekForwardIncrementMs));
listeners.flushEvents(); listeners.flushEvents();
} }
} }
@Override @Override
public long getFastForwardIncrement() { public long getSeekForwardIncrement() {
return fastForwardIncrementMs; return seekForwardIncrementMs;
} }
@Override @Override
public void setRewindIncrement(long rewindIncrementMs) { public void setSeekBackIncrement(long seekBackIncrementMs) {
checkArgument(rewindIncrementMs > 0); checkArgument(seekBackIncrementMs > 0);
if (this.rewindIncrementMs != rewindIncrementMs) { if (this.seekBackIncrementMs != seekBackIncrementMs) {
this.rewindIncrementMs = rewindIncrementMs; this.seekBackIncrementMs = seekBackIncrementMs;
listeners.queueEvent( listeners.queueEvent(
Player.EVENT_REWIND_INCREMENT_CHANGED, Player.EVENT_SEEK_BACK_INCREMENT_CHANGED,
listener -> listener.onRewindIncrementChanged(rewindIncrementMs)); listener -> listener.onSeekBackIncrementChanged(seekBackIncrementMs));
listeners.flushEvents(); listeners.flushEvents();
} }
} }
@Override @Override
public long getRewindIncrement() { public long getSeekBackIncrement() {
return rewindIncrementMs; return seekBackIncrementMs;
} }
@Override @Override

View File

@ -1563,27 +1563,27 @@ public class SimpleExoPlayer extends BasePlayer
} }
@Override @Override
public void setFastForwardIncrement(long fastForwardIncrementMs) { public void setSeekForwardIncrement(long seekForwardIncrementMs) {
verifyApplicationThread(); verifyApplicationThread();
player.setFastForwardIncrement(fastForwardIncrementMs); player.setSeekForwardIncrement(seekForwardIncrementMs);
} }
@Override @Override
public long getFastForwardIncrement() { public long getSeekForwardIncrement() {
verifyApplicationThread(); verifyApplicationThread();
return player.getFastForwardIncrement(); return player.getSeekForwardIncrement();
} }
@Override @Override
public void setRewindIncrement(long rewindIncrementMs) { public void setSeekBackIncrement(long seekBackIncrementMs) {
verifyApplicationThread(); verifyApplicationThread();
player.setRewindIncrement(rewindIncrementMs); player.setSeekBackIncrement(seekBackIncrementMs);
} }
@Override @Override
public long getRewindIncrement() { public long getSeekBackIncrement() {
verifyApplicationThread(); verifyApplicationThread();
return player.getRewindIncrement(); return player.getSeekBackIncrement();
} }
@Override @Override

View File

@ -743,21 +743,21 @@ public class AnalyticsCollector
} }
@Override @Override
public void onFastForwardIncrementChanged(long fastForwardIncrementMs) { public void onSeekForwardIncrementChanged(long seekForwardIncrementMs) {
EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime(); EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime();
sendEvent( sendEvent(
eventTime, eventTime,
AnalyticsListener.EVENT_FAST_FORWARD_INCREMENT_CHANGED, AnalyticsListener.EVENT_SEEK_FORWARD_INCREMENT_CHANGED,
listener -> listener.onFastForwardIncrementChanged(eventTime, fastForwardIncrementMs)); listener -> listener.onSeekForwardIncrementChanged(eventTime, seekForwardIncrementMs));
} }
@Override @Override
public void onRewindIncrementChanged(long rewindIncrementMs) { public void onSeekBackIncrementChanged(long seekBackIncrementMs) {
EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime(); EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime();
sendEvent( sendEvent(
eventTime, eventTime,
AnalyticsListener.EVENT_REWIND_INCREMENT_CHANGED, AnalyticsListener.EVENT_SEEK_BACK_INCREMENT_CHANGED,
listener -> listener.onRewindIncrementChanged(eventTime, rewindIncrementMs)); listener -> listener.onSeekBackIncrementChanged(eventTime, seekBackIncrementMs));
} }
@Override @Override

View File

@ -172,8 +172,8 @@ public interface AnalyticsListener {
EVENT_AVAILABLE_COMMANDS_CHANGED, EVENT_AVAILABLE_COMMANDS_CHANGED,
EVENT_MEDIA_METADATA_CHANGED, EVENT_MEDIA_METADATA_CHANGED,
EVENT_PLAYLIST_METADATA_CHANGED, EVENT_PLAYLIST_METADATA_CHANGED,
EVENT_FAST_FORWARD_INCREMENT_CHANGED, EVENT_SEEK_FORWARD_INCREMENT_CHANGED,
EVENT_REWIND_INCREMENT_CHANGED, EVENT_SEEK_BACK_INCREMENT_CHANGED,
EVENT_LOAD_STARTED, EVENT_LOAD_STARTED,
EVENT_LOAD_COMPLETED, EVENT_LOAD_COMPLETED,
EVENT_LOAD_CANCELED, EVENT_LOAD_CANCELED,
@ -256,10 +256,10 @@ public interface AnalyticsListener {
int EVENT_MEDIA_METADATA_CHANGED = Player.EVENT_MEDIA_METADATA_CHANGED; int EVENT_MEDIA_METADATA_CHANGED = Player.EVENT_MEDIA_METADATA_CHANGED;
/** {@link Player#getPlaylistMetadata()} changed. */ /** {@link Player#getPlaylistMetadata()} changed. */
int EVENT_PLAYLIST_METADATA_CHANGED = Player.EVENT_PLAYLIST_METADATA_CHANGED; int EVENT_PLAYLIST_METADATA_CHANGED = Player.EVENT_PLAYLIST_METADATA_CHANGED;
/** {@link Player#getFastForwardIncrement()} changed. */ /** {@link Player#getSeekForwardIncrement()} changed. */
int EVENT_FAST_FORWARD_INCREMENT_CHANGED = Player.EVENT_FAST_FORWARD_INCREMENT_CHANGED; int EVENT_SEEK_FORWARD_INCREMENT_CHANGED = Player.EVENT_SEEK_FORWARD_INCREMENT_CHANGED;
/** {@link Player#getRewindIncrement()} changed. */ /** {@link Player#getSeekBackIncrement()} changed. */
int EVENT_REWIND_INCREMENT_CHANGED = Player.EVENT_REWIND_INCREMENT_CHANGED; int EVENT_SEEK_BACK_INCREMENT_CHANGED = Player.EVENT_SEEK_BACK_INCREMENT_CHANGED;
/** A source started loading data. */ /** A source started loading data. */
int EVENT_LOAD_STARTED = 1000; // Intentional gap to leave space for new Player events int EVENT_LOAD_STARTED = 1000; // Intentional gap to leave space for new Player events
/** A source started completed loading data. */ /** A source started completed loading data. */
@ -596,20 +596,20 @@ public interface AnalyticsListener {
EventTime eventTime, PlaybackParameters playbackParameters) {} EventTime eventTime, PlaybackParameters playbackParameters) {}
/** /**
* Called when the fast forward increment changed. * Called when the seek forward increment changed.
* *
* @param eventTime The event time. * @param eventTime The event time.
* @param fastForwardIncrementMs The fast forward increment, in milliseconds. * @param seekForwardIncrementMs The seek forward increment, in milliseconds.
*/ */
default void onFastForwardIncrementChanged(EventTime eventTime, long fastForwardIncrementMs) {} default void onSeekForwardIncrementChanged(EventTime eventTime, long seekForwardIncrementMs) {}
/** /**
* Called when the rewind increment changed. * Called when the seek back increment changed.
* *
* @param eventTime The event time. * @param eventTime The event time.
* @param rewindIncrementMs The rewind increment, in milliseconds. * @param seekBackIncrementMs The seek back increment, in milliseconds.
*/ */
default void onRewindIncrementChanged(EventTime eventTime, long rewindIncrementMs) {} default void onSeekBackIncrementChanged(EventTime eventTime, long seekBackIncrementMs) {}
/** /**
* Called when the repeat mode changed. * Called when the repeat mode changed.

View File

@ -17,7 +17,6 @@ package com.google.android.exoplayer2;
import static com.google.android.exoplayer2.Player.COMMAND_ADJUST_DEVICE_VOLUME; import static com.google.android.exoplayer2.Player.COMMAND_ADJUST_DEVICE_VOLUME;
import static com.google.android.exoplayer2.Player.COMMAND_CHANGE_MEDIA_ITEMS; import static com.google.android.exoplayer2.Player.COMMAND_CHANGE_MEDIA_ITEMS;
import static com.google.android.exoplayer2.Player.COMMAND_FAST_FORWARD;
import static com.google.android.exoplayer2.Player.COMMAND_GET_AUDIO_ATTRIBUTES; import static com.google.android.exoplayer2.Player.COMMAND_GET_AUDIO_ATTRIBUTES;
import static com.google.android.exoplayer2.Player.COMMAND_GET_CURRENT_MEDIA_ITEM; import static com.google.android.exoplayer2.Player.COMMAND_GET_CURRENT_MEDIA_ITEM;
import static com.google.android.exoplayer2.Player.COMMAND_GET_DEVICE_VOLUME; import static com.google.android.exoplayer2.Player.COMMAND_GET_DEVICE_VOLUME;
@ -27,23 +26,24 @@ import static com.google.android.exoplayer2.Player.COMMAND_GET_TEXT;
import static com.google.android.exoplayer2.Player.COMMAND_GET_VOLUME; import static com.google.android.exoplayer2.Player.COMMAND_GET_VOLUME;
import static com.google.android.exoplayer2.Player.COMMAND_PLAY_PAUSE; import static com.google.android.exoplayer2.Player.COMMAND_PLAY_PAUSE;
import static com.google.android.exoplayer2.Player.COMMAND_PREPARE_STOP; import static com.google.android.exoplayer2.Player.COMMAND_PREPARE_STOP;
import static com.google.android.exoplayer2.Player.COMMAND_REWIND; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_BACK;
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_FORWARD;
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM;
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_DEFAULT_POSITION; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_DEFAULT_POSITION;
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_MEDIA_ITEM; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_MEDIA_ITEM;
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM;
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM;
import static com.google.android.exoplayer2.Player.COMMAND_SET_DEVICE_VOLUME; import static com.google.android.exoplayer2.Player.COMMAND_SET_DEVICE_VOLUME;
import static com.google.android.exoplayer2.Player.COMMAND_SET_FAST_FORWARD_INCREMENT;
import static com.google.android.exoplayer2.Player.COMMAND_SET_MEDIA_ITEMS_METADATA; import static com.google.android.exoplayer2.Player.COMMAND_SET_MEDIA_ITEMS_METADATA;
import static com.google.android.exoplayer2.Player.COMMAND_SET_REPEAT_MODE; import static com.google.android.exoplayer2.Player.COMMAND_SET_REPEAT_MODE;
import static com.google.android.exoplayer2.Player.COMMAND_SET_REWIND_INCREMENT; import static com.google.android.exoplayer2.Player.COMMAND_SET_SEEK_BACK_INCREMENT;
import static com.google.android.exoplayer2.Player.COMMAND_SET_SEEK_FORWARD_INCREMENT;
import static com.google.android.exoplayer2.Player.COMMAND_SET_SHUFFLE_MODE; import static com.google.android.exoplayer2.Player.COMMAND_SET_SHUFFLE_MODE;
import static com.google.android.exoplayer2.Player.COMMAND_SET_SPEED_AND_PITCH; import static com.google.android.exoplayer2.Player.COMMAND_SET_SPEED_AND_PITCH;
import static com.google.android.exoplayer2.Player.COMMAND_SET_VIDEO_SURFACE; import static com.google.android.exoplayer2.Player.COMMAND_SET_VIDEO_SURFACE;
import static com.google.android.exoplayer2.Player.COMMAND_SET_VOLUME; import static com.google.android.exoplayer2.Player.COMMAND_SET_VOLUME;
import static com.google.android.exoplayer2.Player.DEFAULT_FAST_FORWARD_INCREMENT_MS; import static com.google.android.exoplayer2.Player.DEFAULT_SEEK_BACK_INCREMENT_MS;
import static com.google.android.exoplayer2.Player.DEFAULT_REWIND_INCREMENT_MS; import static com.google.android.exoplayer2.Player.DEFAULT_SEEK_FORWARD_INCREMENT_MS;
import static com.google.android.exoplayer2.Player.STATE_ENDED; import static com.google.android.exoplayer2.Player.STATE_ENDED;
import static com.google.android.exoplayer2.robolectric.RobolectricUtil.runMainLooperUntil; import static com.google.android.exoplayer2.robolectric.RobolectricUtil.runMainLooperUntil;
import static com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.playUntilPosition; import static com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.playUntilPosition;
@ -8171,10 +8171,10 @@ public final class ExoPlayerTest {
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM)).isTrue(); assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)).isTrue(); assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SET_FAST_FORWARD_INCREMENT)).isTrue(); assertThat(player.isCommandAvailable(COMMAND_SET_SEEK_FORWARD_INCREMENT)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_FAST_FORWARD)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_FORWARD)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SET_REWIND_INCREMENT)).isTrue(); assertThat(player.isCommandAvailable(COMMAND_SET_SEEK_BACK_INCREMENT)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_REWIND)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_BACK)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SET_SPEED_AND_PITCH)).isTrue(); assertThat(player.isCommandAvailable(COMMAND_SET_SPEED_AND_PITCH)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SET_SHUFFLE_MODE)).isTrue(); assertThat(player.isCommandAvailable(COMMAND_SET_SHUFFLE_MODE)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SET_REPEAT_MODE)).isTrue(); assertThat(player.isCommandAvailable(COMMAND_SET_REPEAT_MODE)).isTrue();
@ -8222,8 +8222,8 @@ public final class ExoPlayerTest {
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_FAST_FORWARD)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_FORWARD)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_REWIND)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_BACK)).isFalse();
} }
@Test @Test
@ -8242,8 +8242,8 @@ public final class ExoPlayerTest {
runUntilPlaybackState(player, Player.STATE_READY); runUntilPlaybackState(player, Player.STATE_READY);
assertThat(player.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_FAST_FORWARD)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_FORWARD)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_REWIND)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_BACK)).isFalse();
} }
@Test @Test
@ -8336,20 +8336,20 @@ public final class ExoPlayerTest {
Player.Commands commandsWithSeekInCurrentAndToNext = Player.Commands commandsWithSeekInCurrentAndToNext =
createWithDefaultCommands( createWithDefaultCommands(
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM, COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM,
COMMAND_FAST_FORWARD, COMMAND_SEEK_FORWARD,
COMMAND_REWIND, COMMAND_SEEK_BACK,
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM); COMMAND_SEEK_TO_NEXT_MEDIA_ITEM);
Player.Commands commandsWithSeekInCurrentAndToPrevious = Player.Commands commandsWithSeekInCurrentAndToPrevious =
createWithDefaultCommands( createWithDefaultCommands(
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM, COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM,
COMMAND_FAST_FORWARD, COMMAND_SEEK_FORWARD,
COMMAND_REWIND, COMMAND_SEEK_BACK,
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM); COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM);
Player.Commands commandsWithSeekAnywhere = Player.Commands commandsWithSeekAnywhere =
createWithDefaultCommands( createWithDefaultCommands(
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM, COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM,
COMMAND_FAST_FORWARD, COMMAND_SEEK_FORWARD,
COMMAND_REWIND, COMMAND_SEEK_BACK,
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, COMMAND_SEEK_TO_NEXT_MEDIA_ITEM,
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM); COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM);
Player.Listener mockListener = mock(Player.Listener.class); Player.Listener mockListener = mock(Player.Listener.class);
@ -10398,20 +10398,20 @@ public final class ExoPlayerTest {
} }
@Test @Test
public void setFastForwardIncrement_notifiesFastForwardIncrementChanged() { public void setSeekForwardIncrement_notifiesSeekForwardIncrementChanged() {
ExoPlayer player = new TestExoPlayerBuilder(context).build(); ExoPlayer player = new TestExoPlayerBuilder(context).build();
Player.Listener listener = mock(Player.Listener.class); Player.Listener listener = mock(Player.Listener.class);
player.addListener(listener); player.addListener(listener);
long fastForwardIncrementMs = 1000; long seekForwardIncrementMs = 1000;
player.setFastForwardIncrement(fastForwardIncrementMs); player.setSeekForwardIncrement(seekForwardIncrementMs);
verify(listener).onFastForwardIncrementChanged(fastForwardIncrementMs); verify(listener).onSeekForwardIncrementChanged(seekForwardIncrementMs);
assertThat(player.getFastForwardIncrement()).isEqualTo(fastForwardIncrementMs); assertThat(player.getSeekForwardIncrement()).isEqualTo(seekForwardIncrementMs);
} }
@Test @Test
public void fastForward_callsOnPositionDiscontinuity() throws Exception { public void seekForward_callsOnPositionDiscontinuity() throws Exception {
ExoPlayer player = new TestExoPlayerBuilder(context).build(); ExoPlayer player = new TestExoPlayerBuilder(context).build();
Player.Listener listener = mock(Player.Listener.class); Player.Listener listener = mock(Player.Listener.class);
player.addListener(listener); player.addListener(listener);
@ -10420,12 +10420,12 @@ public final class ExoPlayerTest {
new TimelineWindowDefinition( new TimelineWindowDefinition(
/* isSeekable= */ true, /* isSeekable= */ true,
/* isDynamic= */ true, /* isDynamic= */ true,
/* durationUs= */ C.msToUs(2 * DEFAULT_FAST_FORWARD_INCREMENT_MS))); /* durationUs= */ C.msToUs(2 * DEFAULT_SEEK_FORWARD_INCREMENT_MS)));
player.setMediaSource(new FakeMediaSource(fakeTimeline)); player.setMediaSource(new FakeMediaSource(fakeTimeline));
player.prepare(); player.prepare();
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY); TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY);
player.fastForward(); player.seekForward();
ArgumentCaptor<Player.PositionInfo> oldPosition = ArgumentCaptor<Player.PositionInfo> oldPosition =
ArgumentCaptor.forClass(Player.PositionInfo.class); ArgumentCaptor.forClass(Player.PositionInfo.class);
@ -10442,47 +10442,47 @@ public final class ExoPlayerTest {
assertThat(oldPositions.get(0).positionMs).isEqualTo(0); assertThat(oldPositions.get(0).positionMs).isEqualTo(0);
assertThat(oldPositions.get(0).contentPositionMs).isEqualTo(0); assertThat(oldPositions.get(0).contentPositionMs).isEqualTo(0);
assertThat(newPositions.get(0).windowIndex).isEqualTo(0); assertThat(newPositions.get(0).windowIndex).isEqualTo(0);
assertThat(newPositions.get(0).positionMs).isEqualTo(DEFAULT_FAST_FORWARD_INCREMENT_MS); assertThat(newPositions.get(0).positionMs).isEqualTo(DEFAULT_SEEK_FORWARD_INCREMENT_MS);
assertThat(newPositions.get(0).contentPositionMs).isEqualTo(DEFAULT_FAST_FORWARD_INCREMENT_MS); assertThat(newPositions.get(0).contentPositionMs).isEqualTo(DEFAULT_SEEK_FORWARD_INCREMENT_MS);
player.release(); player.release();
} }
@Test @Test
public void fastForward_pastDuration_seeksToDuration() throws Exception { public void seekForward_pastDuration_seeksToDuration() throws Exception {
ExoPlayer player = new TestExoPlayerBuilder(context).build(); ExoPlayer player = new TestExoPlayerBuilder(context).build();
Timeline fakeTimeline = Timeline fakeTimeline =
new FakeTimeline( new FakeTimeline(
new TimelineWindowDefinition( new TimelineWindowDefinition(
/* isSeekable= */ true, /* isSeekable= */ true,
/* isDynamic= */ true, /* isDynamic= */ true,
/* durationUs= */ C.msToUs(DEFAULT_FAST_FORWARD_INCREMENT_MS / 2))); /* durationUs= */ C.msToUs(DEFAULT_SEEK_FORWARD_INCREMENT_MS / 2)));
player.setMediaSource(new FakeMediaSource(fakeTimeline)); player.setMediaSource(new FakeMediaSource(fakeTimeline));
player.prepare(); player.prepare();
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY); TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY);
player.fastForward(); player.seekForward();
assertThat(player.getCurrentPosition()).isEqualTo(DEFAULT_FAST_FORWARD_INCREMENT_MS / 2); assertThat(player.getCurrentPosition()).isEqualTo(DEFAULT_SEEK_FORWARD_INCREMENT_MS / 2);
player.release(); player.release();
} }
@Test @Test
public void setRewindIncrement_notifiesRewindIncrementChanged() { public void setSeekBackIncrement_notifiesSeekBackIncrementChanged() {
ExoPlayer player = new TestExoPlayerBuilder(context).build(); ExoPlayer player = new TestExoPlayerBuilder(context).build();
Player.Listener listener = mock(Player.Listener.class); Player.Listener listener = mock(Player.Listener.class);
player.addListener(listener); player.addListener(listener);
long rewindIncrementMs = 1000; long seekBackIncrementMs = 1000;
player.setRewindIncrement(rewindIncrementMs); player.setSeekBackIncrement(seekBackIncrementMs);
verify(listener).onRewindIncrementChanged(rewindIncrementMs); verify(listener).onSeekBackIncrementChanged(seekBackIncrementMs);
assertThat(player.getRewindIncrement()).isEqualTo(rewindIncrementMs); assertThat(player.getSeekBackIncrement()).isEqualTo(seekBackIncrementMs);
} }
@Test @Test
public void rewind_callsOnPositionDiscontinuity() throws Exception { public void seekBack_callsOnPositionDiscontinuity() throws Exception {
ExoPlayer player = new TestExoPlayerBuilder(context).build(); ExoPlayer player = new TestExoPlayerBuilder(context).build();
Player.Listener listener = mock(Player.Listener.class); Player.Listener listener = mock(Player.Listener.class);
player.addListener(listener); player.addListener(listener);
@ -10491,13 +10491,13 @@ public final class ExoPlayerTest {
new TimelineWindowDefinition( new TimelineWindowDefinition(
/* isSeekable= */ true, /* isSeekable= */ true,
/* isDynamic= */ true, /* isDynamic= */ true,
/* durationUs= */ C.msToUs(3 * DEFAULT_REWIND_INCREMENT_MS))); /* durationUs= */ C.msToUs(3 * DEFAULT_SEEK_BACK_INCREMENT_MS)));
player.setMediaSource(new FakeMediaSource(fakeTimeline)); player.setMediaSource(new FakeMediaSource(fakeTimeline));
player.prepare(); player.prepare();
TestPlayerRunHelper.playUntilPosition( TestPlayerRunHelper.playUntilPosition(
player, /* windowIndex= */ 0, /* positionMs= */ 2 * DEFAULT_REWIND_INCREMENT_MS); player, /* windowIndex= */ 0, /* positionMs= */ 2 * DEFAULT_SEEK_BACK_INCREMENT_MS);
player.rewind(); player.seekBack();
ArgumentCaptor<Player.PositionInfo> oldPosition = ArgumentCaptor<Player.PositionInfo> oldPosition =
ArgumentCaptor.forClass(Player.PositionInfo.class); ArgumentCaptor.forClass(Player.PositionInfo.class);
@ -10512,33 +10512,37 @@ public final class ExoPlayerTest {
List<Player.PositionInfo> newPositions = newPosition.getAllValues(); List<Player.PositionInfo> newPositions = newPosition.getAllValues();
assertThat(oldPositions.get(0).windowIndex).isEqualTo(0); assertThat(oldPositions.get(0).windowIndex).isEqualTo(0);
assertThat(oldPositions.get(0).positionMs) assertThat(oldPositions.get(0).positionMs)
.isIn(Range.closed(2 * DEFAULT_REWIND_INCREMENT_MS - 20, 2 * DEFAULT_REWIND_INCREMENT_MS)); .isIn(
Range.closed(
2 * DEFAULT_SEEK_BACK_INCREMENT_MS - 20, 2 * DEFAULT_SEEK_BACK_INCREMENT_MS));
assertThat(oldPositions.get(0).contentPositionMs) assertThat(oldPositions.get(0).contentPositionMs)
.isIn(Range.closed(2 * DEFAULT_REWIND_INCREMENT_MS - 20, 2 * DEFAULT_REWIND_INCREMENT_MS)); .isIn(
Range.closed(
2 * DEFAULT_SEEK_BACK_INCREMENT_MS - 20, 2 * DEFAULT_SEEK_BACK_INCREMENT_MS));
assertThat(newPositions.get(0).windowIndex).isEqualTo(0); assertThat(newPositions.get(0).windowIndex).isEqualTo(0);
assertThat(newPositions.get(0).positionMs) assertThat(newPositions.get(0).positionMs)
.isIn(Range.closed(DEFAULT_REWIND_INCREMENT_MS - 20, DEFAULT_REWIND_INCREMENT_MS)); .isIn(Range.closed(DEFAULT_SEEK_BACK_INCREMENT_MS - 20, DEFAULT_SEEK_BACK_INCREMENT_MS));
assertThat(newPositions.get(0).contentPositionMs) assertThat(newPositions.get(0).contentPositionMs)
.isIn(Range.closed(DEFAULT_REWIND_INCREMENT_MS - 20, DEFAULT_REWIND_INCREMENT_MS)); .isIn(Range.closed(DEFAULT_SEEK_BACK_INCREMENT_MS - 20, DEFAULT_SEEK_BACK_INCREMENT_MS));
player.release(); player.release();
} }
@Test @Test
public void rewind_pastZero_seeksToZero() throws Exception { public void seekBack_pastZero_seeksToZero() throws Exception {
ExoPlayer player = new TestExoPlayerBuilder(context).build(); ExoPlayer player = new TestExoPlayerBuilder(context).build();
Timeline fakeTimeline = Timeline fakeTimeline =
new FakeTimeline( new FakeTimeline(
new TimelineWindowDefinition( new TimelineWindowDefinition(
/* isSeekable= */ true, /* isSeekable= */ true,
/* isDynamic= */ true, /* isDynamic= */ true,
/* durationUs= */ C.msToUs(DEFAULT_REWIND_INCREMENT_MS))); /* durationUs= */ C.msToUs(DEFAULT_SEEK_BACK_INCREMENT_MS)));
player.setMediaSource(new FakeMediaSource(fakeTimeline)); player.setMediaSource(new FakeMediaSource(fakeTimeline));
player.prepare(); player.prepare();
TestPlayerRunHelper.playUntilPosition( TestPlayerRunHelper.playUntilPosition(
player, /* windowIndex= */ 0, /* positionMs= */ DEFAULT_REWIND_INCREMENT_MS / 2); player, /* windowIndex= */ 0, /* positionMs= */ DEFAULT_SEEK_BACK_INCREMENT_MS / 2);
player.rewind(); player.seekBack();
assertThat(player.getCurrentPosition()).isEqualTo(0); assertThat(player.getCurrentPosition()).isEqualTo(0);
@ -10769,8 +10773,8 @@ public final class ExoPlayerTest {
builder.addAll( builder.addAll(
COMMAND_PLAY_PAUSE, COMMAND_PLAY_PAUSE,
COMMAND_PREPARE_STOP, COMMAND_PREPARE_STOP,
COMMAND_SET_FAST_FORWARD_INCREMENT, COMMAND_SET_SEEK_FORWARD_INCREMENT,
COMMAND_SET_REWIND_INCREMENT, COMMAND_SET_SEEK_BACK_INCREMENT,
COMMAND_SET_SPEED_AND_PITCH, COMMAND_SET_SPEED_AND_PITCH,
COMMAND_SET_SHUFFLE_MODE, COMMAND_SET_SHUFFLE_MODE,
COMMAND_SET_REPEAT_MODE, COMMAND_SET_REPEAT_MODE,

View File

@ -300,22 +300,22 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
} }
@Override @Override
public void setFastForwardIncrement(long fastForwardIncrementMs) { public void setSeekForwardIncrement(long seekForwardIncrementMs) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override @Override
public long getFastForwardIncrement() { public long getSeekForwardIncrement() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override @Override
public void setRewindIncrement(long rewindIncrementMs) { public void setSeekBackIncrement(long seekBackIncrementMs) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override @Override
public long getRewindIncrement() { public long getSeekBackIncrement() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }