From 15c565c7d73ab8fd76b630054ca21c8ca6f954ec Mon Sep 17 00:00:00 2001 From: kimvde Date: Tue, 6 Jul 2021 09:51:37 +0100 Subject: [PATCH] Rename fastForward/rewind to seekForward/Back in Player This matches the Javadoc better. PiperOrigin-RevId: 383228021 --- RELEASENOTES.md | 2 +- .../exoplayer2/ext/cast/CastPlayer.java | 44 +++--- .../exoplayer2/ext/cast/CastPlayerTest.java | 74 +++++----- .../google/android/exoplayer2/BasePlayer.java | 12 +- .../android/exoplayer2/ForwardingPlayer.java | 32 ++--- .../com/google/android/exoplayer2/Player.java | 127 +++++++++--------- .../android/exoplayer2/ExoPlayerImpl.java | 44 +++--- .../android/exoplayer2/SimpleExoPlayer.java | 16 +-- .../analytics/AnalyticsCollector.java | 12 +- .../analytics/AnalyticsListener.java | 24 ++-- .../android/exoplayer2/ExoPlayerTest.java | 110 +++++++-------- .../exoplayer2/testutil/StubExoPlayer.java | 8 +- 12 files changed, 255 insertions(+), 250 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 4d42413a78..57cf98da83 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -4,7 +4,7 @@ * Core Library: * 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 `ExoPlaybackException`: * `Player.getPlayerError` now returns a `PlaybackException`. diff --git a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java index 32d6304187..81b0b4b62c 100644 --- a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java +++ b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java @@ -94,8 +94,8 @@ public final class CastPlayer extends BasePlayer { COMMAND_PREPARE_STOP, COMMAND_SEEK_TO_DEFAULT_POSITION, COMMAND_SEEK_TO_MEDIA_ITEM, - COMMAND_SET_FAST_FORWARD_INCREMENT, - COMMAND_SET_REWIND_INCREMENT, + COMMAND_SET_SEEK_FORWARD_INCREMENT, + COMMAND_SET_SEEK_BACK_INCREMENT, COMMAND_SET_REPEAT_MODE, COMMAND_GET_CURRENT_MEDIA_ITEM, COMMAND_GET_MEDIA_ITEMS, @@ -144,8 +144,8 @@ public final class CastPlayer extends BasePlayer { private int pendingSeekWindowIndex; private long pendingSeekPositionMs; @Nullable private PositionInfo pendingMediaItemRemovalPosition; - private long fastForwardIncrementMs; - private long rewindIncrementMs; + private long seekForwardIncrementMs; + private long seekBackIncrementMs; /** * 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(); pendingSeekWindowIndex = C.INDEX_UNSET; pendingSeekPositionMs = C.TIME_UNSET; - fastForwardIncrementMs = DEFAULT_FAST_FORWARD_INCREMENT_MS; - rewindIncrementMs = DEFAULT_REWIND_INCREMENT_MS; + seekForwardIncrementMs = DEFAULT_SEEK_FORWARD_INCREMENT_MS; + seekBackIncrementMs = DEFAULT_SEEK_BACK_INCREMENT_MS; SessionManager sessionManager = castContext.getSessionManager(); sessionManager.addSessionManagerListener(statusListener, CastSession.class); @@ -419,37 +419,37 @@ public final class CastPlayer extends BasePlayer { } @Override - public void setFastForwardIncrement(long fastForwardIncrementMs) { - checkArgument(fastForwardIncrementMs > 0); - if (this.fastForwardIncrementMs != fastForwardIncrementMs) { - this.fastForwardIncrementMs = fastForwardIncrementMs; + public void setSeekForwardIncrement(long seekForwardIncrementMs) { + checkArgument(seekForwardIncrementMs > 0); + if (this.seekForwardIncrementMs != seekForwardIncrementMs) { + this.seekForwardIncrementMs = seekForwardIncrementMs; listeners.queueEvent( - Player.EVENT_FAST_FORWARD_INCREMENT_CHANGED, - listener -> listener.onFastForwardIncrementChanged(fastForwardIncrementMs)); + Player.EVENT_SEEK_FORWARD_INCREMENT_CHANGED, + listener -> listener.onSeekForwardIncrementChanged(seekForwardIncrementMs)); listeners.flushEvents(); } } @Override - public long getFastForwardIncrement() { - return fastForwardIncrementMs; + public long getSeekForwardIncrement() { + return seekForwardIncrementMs; } @Override - public void setRewindIncrement(long rewindIncrementMs) { - checkArgument(rewindIncrementMs > 0); - if (this.rewindIncrementMs != rewindIncrementMs) { - this.rewindIncrementMs = rewindIncrementMs; + public void setSeekBackIncrement(long seekBackIncrementMs) { + checkArgument(seekBackIncrementMs > 0); + if (this.seekBackIncrementMs != seekBackIncrementMs) { + this.seekBackIncrementMs = seekBackIncrementMs; listeners.queueEvent( - Player.EVENT_REWIND_INCREMENT_CHANGED, - listener -> listener.onRewindIncrementChanged(rewindIncrementMs)); + Player.EVENT_SEEK_BACK_INCREMENT_CHANGED, + listener -> listener.onSeekBackIncrementChanged(seekBackIncrementMs)); listeners.flushEvents(); } } @Override - public long getRewindIncrement() { - return rewindIncrementMs; + public long getSeekBackIncrement() { + return seekBackIncrementMs; } @Override diff --git a/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastPlayerTest.java b/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastPlayerTest.java index a9aa3b4062..81751a810b 100644 --- a/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastPlayerTest.java +++ b/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastPlayerTest.java @@ -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_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_CURRENT_MEDIA_ITEM; 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_PLAY_PAUSE; 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_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_NEXT_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_FAST_FORWARD_INCREMENT; 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_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_SPEED_AND_PITCH; 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.DEFAULT_FAST_FORWARD_INCREMENT_MS; -import static com.google.android.exoplayer2.Player.DEFAULT_REWIND_INCREMENT_MS; +import static com.google.android.exoplayer2.Player.DEFAULT_SEEK_BACK_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.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED; import static com.google.common.truth.Truth.assertThat; @@ -1107,30 +1107,30 @@ public class CastPlayerTest { } @Test - public void setFastForwardIncrement_notifiesFastForwardIncrementChanged() { - long fastForwardIncrementMs = 1000; + public void setSeekForwardIncrement_notifiesSeekForwardIncrementChanged() { + long seekForwardIncrementMs = 1000; - castPlayer.setFastForwardIncrement(fastForwardIncrementMs); + castPlayer.setSeekForwardIncrement(seekForwardIncrementMs); - verify(mockListener).onFastForwardIncrementChanged(fastForwardIncrementMs); - assertThat(castPlayer.getFastForwardIncrement()).isEqualTo(fastForwardIncrementMs); + verify(mockListener).onSeekForwardIncrementChanged(seekForwardIncrementMs); + assertThat(castPlayer.getSeekForwardIncrement()).isEqualTo(seekForwardIncrementMs); } @Test @SuppressWarnings("deprecation") // Mocks deprecated method used by the CastPlayer. - public void fastForward_notifiesPositionDiscontinuity() { + public void seekForward_notifiesPositionDiscontinuity() { when(mockRemoteMediaClient.seek(anyLong())).thenReturn(mockPendingResult); int[] mediaQueueItemIds = new int[] {1}; List mediaItems = createMediaItems(mediaQueueItemIds); int currentItemId = 1; 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; castPlayer.addMediaItems(mediaItems); updateTimeLine( mediaItems, mediaQueueItemIds, currentItemId, streamTypes, durationsMs, positionMs); - castPlayer.fastForward(); + castPlayer.seekForward(); Player.PositionInfo oldPosition = new Player.PositionInfo( @@ -1148,8 +1148,8 @@ public class CastPlayerTest { /* windowIndex= */ 0, /* periodUid= */ 1, /* periodIndex= */ 0, - /* positionMs= */ DEFAULT_FAST_FORWARD_INCREMENT_MS, - /* contentPositionMs= */ DEFAULT_FAST_FORWARD_INCREMENT_MS, + /* positionMs= */ DEFAULT_SEEK_FORWARD_INCREMENT_MS, + /* contentPositionMs= */ DEFAULT_SEEK_FORWARD_INCREMENT_MS, /* adGroupIndex= */ C.INDEX_UNSET, /* adIndexInAdGroup= */ C.INDEX_UNSET); InOrder inOrder = Mockito.inOrder(mockListener); @@ -1163,30 +1163,30 @@ public class CastPlayerTest { } @Test - public void setRewindIncrement_notifiesRewindIncrementChanged() { - long rewindIncrementMs = 1000; + public void setSeekBackIncrement_notifiesSeekBackIncrementChanged() { + long seekBackIncrementMs = 1000; - castPlayer.setRewindIncrement(rewindIncrementMs); + castPlayer.setSeekBackIncrement(seekBackIncrementMs); - verify(mockListener).onRewindIncrementChanged(rewindIncrementMs); - assertThat(castPlayer.getRewindIncrement()).isEqualTo(rewindIncrementMs); + verify(mockListener).onSeekBackIncrementChanged(seekBackIncrementMs); + assertThat(castPlayer.getSeekBackIncrement()).isEqualTo(seekBackIncrementMs); } @Test @SuppressWarnings("deprecation") // Mocks deprecated method used by the CastPlayer. - public void rewind_notifiesPositionDiscontinuity() { + public void seekBack_notifiesPositionDiscontinuity() { when(mockRemoteMediaClient.seek(anyLong())).thenReturn(mockPendingResult); int[] mediaQueueItemIds = new int[] {1}; List mediaItems = createMediaItems(mediaQueueItemIds); int currentItemId = 1; int[] streamTypes = new int[] {MediaInfo.STREAM_TYPE_BUFFERED}; - long[] durationsMs = new long[] {3 * DEFAULT_REWIND_INCREMENT_MS}; - long positionMs = 2 * DEFAULT_REWIND_INCREMENT_MS; + long[] durationsMs = new long[] {3 * DEFAULT_SEEK_BACK_INCREMENT_MS}; + long positionMs = 2 * DEFAULT_SEEK_BACK_INCREMENT_MS; castPlayer.addMediaItems(mediaItems); updateTimeLine( mediaItems, mediaQueueItemIds, currentItemId, streamTypes, durationsMs, positionMs); - castPlayer.rewind(); + castPlayer.seekBack(); Player.PositionInfo oldPosition = new Player.PositionInfo( @@ -1194,8 +1194,8 @@ public class CastPlayerTest { /* windowIndex= */ 0, /* periodUid= */ 1, /* periodIndex= */ 0, - /* positionMs= */ 2 * DEFAULT_REWIND_INCREMENT_MS, - /* contentPositionMs= */ 2 * DEFAULT_REWIND_INCREMENT_MS, + /* positionMs= */ 2 * DEFAULT_SEEK_BACK_INCREMENT_MS, + /* contentPositionMs= */ 2 * DEFAULT_SEEK_BACK_INCREMENT_MS, /* adGroupIndex= */ C.INDEX_UNSET, /* adIndexInAdGroup= */ C.INDEX_UNSET); Player.PositionInfo newPosition = @@ -1204,8 +1204,8 @@ public class CastPlayerTest { /* windowIndex= */ 0, /* periodUid= */ 1, /* periodIndex= */ 0, - /* positionMs= */ DEFAULT_REWIND_INCREMENT_MS, - /* contentPositionMs= */ DEFAULT_REWIND_INCREMENT_MS, + /* positionMs= */ DEFAULT_SEEK_BACK_INCREMENT_MS, + /* contentPositionMs= */ DEFAULT_SEEK_BACK_INCREMENT_MS, /* adGroupIndex= */ C.INDEX_UNSET, /* adIndexInAdGroup= */ C.INDEX_UNSET); 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_PREVIOUS_MEDIA_ITEM)).isFalse(); assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)).isTrue(); - assertThat(castPlayer.isCommandAvailable(COMMAND_SET_FAST_FORWARD_INCREMENT)).isTrue(); - assertThat(castPlayer.isCommandAvailable(COMMAND_FAST_FORWARD)).isTrue(); - assertThat(castPlayer.isCommandAvailable(COMMAND_SET_REWIND_INCREMENT)).isTrue(); - assertThat(castPlayer.isCommandAvailable(COMMAND_REWIND)).isTrue(); + assertThat(castPlayer.isCommandAvailable(COMMAND_SET_SEEK_FORWARD_INCREMENT)).isTrue(); + assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_FORWARD)).isTrue(); + assertThat(castPlayer.isCommandAvailable(COMMAND_SET_SEEK_BACK_INCREMENT)).isTrue(); + assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_BACK)).isTrue(); assertThat(castPlayer.isCommandAvailable(COMMAND_SET_SPEED_AND_PITCH)).isFalse(); assertThat(castPlayer.isCommandAvailable(COMMAND_SET_SHUFFLE_MODE)).isFalse(); assertThat(castPlayer.isCommandAvailable(COMMAND_SET_REPEAT_MODE)).isTrue(); @@ -1273,8 +1273,8 @@ public class CastPlayerTest { /* positionMs= */ C.TIME_UNSET); assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)).isFalse(); - assertThat(castPlayer.isCommandAvailable(COMMAND_FAST_FORWARD)).isFalse(); - assertThat(castPlayer.isCommandAvailable(COMMAND_REWIND)).isFalse(); + assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_FORWARD)).isFalse(); + assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_BACK)).isFalse(); } @Test @@ -1687,8 +1687,8 @@ public class CastPlayerTest { Player.Commands.Builder builder = new Player.Commands.Builder(); builder.addAll(CastPlayer.PERMANENT_AVAILABLE_COMMANDS); builder.add(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM); - builder.add(COMMAND_FAST_FORWARD); - builder.add(COMMAND_REWIND); + builder.add(COMMAND_SEEK_FORWARD); + builder.add(COMMAND_SEEK_BACK); builder.addAll(additionalCommands); return builder.build(); } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/BasePlayer.java b/library/common/src/main/java/com/google/android/exoplayer2/BasePlayer.java index d3335f16d9..f9260d0dc9 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/BasePlayer.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/BasePlayer.java @@ -122,13 +122,13 @@ public abstract class BasePlayer implements Player { } @Override - public final void fastForward() { - seekToOffset(getFastForwardIncrement()); + public final void seekForward() { + seekToOffset(getSeekForwardIncrement()); } @Override - public final void rewind() { - seekToOffset(-getRewindIncrement()); + public final void seekBack() { + seekToOffset(-getSeekBackIncrement()); } @Override @@ -267,8 +267,8 @@ public abstract class BasePlayer implements Player { .addIf(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, hasNext() && !isPlayingAd()) .addIf(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, hasPrevious() && !isPlayingAd()) .addIf(COMMAND_SEEK_TO_MEDIA_ITEM, !isPlayingAd()) - .addIf(COMMAND_FAST_FORWARD, isCurrentWindowSeekable() && !isPlayingAd()) - .addIf(COMMAND_REWIND, isCurrentWindowSeekable() && !isPlayingAd()) + .addIf(COMMAND_SEEK_FORWARD, isCurrentWindowSeekable() && !isPlayingAd()) + .addIf(COMMAND_SEEK_BACK, isCurrentWindowSeekable() && !isPlayingAd()) .build(); } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java b/library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java index b6d05515d9..a13aca7aa6 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java @@ -248,33 +248,33 @@ public class ForwardingPlayer implements Player { } @Override - public void setFastForwardIncrement(long fastForwardIncrementMs) { - player.setFastForwardIncrement(fastForwardIncrementMs); + public void setSeekForwardIncrement(long seekForwardIncrementMs) { + player.setSeekForwardIncrement(seekForwardIncrementMs); } @Override - public long getFastForwardIncrement() { - return player.getFastForwardIncrement(); + public long getSeekForwardIncrement() { + return player.getSeekForwardIncrement(); } @Override - public void fastForward() { - player.fastForward(); + public void seekForward() { + player.seekForward(); } @Override - public void setRewindIncrement(long rewindIncrementMs) { - player.setRewindIncrement(rewindIncrementMs); + public void setSeekBackIncrement(long seekBackIncrementMs) { + player.setSeekBackIncrement(seekBackIncrementMs); } @Override - public long getRewindIncrement() { - return player.getRewindIncrement(); + public long getSeekBackIncrement() { + return player.getSeekBackIncrement(); } @Override - public void rewind() { - player.rewind(); + public void seekBack() { + player.seekBack(); } @Override @@ -707,13 +707,13 @@ public class ForwardingPlayer implements Player { } @Override - public void onFastForwardIncrementChanged(long fastForwardIncrementMs) { - eventListener.onFastForwardIncrementChanged(fastForwardIncrementMs); + public void onSeekForwardIncrementChanged(long seekForwardIncrementMs) { + eventListener.onSeekForwardIncrementChanged(seekForwardIncrementMs); } @Override - public void onRewindIncrementChanged(long rewindIncrementMs) { - eventListener.onRewindIncrementChanged(rewindIncrementMs); + public void onSeekBackIncrementChanged(long seekBackIncrementMs) { + eventListener.onSeekBackIncrementChanged(seekBackIncrementMs); } @Override diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Player.java b/library/common/src/main/java/com/google/android/exoplayer2/Player.java index 5046fc6afd..f11832059a 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/Player.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/Player.java @@ -324,24 +324,24 @@ public interface Player { default void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {} /** - * Called when the value of {@link #getFastForwardIncrement()} changes. + * Called when the value of {@link #getSeekForwardIncrement()} changes. * *

{@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. * - * @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. * *

{@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. * - * @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 @@ -630,10 +630,10 @@ public interface Player { COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, COMMAND_SEEK_TO_MEDIA_ITEM, - COMMAND_SET_FAST_FORWARD_INCREMENT, - COMMAND_FAST_FORWARD, - COMMAND_SET_REWIND_INCREMENT, - COMMAND_REWIND, + COMMAND_SET_SEEK_FORWARD_INCREMENT, + COMMAND_SEEK_FORWARD, + COMMAND_SET_SEEK_BACK_INCREMENT, + COMMAND_SEEK_BACK, COMMAND_SET_SPEED_AND_PITCH, COMMAND_SET_SHUFFLE_MODE, COMMAND_SET_REPEAT_MODE, @@ -886,10 +886,10 @@ public interface Player { default void onMetadata(Metadata metadata) {} } - /** The default {@link #fastForward()} increment, in milliseconds. */ - long DEFAULT_FAST_FORWARD_INCREMENT_MS = 15_000; - /** The default {@link #rewind()} increment, in milliseconds. */ - long DEFAULT_REWIND_INCREMENT_MS = 5000; + /** The default {@link #seekForward()} increment, in milliseconds. */ + long DEFAULT_SEEK_FORWARD_INCREMENT_MS = 15_000; + /** The default {@link #seekBack()} increment, in milliseconds. */ + long DEFAULT_SEEK_BACK_INCREMENT_MS = 5000; /** * 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_MEDIA_METADATA_CHANGED, EVENT_PLAYLIST_METADATA_CHANGED, - EVENT_FAST_FORWARD_INCREMENT_CHANGED, - EVENT_REWIND_INCREMENT_CHANGED + EVENT_SEEK_FORWARD_INCREMENT_CHANGED, + EVENT_SEEK_BACK_INCREMENT_CHANGED }) @interface EventFlags {} /** {@link #getCurrentTimeline()} changed. */ @@ -1144,25 +1144,26 @@ public interface Player { int EVENT_MEDIA_METADATA_CHANGED = 15; /** {@link #getPlaylistMetadata()} changed. */ int EVENT_PLAYLIST_METADATA_CHANGED = 16; - /** {@link #getFastForwardIncrement()} changed. */ - int EVENT_FAST_FORWARD_INCREMENT_CHANGED = 17; - /** {@link #getRewindIncrement()} changed. */ - int EVENT_REWIND_INCREMENT_CHANGED = 18; + /** {@link #getSeekForwardIncrement()} changed. */ + int EVENT_SEEK_FORWARD_INCREMENT_CHANGED = 17; + /** {@link #getSeekBackIncrement()} changed. */ + int EVENT_SEEK_BACK_INCREMENT_CHANGED = 18; /** * 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_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_SET_FAST_FORWARD_INCREMENT}, {@link #COMMAND_FAST_FORWARD}, {@link - * #COMMAND_SET_REWIND_INCREMENT}, {@link #COMMAND_REWIND}, {@link #COMMAND_SET_SPEED_AND_PITCH}, - * {@link #COMMAND_SET_SHUFFLE_MODE}, {@link #COMMAND_SET_REPEAT_MODE}, {@link - * #COMMAND_GET_CURRENT_MEDIA_ITEM}, {@link #COMMAND_GET_MEDIA_ITEMS}, {@link - * #COMMAND_GET_MEDIA_ITEMS_METADATA}, {@link #COMMAND_SET_MEDIA_ITEMS_METADATA}, {@link - * #COMMAND_CHANGE_MEDIA_ITEMS}, {@link #COMMAND_GET_AUDIO_ATTRIBUTES}, {@link - * #COMMAND_GET_VOLUME}, {@link #COMMAND_GET_DEVICE_VOLUME}, {@link #COMMAND_SET_VOLUME}, {@link - * #COMMAND_SET_DEVICE_VOLUME}, {@link #COMMAND_ADJUST_DEVICE_VOLUME}, {@link - * #COMMAND_SET_VIDEO_SURFACE} or {@link #COMMAND_GET_TEXT}. + * #COMMAND_SET_SEEK_FORWARD_INCREMENT}, {@link #COMMAND_SEEK_FORWARD}, {@link + * #COMMAND_SET_SEEK_BACK_INCREMENT}, {@link #COMMAND_SEEK_BACK}, {@link + * #COMMAND_SET_SPEED_AND_PITCH}, {@link #COMMAND_SET_SHUFFLE_MODE}, {@link + * #COMMAND_SET_REPEAT_MODE}, {@link #COMMAND_GET_CURRENT_MEDIA_ITEM}, {@link + * #COMMAND_GET_MEDIA_ITEMS}, {@link #COMMAND_GET_MEDIA_ITEMS_METADATA}, {@link + * #COMMAND_SET_MEDIA_ITEMS_METADATA}, {@link #COMMAND_CHANGE_MEDIA_ITEMS}, {@link + * #COMMAND_GET_AUDIO_ATTRIBUTES}, {@link #COMMAND_GET_VOLUME}, {@link + * #COMMAND_GET_DEVICE_VOLUME}, {@link #COMMAND_SET_VOLUME}, {@link #COMMAND_SET_DEVICE_VOLUME}, + * {@link #COMMAND_ADJUST_DEVICE_VOLUME}, {@link #COMMAND_SET_VIDEO_SURFACE} or {@link + * #COMMAND_GET_TEXT}. */ @Documented @Retention(RetentionPolicy.SOURCE) @@ -1175,10 +1176,10 @@ public interface Player { COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, COMMAND_SEEK_TO_MEDIA_ITEM, - COMMAND_SET_FAST_FORWARD_INCREMENT, - COMMAND_FAST_FORWARD, - COMMAND_SET_REWIND_INCREMENT, - COMMAND_REWIND, + COMMAND_SET_SEEK_FORWARD_INCREMENT, + COMMAND_SEEK_FORWARD, + COMMAND_SET_SEEK_BACK_INCREMENT, + COMMAND_SEEK_BACK, COMMAND_SET_SPEED_AND_PITCH, COMMAND_SET_SHUFFLE_MODE, COMMAND_SET_REPEAT_MODE, @@ -1211,14 +1212,14 @@ public interface Player { int COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM = 6; /** Command to seek anywhere in any window. */ int COMMAND_SEEK_TO_MEDIA_ITEM = 7; - /** Command to set the fast forward increment. */ - int COMMAND_SET_FAST_FORWARD_INCREMENT = 8; - /** Command to fast forward into the current window. */ - int COMMAND_FAST_FORWARD = 9; - /** Command to set the rewind increment. */ - int COMMAND_SET_REWIND_INCREMENT = 10; - /** Command to rewind into the current window. */ - int COMMAND_REWIND = 11; + /** Command to set the seek forward increment. */ + int COMMAND_SET_SEEK_FORWARD_INCREMENT = 8; + /** Command to seek forward into the current window. */ + int COMMAND_SEEK_FORWARD = 9; + /** Command to set the seek back increment. */ + int COMMAND_SET_SEEK_BACK_INCREMENT = 10; + /** Command to seek back into the current window. */ + int COMMAND_SEEK_BACK = 11; /** Command to set the playback speed and pitch. */ int COMMAND_SET_SPEED_AND_PITCH = 12; /** Command to enable shuffling. */ @@ -1625,46 +1626,46 @@ public interface Player { void seekTo(int windowIndex, long positionMs); /** - * Sets the {@link #fastForward()} increment. + * Sets the {@link #seekForward()} increment. * - * @param fastForwardIncrementMs The fast forward increment, in milliseconds. - * @throws IllegalArgumentException If {@code fastForwardIncrementMs} is non-positive. + * @param seekForwardIncrementMs The seek forward increment, in milliseconds. + * @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. * - *

The default value is {@link #DEFAULT_FAST_FORWARD_INCREMENT_MS}. + *

The default value is {@link #DEFAULT_SEEK_FORWARD_INCREMENT_MS}. * - * @return The fast forward increment, in milliseconds. - * @see Listener#onFastForwardIncrementChanged(long) + * @return The seek forward increment, in milliseconds. + * @see Listener#onSeekForwardIncrementChanged(long) */ - long getFastForwardIncrement(); + long getSeekForwardIncrement(); - /** Seeks forward in the current window by {@link #getFastForwardIncrement()} milliseconds. */ - void fastForward(); + /** Seeks forward in the current window by {@link #getSeekForwardIncrement()} milliseconds. */ + void seekForward(); /** - * Sets the {@link #rewind()} increment. + * Sets the {@link #seekBack()} increment. * - * @param rewindIncrementMs The rewind increment, in milliseconds. - * @throws IllegalArgumentException If {@code rewindIncrementMs} is non-positive. + * @param seekBackIncrementMs The seek back increment, in milliseconds. + * @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. * - *

The default value is {@link #DEFAULT_REWIND_INCREMENT_MS}. + *

The default value is {@link #DEFAULT_SEEK_BACK_INCREMENT_MS}. * - * @return The rewind increment, in milliseconds. - * @see Listener#onRewindIncrementChanged(long) + * @return The seek back increment, in milliseconds. + * @see Listener#onSeekBackIncrementChanged(long) */ - long getRewindIncrement(); + long getSeekBackIncrement(); - /** Seeks back in the current window by {@link #getRewindIncrement()} milliseconds. */ - void rewind(); + /** Seeks back in the current window by {@link #getSeekBackIncrement()} milliseconds. */ + void seekBack(); /** * Returns whether a previous window exists, which may depend on the current repeat mode and diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java index d86cd8860e..1c79e1a323 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java @@ -104,8 +104,8 @@ import java.util.concurrent.CopyOnWriteArraySet; private Commands availableCommands; private MediaMetadata mediaMetadata; private MediaMetadata playlistMetadata; - private long fastForwardIncrementMs; - private long rewindIncrementMs; + private long seekForwardIncrementMs; + private long seekBackIncrementMs; // Playback information when there is no pending seek/set source operation. private PlaybackInfo playbackInfo; @@ -197,8 +197,8 @@ import java.util.concurrent.CopyOnWriteArraySet; .addAll( COMMAND_PLAY_PAUSE, COMMAND_PREPARE_STOP, - COMMAND_SET_FAST_FORWARD_INCREMENT, - COMMAND_SET_REWIND_INCREMENT, + COMMAND_SET_SEEK_FORWARD_INCREMENT, + COMMAND_SET_SEEK_BACK_INCREMENT, COMMAND_SET_SPEED_AND_PITCH, COMMAND_SET_SHUFFLE_MODE, COMMAND_SET_REPEAT_MODE, @@ -217,8 +217,8 @@ import java.util.concurrent.CopyOnWriteArraySet; .build(); mediaMetadata = MediaMetadata.EMPTY; playlistMetadata = MediaMetadata.EMPTY; - fastForwardIncrementMs = DEFAULT_FAST_FORWARD_INCREMENT_MS; - rewindIncrementMs = DEFAULT_REWIND_INCREMENT_MS; + seekForwardIncrementMs = DEFAULT_SEEK_FORWARD_INCREMENT_MS; + seekBackIncrementMs = DEFAULT_SEEK_BACK_INCREMENT_MS; maskingWindowIndex = C.INDEX_UNSET; playbackInfoUpdateHandler = clock.createHandler(applicationLooper, /* callback= */ null); playbackInfoUpdateListener = @@ -720,37 +720,37 @@ import java.util.concurrent.CopyOnWriteArraySet; } @Override - public void setFastForwardIncrement(long fastForwardIncrementMs) { - checkArgument(fastForwardIncrementMs > 0); - if (this.fastForwardIncrementMs != fastForwardIncrementMs) { - this.fastForwardIncrementMs = fastForwardIncrementMs; + public void setSeekForwardIncrement(long seekForwardIncrementMs) { + checkArgument(seekForwardIncrementMs > 0); + if (this.seekForwardIncrementMs != seekForwardIncrementMs) { + this.seekForwardIncrementMs = seekForwardIncrementMs; listeners.queueEvent( - Player.EVENT_FAST_FORWARD_INCREMENT_CHANGED, - listener -> listener.onFastForwardIncrementChanged(fastForwardIncrementMs)); + Player.EVENT_SEEK_FORWARD_INCREMENT_CHANGED, + listener -> listener.onSeekForwardIncrementChanged(seekForwardIncrementMs)); listeners.flushEvents(); } } @Override - public long getFastForwardIncrement() { - return fastForwardIncrementMs; + public long getSeekForwardIncrement() { + return seekForwardIncrementMs; } @Override - public void setRewindIncrement(long rewindIncrementMs) { - checkArgument(rewindIncrementMs > 0); - if (this.rewindIncrementMs != rewindIncrementMs) { - this.rewindIncrementMs = rewindIncrementMs; + public void setSeekBackIncrement(long seekBackIncrementMs) { + checkArgument(seekBackIncrementMs > 0); + if (this.seekBackIncrementMs != seekBackIncrementMs) { + this.seekBackIncrementMs = seekBackIncrementMs; listeners.queueEvent( - Player.EVENT_REWIND_INCREMENT_CHANGED, - listener -> listener.onRewindIncrementChanged(rewindIncrementMs)); + Player.EVENT_SEEK_BACK_INCREMENT_CHANGED, + listener -> listener.onSeekBackIncrementChanged(seekBackIncrementMs)); listeners.flushEvents(); } } @Override - public long getRewindIncrement() { - return rewindIncrementMs; + public long getSeekBackIncrement() { + return seekBackIncrementMs; } @Override diff --git a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java index ae9e5cf2c1..16a4e986c7 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java @@ -1563,27 +1563,27 @@ public class SimpleExoPlayer extends BasePlayer } @Override - public void setFastForwardIncrement(long fastForwardIncrementMs) { + public void setSeekForwardIncrement(long seekForwardIncrementMs) { verifyApplicationThread(); - player.setFastForwardIncrement(fastForwardIncrementMs); + player.setSeekForwardIncrement(seekForwardIncrementMs); } @Override - public long getFastForwardIncrement() { + public long getSeekForwardIncrement() { verifyApplicationThread(); - return player.getFastForwardIncrement(); + return player.getSeekForwardIncrement(); } @Override - public void setRewindIncrement(long rewindIncrementMs) { + public void setSeekBackIncrement(long seekBackIncrementMs) { verifyApplicationThread(); - player.setRewindIncrement(rewindIncrementMs); + player.setSeekBackIncrement(seekBackIncrementMs); } @Override - public long getRewindIncrement() { + public long getSeekBackIncrement() { verifyApplicationThread(); - return player.getRewindIncrement(); + return player.getSeekBackIncrement(); } @Override diff --git a/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsCollector.java b/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsCollector.java index 5dbc09eadd..da6ebf0275 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsCollector.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsCollector.java @@ -743,21 +743,21 @@ public class AnalyticsCollector } @Override - public void onFastForwardIncrementChanged(long fastForwardIncrementMs) { + public void onSeekForwardIncrementChanged(long seekForwardIncrementMs) { EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime(); sendEvent( eventTime, - AnalyticsListener.EVENT_FAST_FORWARD_INCREMENT_CHANGED, - listener -> listener.onFastForwardIncrementChanged(eventTime, fastForwardIncrementMs)); + AnalyticsListener.EVENT_SEEK_FORWARD_INCREMENT_CHANGED, + listener -> listener.onSeekForwardIncrementChanged(eventTime, seekForwardIncrementMs)); } @Override - public void onRewindIncrementChanged(long rewindIncrementMs) { + public void onSeekBackIncrementChanged(long seekBackIncrementMs) { EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime(); sendEvent( eventTime, - AnalyticsListener.EVENT_REWIND_INCREMENT_CHANGED, - listener -> listener.onRewindIncrementChanged(eventTime, rewindIncrementMs)); + AnalyticsListener.EVENT_SEEK_BACK_INCREMENT_CHANGED, + listener -> listener.onSeekBackIncrementChanged(eventTime, seekBackIncrementMs)); } @Override diff --git a/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsListener.java b/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsListener.java index 612264aefe..53344dba00 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsListener.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsListener.java @@ -172,8 +172,8 @@ public interface AnalyticsListener { EVENT_AVAILABLE_COMMANDS_CHANGED, EVENT_MEDIA_METADATA_CHANGED, EVENT_PLAYLIST_METADATA_CHANGED, - EVENT_FAST_FORWARD_INCREMENT_CHANGED, - EVENT_REWIND_INCREMENT_CHANGED, + EVENT_SEEK_FORWARD_INCREMENT_CHANGED, + EVENT_SEEK_BACK_INCREMENT_CHANGED, EVENT_LOAD_STARTED, EVENT_LOAD_COMPLETED, EVENT_LOAD_CANCELED, @@ -256,10 +256,10 @@ public interface AnalyticsListener { int EVENT_MEDIA_METADATA_CHANGED = Player.EVENT_MEDIA_METADATA_CHANGED; /** {@link Player#getPlaylistMetadata()} changed. */ int EVENT_PLAYLIST_METADATA_CHANGED = Player.EVENT_PLAYLIST_METADATA_CHANGED; - /** {@link Player#getFastForwardIncrement()} changed. */ - int EVENT_FAST_FORWARD_INCREMENT_CHANGED = Player.EVENT_FAST_FORWARD_INCREMENT_CHANGED; - /** {@link Player#getRewindIncrement()} changed. */ - int EVENT_REWIND_INCREMENT_CHANGED = Player.EVENT_REWIND_INCREMENT_CHANGED; + /** {@link Player#getSeekForwardIncrement()} changed. */ + int EVENT_SEEK_FORWARD_INCREMENT_CHANGED = Player.EVENT_SEEK_FORWARD_INCREMENT_CHANGED; + /** {@link Player#getSeekBackIncrement()} changed. */ + int EVENT_SEEK_BACK_INCREMENT_CHANGED = Player.EVENT_SEEK_BACK_INCREMENT_CHANGED; /** A source started loading data. */ int EVENT_LOAD_STARTED = 1000; // Intentional gap to leave space for new Player events /** A source started completed loading data. */ @@ -596,20 +596,20 @@ public interface AnalyticsListener { EventTime eventTime, PlaybackParameters playbackParameters) {} /** - * Called when the fast forward increment changed. + * Called when the seek forward increment changed. * * @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 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. diff --git a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java index 71d43ecaaa..5ce75fa22a 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java @@ -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_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_CURRENT_MEDIA_ITEM; 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_PLAY_PAUSE; 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_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_NEXT_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_FAST_FORWARD_INCREMENT; 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_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_SPEED_AND_PITCH; 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.DEFAULT_FAST_FORWARD_INCREMENT_MS; -import static com.google.android.exoplayer2.Player.DEFAULT_REWIND_INCREMENT_MS; +import static com.google.android.exoplayer2.Player.DEFAULT_SEEK_BACK_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.robolectric.RobolectricUtil.runMainLooperUntil; 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_PREVIOUS_MEDIA_ITEM)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)).isTrue(); - assertThat(player.isCommandAvailable(COMMAND_SET_FAST_FORWARD_INCREMENT)).isTrue(); - assertThat(player.isCommandAvailable(COMMAND_FAST_FORWARD)).isFalse(); - assertThat(player.isCommandAvailable(COMMAND_SET_REWIND_INCREMENT)).isTrue(); - assertThat(player.isCommandAvailable(COMMAND_REWIND)).isFalse(); + assertThat(player.isCommandAvailable(COMMAND_SET_SEEK_FORWARD_INCREMENT)).isTrue(); + assertThat(player.isCommandAvailable(COMMAND_SEEK_FORWARD)).isFalse(); + assertThat(player.isCommandAvailable(COMMAND_SET_SEEK_BACK_INCREMENT)).isTrue(); + assertThat(player.isCommandAvailable(COMMAND_SEEK_BACK)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SET_SPEED_AND_PITCH)).isTrue(); assertThat(player.isCommandAvailable(COMMAND_SET_SHUFFLE_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_PREVIOUS_MEDIA_ITEM)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)).isFalse(); - assertThat(player.isCommandAvailable(COMMAND_FAST_FORWARD)).isFalse(); - assertThat(player.isCommandAvailable(COMMAND_REWIND)).isFalse(); + assertThat(player.isCommandAvailable(COMMAND_SEEK_FORWARD)).isFalse(); + assertThat(player.isCommandAvailable(COMMAND_SEEK_BACK)).isFalse(); } @Test @@ -8242,8 +8242,8 @@ public final class ExoPlayerTest { runUntilPlaybackState(player, Player.STATE_READY); assertThat(player.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)).isFalse(); - assertThat(player.isCommandAvailable(COMMAND_FAST_FORWARD)).isFalse(); - assertThat(player.isCommandAvailable(COMMAND_REWIND)).isFalse(); + assertThat(player.isCommandAvailable(COMMAND_SEEK_FORWARD)).isFalse(); + assertThat(player.isCommandAvailable(COMMAND_SEEK_BACK)).isFalse(); } @Test @@ -8336,20 +8336,20 @@ public final class ExoPlayerTest { Player.Commands commandsWithSeekInCurrentAndToNext = createWithDefaultCommands( COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM, - COMMAND_FAST_FORWARD, - COMMAND_REWIND, + COMMAND_SEEK_FORWARD, + COMMAND_SEEK_BACK, COMMAND_SEEK_TO_NEXT_MEDIA_ITEM); Player.Commands commandsWithSeekInCurrentAndToPrevious = createWithDefaultCommands( COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM, - COMMAND_FAST_FORWARD, - COMMAND_REWIND, + COMMAND_SEEK_FORWARD, + COMMAND_SEEK_BACK, COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM); Player.Commands commandsWithSeekAnywhere = createWithDefaultCommands( COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM, - COMMAND_FAST_FORWARD, - COMMAND_REWIND, + COMMAND_SEEK_FORWARD, + COMMAND_SEEK_BACK, COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM); Player.Listener mockListener = mock(Player.Listener.class); @@ -10398,20 +10398,20 @@ public final class ExoPlayerTest { } @Test - public void setFastForwardIncrement_notifiesFastForwardIncrementChanged() { + public void setSeekForwardIncrement_notifiesSeekForwardIncrementChanged() { ExoPlayer player = new TestExoPlayerBuilder(context).build(); Player.Listener listener = mock(Player.Listener.class); player.addListener(listener); - long fastForwardIncrementMs = 1000; + long seekForwardIncrementMs = 1000; - player.setFastForwardIncrement(fastForwardIncrementMs); + player.setSeekForwardIncrement(seekForwardIncrementMs); - verify(listener).onFastForwardIncrementChanged(fastForwardIncrementMs); - assertThat(player.getFastForwardIncrement()).isEqualTo(fastForwardIncrementMs); + verify(listener).onSeekForwardIncrementChanged(seekForwardIncrementMs); + assertThat(player.getSeekForwardIncrement()).isEqualTo(seekForwardIncrementMs); } @Test - public void fastForward_callsOnPositionDiscontinuity() throws Exception { + public void seekForward_callsOnPositionDiscontinuity() throws Exception { ExoPlayer player = new TestExoPlayerBuilder(context).build(); Player.Listener listener = mock(Player.Listener.class); player.addListener(listener); @@ -10420,12 +10420,12 @@ public final class ExoPlayerTest { new TimelineWindowDefinition( /* isSeekable= */ 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.prepare(); TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY); - player.fastForward(); + player.seekForward(); ArgumentCaptor oldPosition = ArgumentCaptor.forClass(Player.PositionInfo.class); @@ -10442,47 +10442,47 @@ public final class ExoPlayerTest { assertThat(oldPositions.get(0).positionMs).isEqualTo(0); assertThat(oldPositions.get(0).contentPositionMs).isEqualTo(0); assertThat(newPositions.get(0).windowIndex).isEqualTo(0); - assertThat(newPositions.get(0).positionMs).isEqualTo(DEFAULT_FAST_FORWARD_INCREMENT_MS); - assertThat(newPositions.get(0).contentPositionMs).isEqualTo(DEFAULT_FAST_FORWARD_INCREMENT_MS); + assertThat(newPositions.get(0).positionMs).isEqualTo(DEFAULT_SEEK_FORWARD_INCREMENT_MS); + assertThat(newPositions.get(0).contentPositionMs).isEqualTo(DEFAULT_SEEK_FORWARD_INCREMENT_MS); player.release(); } @Test - public void fastForward_pastDuration_seeksToDuration() throws Exception { + public void seekForward_pastDuration_seeksToDuration() throws Exception { ExoPlayer player = new TestExoPlayerBuilder(context).build(); Timeline fakeTimeline = new FakeTimeline( new TimelineWindowDefinition( /* isSeekable= */ 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.prepare(); 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(); } @Test - public void setRewindIncrement_notifiesRewindIncrementChanged() { + public void setSeekBackIncrement_notifiesSeekBackIncrementChanged() { ExoPlayer player = new TestExoPlayerBuilder(context).build(); Player.Listener listener = mock(Player.Listener.class); player.addListener(listener); - long rewindIncrementMs = 1000; + long seekBackIncrementMs = 1000; - player.setRewindIncrement(rewindIncrementMs); + player.setSeekBackIncrement(seekBackIncrementMs); - verify(listener).onRewindIncrementChanged(rewindIncrementMs); - assertThat(player.getRewindIncrement()).isEqualTo(rewindIncrementMs); + verify(listener).onSeekBackIncrementChanged(seekBackIncrementMs); + assertThat(player.getSeekBackIncrement()).isEqualTo(seekBackIncrementMs); } @Test - public void rewind_callsOnPositionDiscontinuity() throws Exception { + public void seekBack_callsOnPositionDiscontinuity() throws Exception { ExoPlayer player = new TestExoPlayerBuilder(context).build(); Player.Listener listener = mock(Player.Listener.class); player.addListener(listener); @@ -10491,13 +10491,13 @@ public final class ExoPlayerTest { new TimelineWindowDefinition( /* isSeekable= */ 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.prepare(); TestPlayerRunHelper.playUntilPosition( - player, /* windowIndex= */ 0, /* positionMs= */ 2 * DEFAULT_REWIND_INCREMENT_MS); - player.rewind(); + player, /* windowIndex= */ 0, /* positionMs= */ 2 * DEFAULT_SEEK_BACK_INCREMENT_MS); + player.seekBack(); ArgumentCaptor oldPosition = ArgumentCaptor.forClass(Player.PositionInfo.class); @@ -10512,33 +10512,37 @@ public final class ExoPlayerTest { List newPositions = newPosition.getAllValues(); assertThat(oldPositions.get(0).windowIndex).isEqualTo(0); 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) - .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).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) - .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(); } @Test - public void rewind_pastZero_seeksToZero() throws Exception { + public void seekBack_pastZero_seeksToZero() throws Exception { ExoPlayer player = new TestExoPlayerBuilder(context).build(); Timeline fakeTimeline = new FakeTimeline( new TimelineWindowDefinition( /* isSeekable= */ true, /* isDynamic= */ true, - /* durationUs= */ C.msToUs(DEFAULT_REWIND_INCREMENT_MS))); + /* durationUs= */ C.msToUs(DEFAULT_SEEK_BACK_INCREMENT_MS))); player.setMediaSource(new FakeMediaSource(fakeTimeline)); player.prepare(); TestPlayerRunHelper.playUntilPosition( - player, /* windowIndex= */ 0, /* positionMs= */ DEFAULT_REWIND_INCREMENT_MS / 2); - player.rewind(); + player, /* windowIndex= */ 0, /* positionMs= */ DEFAULT_SEEK_BACK_INCREMENT_MS / 2); + player.seekBack(); assertThat(player.getCurrentPosition()).isEqualTo(0); @@ -10769,8 +10773,8 @@ public final class ExoPlayerTest { builder.addAll( COMMAND_PLAY_PAUSE, COMMAND_PREPARE_STOP, - COMMAND_SET_FAST_FORWARD_INCREMENT, - COMMAND_SET_REWIND_INCREMENT, + COMMAND_SET_SEEK_FORWARD_INCREMENT, + COMMAND_SET_SEEK_BACK_INCREMENT, COMMAND_SET_SPEED_AND_PITCH, COMMAND_SET_SHUFFLE_MODE, COMMAND_SET_REPEAT_MODE, diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java index 576df4e3e0..1ac59431f7 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java @@ -300,22 +300,22 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer { } @Override - public void setFastForwardIncrement(long fastForwardIncrementMs) { + public void setSeekForwardIncrement(long seekForwardIncrementMs) { throw new UnsupportedOperationException(); } @Override - public long getFastForwardIncrement() { + public long getSeekForwardIncrement() { throw new UnsupportedOperationException(); } @Override - public void setRewindIncrement(long rewindIncrementMs) { + public void setSeekBackIncrement(long seekBackIncrementMs) { throw new UnsupportedOperationException(); } @Override - public long getRewindIncrement() { + public long getSeekBackIncrement() { throw new UnsupportedOperationException(); }