mirror of
https://github.com/androidx/media.git
synced 2025-05-06 23:20:42 +08:00
Remove the seekBack/Forward increment setters
This simplifies the API surface and the MediaController implementation. PiperOrigin-RevId: 383385436
This commit is contained in:
parent
73b5d0c37b
commit
1608f6f9da
@ -94,8 +94,6 @@ 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_SEEK_FORWARD_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,
|
||||||
@ -117,6 +115,8 @@ public final class CastPlayer extends BasePlayer {
|
|||||||
|
|
||||||
private final CastContext castContext;
|
private final CastContext castContext;
|
||||||
private final MediaItemConverter mediaItemConverter;
|
private final MediaItemConverter mediaItemConverter;
|
||||||
|
private final long seekForwardIncrementMs;
|
||||||
|
private final long seekBackIncrementMs;
|
||||||
// TODO: Allow custom implementations of CastTimelineTracker.
|
// TODO: Allow custom implementations of CastTimelineTracker.
|
||||||
private final CastTimelineTracker timelineTracker;
|
private final CastTimelineTracker timelineTracker;
|
||||||
private final Timeline.Period period;
|
private final Timeline.Period period;
|
||||||
@ -144,11 +144,15 @@ 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 seekForwardIncrementMs;
|
|
||||||
private long seekBackIncrementMs;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new cast player that uses a {@link DefaultMediaItemConverter}.
|
* Creates a new cast player.
|
||||||
|
*
|
||||||
|
* <p>The returned player uses a {@link DefaultMediaItemConverter} and
|
||||||
|
*
|
||||||
|
* <p>{@code mediaItemConverter} is set to a {@link DefaultMediaItemConverter}, {@code
|
||||||
|
* seekForwardIncrementMs} is set to {@link C#DEFAULT_SEEK_FORWARD_INCREMENT_MS} and {@code
|
||||||
|
* seekBackIncrementMs} is set to {@link C#DEFAULT_SEEK_BACK_INCREMENT_MS}.
|
||||||
*
|
*
|
||||||
* @param castContext The context from which the cast session is obtained.
|
* @param castContext The context from which the cast session is obtained.
|
||||||
*/
|
*/
|
||||||
@ -159,12 +163,40 @@ public final class CastPlayer extends BasePlayer {
|
|||||||
/**
|
/**
|
||||||
* Creates a new cast player.
|
* Creates a new cast player.
|
||||||
*
|
*
|
||||||
|
* <p>{@code seekForwardIncrementMs} is set to {@link C#DEFAULT_SEEK_FORWARD_INCREMENT_MS} and
|
||||||
|
* {@code seekBackIncrementMs} is set to {@link C#DEFAULT_SEEK_BACK_INCREMENT_MS}.
|
||||||
|
*
|
||||||
* @param castContext The context from which the cast session is obtained.
|
* @param castContext The context from which the cast session is obtained.
|
||||||
* @param mediaItemConverter The {@link MediaItemConverter} to use.
|
* @param mediaItemConverter The {@link MediaItemConverter} to use.
|
||||||
*/
|
*/
|
||||||
public CastPlayer(CastContext castContext, MediaItemConverter mediaItemConverter) {
|
public CastPlayer(CastContext castContext, MediaItemConverter mediaItemConverter) {
|
||||||
|
this(
|
||||||
|
castContext,
|
||||||
|
mediaItemConverter,
|
||||||
|
C.DEFAULT_SEEK_FORWARD_INCREMENT_MS,
|
||||||
|
C.DEFAULT_SEEK_BACK_INCREMENT_MS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new cast player.
|
||||||
|
*
|
||||||
|
* @param castContext The context from which the cast session is obtained.
|
||||||
|
* @param mediaItemConverter The {@link MediaItemConverter} to use.
|
||||||
|
* @param seekForwardIncrementMs The {@link #seekForward()} increment, in milliseconds.
|
||||||
|
* @param seekBackIncrementMs The {@link #seekBack()} increment, in milliseconds.
|
||||||
|
* @throws IllegalArgumentException If {@code seekForwardIncrementMs} or {@code
|
||||||
|
* seekBackIncrementMs} is non-positive.
|
||||||
|
*/
|
||||||
|
public CastPlayer(
|
||||||
|
CastContext castContext,
|
||||||
|
MediaItemConverter mediaItemConverter,
|
||||||
|
long seekForwardIncrementMs,
|
||||||
|
long seekBackIncrementMs) {
|
||||||
|
checkArgument(seekForwardIncrementMs > 0 && seekBackIncrementMs > 0);
|
||||||
this.castContext = castContext;
|
this.castContext = castContext;
|
||||||
this.mediaItemConverter = mediaItemConverter;
|
this.mediaItemConverter = mediaItemConverter;
|
||||||
|
this.seekForwardIncrementMs = seekForwardIncrementMs;
|
||||||
|
this.seekBackIncrementMs = seekBackIncrementMs;
|
||||||
timelineTracker = new CastTimelineTracker();
|
timelineTracker = new CastTimelineTracker();
|
||||||
period = new Timeline.Period();
|
period = new Timeline.Period();
|
||||||
statusListener = new StatusListener();
|
statusListener = new StatusListener();
|
||||||
@ -183,8 +215,6 @@ 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;
|
||||||
seekForwardIncrementMs = DEFAULT_SEEK_FORWARD_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);
|
||||||
@ -418,35 +448,11 @@ public final class CastPlayer extends BasePlayer {
|
|||||||
listeners.flushEvents();
|
listeners.flushEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSeekForwardIncrement(long seekForwardIncrementMs) {
|
|
||||||
checkArgument(seekForwardIncrementMs > 0);
|
|
||||||
if (this.seekForwardIncrementMs != seekForwardIncrementMs) {
|
|
||||||
this.seekForwardIncrementMs = seekForwardIncrementMs;
|
|
||||||
listeners.queueEvent(
|
|
||||||
Player.EVENT_SEEK_FORWARD_INCREMENT_CHANGED,
|
|
||||||
listener -> listener.onSeekForwardIncrementChanged(seekForwardIncrementMs));
|
|
||||||
listeners.flushEvents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSeekForwardIncrement() {
|
public long getSeekForwardIncrement() {
|
||||||
return seekForwardIncrementMs;
|
return seekForwardIncrementMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSeekBackIncrement(long seekBackIncrementMs) {
|
|
||||||
checkArgument(seekBackIncrementMs > 0);
|
|
||||||
if (this.seekBackIncrementMs != seekBackIncrementMs) {
|
|
||||||
this.seekBackIncrementMs = seekBackIncrementMs;
|
|
||||||
listeners.queueEvent(
|
|
||||||
Player.EVENT_SEEK_BACK_INCREMENT_CHANGED,
|
|
||||||
listener -> listener.onSeekBackIncrementChanged(seekBackIncrementMs));
|
|
||||||
listeners.flushEvents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSeekBackIncrement() {
|
public long getSeekBackIncrement() {
|
||||||
return seekBackIncrementMs;
|
return seekBackIncrementMs;
|
||||||
|
@ -36,14 +36,10 @@ import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_PREVIOUS_MEDI
|
|||||||
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_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_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_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.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;
|
||||||
@ -1106,16 +1102,6 @@ public class CastPlayerTest {
|
|||||||
inOrder.verify(mockListener, never()).onPositionDiscontinuity(any(), any(), anyInt());
|
inOrder.verify(mockListener, never()).onPositionDiscontinuity(any(), any(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void setSeekForwardIncrement_notifiesSeekForwardIncrementChanged() {
|
|
||||||
long seekForwardIncrementMs = 1000;
|
|
||||||
|
|
||||||
castPlayer.setSeekForwardIncrement(seekForwardIncrementMs);
|
|
||||||
|
|
||||||
verify(mockListener).onSeekForwardIncrementChanged(seekForwardIncrementMs);
|
|
||||||
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 seekForward_notifiesPositionDiscontinuity() {
|
public void seekForward_notifiesPositionDiscontinuity() {
|
||||||
@ -1124,7 +1110,7 @@ public class CastPlayerTest {
|
|||||||
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_SEEK_FORWARD_INCREMENT_MS};
|
long[] durationsMs = new long[] {2 * C.DEFAULT_SEEK_FORWARD_INCREMENT_MS};
|
||||||
long positionMs = 0;
|
long positionMs = 0;
|
||||||
|
|
||||||
castPlayer.addMediaItems(mediaItems);
|
castPlayer.addMediaItems(mediaItems);
|
||||||
@ -1148,8 +1134,8 @@ public class CastPlayerTest {
|
|||||||
/* windowIndex= */ 0,
|
/* windowIndex= */ 0,
|
||||||
/* periodUid= */ 1,
|
/* periodUid= */ 1,
|
||||||
/* periodIndex= */ 0,
|
/* periodIndex= */ 0,
|
||||||
/* positionMs= */ DEFAULT_SEEK_FORWARD_INCREMENT_MS,
|
/* positionMs= */ C.DEFAULT_SEEK_FORWARD_INCREMENT_MS,
|
||||||
/* contentPositionMs= */ DEFAULT_SEEK_FORWARD_INCREMENT_MS,
|
/* contentPositionMs= */ C.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);
|
||||||
@ -1162,16 +1148,6 @@ public class CastPlayerTest {
|
|||||||
inOrder.verify(mockListener, never()).onPositionDiscontinuity(any(), any(), anyInt());
|
inOrder.verify(mockListener, never()).onPositionDiscontinuity(any(), any(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void setSeekBackIncrement_notifiesSeekBackIncrementChanged() {
|
|
||||||
long seekBackIncrementMs = 1000;
|
|
||||||
|
|
||||||
castPlayer.setSeekBackIncrement(seekBackIncrementMs);
|
|
||||||
|
|
||||||
verify(mockListener).onSeekBackIncrementChanged(seekBackIncrementMs);
|
|
||||||
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 seekBack_notifiesPositionDiscontinuity() {
|
public void seekBack_notifiesPositionDiscontinuity() {
|
||||||
@ -1180,8 +1156,8 @@ public class CastPlayerTest {
|
|||||||
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_SEEK_BACK_INCREMENT_MS};
|
long[] durationsMs = new long[] {3 * C.DEFAULT_SEEK_BACK_INCREMENT_MS};
|
||||||
long positionMs = 2 * DEFAULT_SEEK_BACK_INCREMENT_MS;
|
long positionMs = 2 * C.DEFAULT_SEEK_BACK_INCREMENT_MS;
|
||||||
|
|
||||||
castPlayer.addMediaItems(mediaItems);
|
castPlayer.addMediaItems(mediaItems);
|
||||||
updateTimeLine(
|
updateTimeLine(
|
||||||
@ -1194,8 +1170,8 @@ public class CastPlayerTest {
|
|||||||
/* windowIndex= */ 0,
|
/* windowIndex= */ 0,
|
||||||
/* periodUid= */ 1,
|
/* periodUid= */ 1,
|
||||||
/* periodIndex= */ 0,
|
/* periodIndex= */ 0,
|
||||||
/* positionMs= */ 2 * DEFAULT_SEEK_BACK_INCREMENT_MS,
|
/* positionMs= */ 2 * C.DEFAULT_SEEK_BACK_INCREMENT_MS,
|
||||||
/* contentPositionMs= */ 2 * DEFAULT_SEEK_BACK_INCREMENT_MS,
|
/* contentPositionMs= */ 2 * C.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 +1180,8 @@ public class CastPlayerTest {
|
|||||||
/* windowIndex= */ 0,
|
/* windowIndex= */ 0,
|
||||||
/* periodUid= */ 1,
|
/* periodUid= */ 1,
|
||||||
/* periodIndex= */ 0,
|
/* periodIndex= */ 0,
|
||||||
/* positionMs= */ DEFAULT_SEEK_BACK_INCREMENT_MS,
|
/* positionMs= */ C.DEFAULT_SEEK_BACK_INCREMENT_MS,
|
||||||
/* contentPositionMs= */ DEFAULT_SEEK_BACK_INCREMENT_MS,
|
/* contentPositionMs= */ C.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,9 +1209,7 @@ 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_SEEK_FORWARD_INCREMENT)).isTrue();
|
|
||||||
assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_FORWARD)).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_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();
|
||||||
|
@ -646,6 +646,11 @@ public final class C {
|
|||||||
/** A default size in bytes for an individual allocation that forms part of a larger buffer. */
|
/** A default size in bytes for an individual allocation that forms part of a larger buffer. */
|
||||||
public static final int DEFAULT_BUFFER_SEGMENT_SIZE = 64 * 1024;
|
public static final int DEFAULT_BUFFER_SEGMENT_SIZE = 64 * 1024;
|
||||||
|
|
||||||
|
/** A default seek forward increment, in milliseconds. */
|
||||||
|
public static final long DEFAULT_SEEK_FORWARD_INCREMENT_MS = 15_000;
|
||||||
|
/** A default seek back increment, in milliseconds. */
|
||||||
|
public static final long DEFAULT_SEEK_BACK_INCREMENT_MS = 5000;
|
||||||
|
|
||||||
/** "cenc" scheme type name as defined in ISO/IEC 23001-7:2016. */
|
/** "cenc" scheme type name as defined in ISO/IEC 23001-7:2016. */
|
||||||
@SuppressWarnings("ConstantField")
|
@SuppressWarnings("ConstantField")
|
||||||
public static final String CENC_TYPE_cenc = "cenc";
|
public static final String CENC_TYPE_cenc = "cenc";
|
||||||
|
@ -247,11 +247,6 @@ public class ForwardingPlayer implements Player {
|
|||||||
player.seekTo(windowIndex, positionMs);
|
player.seekTo(windowIndex, positionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSeekForwardIncrement(long seekForwardIncrementMs) {
|
|
||||||
player.setSeekForwardIncrement(seekForwardIncrementMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSeekForwardIncrement() {
|
public long getSeekForwardIncrement() {
|
||||||
return player.getSeekForwardIncrement();
|
return player.getSeekForwardIncrement();
|
||||||
@ -262,11 +257,6 @@ public class ForwardingPlayer implements Player {
|
|||||||
player.seekForward();
|
player.seekForward();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSeekBackIncrement(long seekBackIncrementMs) {
|
|
||||||
player.setSeekBackIncrement(seekBackIncrementMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSeekBackIncrement() {
|
public long getSeekBackIncrement() {
|
||||||
return player.getSeekBackIncrement();
|
return player.getSeekBackIncrement();
|
||||||
|
@ -630,9 +630,7 @@ 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_SEEK_FORWARD_INCREMENT,
|
|
||||||
COMMAND_SEEK_FORWARD,
|
COMMAND_SEEK_FORWARD,
|
||||||
COMMAND_SET_SEEK_BACK_INCREMENT,
|
|
||||||
COMMAND_SEEK_BACK,
|
COMMAND_SEEK_BACK,
|
||||||
COMMAND_SET_SPEED_AND_PITCH,
|
COMMAND_SET_SPEED_AND_PITCH,
|
||||||
COMMAND_SET_SHUFFLE_MODE,
|
COMMAND_SET_SHUFFLE_MODE,
|
||||||
@ -886,11 +884,6 @@ public interface Player {
|
|||||||
default void onMetadata(Metadata metadata) {}
|
default void onMetadata(Metadata metadata) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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
|
* Playback state. One of {@link #STATE_IDLE}, {@link #STATE_BUFFERING}, {@link #STATE_READY} or
|
||||||
* {@link #STATE_ENDED}.
|
* {@link #STATE_ENDED}.
|
||||||
@ -1154,16 +1147,14 @@ public interface Player {
|
|||||||
* #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_SEEK_FORWARD_INCREMENT}, {@link #COMMAND_SEEK_FORWARD}, {@link
|
* #COMMAND_SEEK_FORWARD}, {@link #COMMAND_SEEK_BACK}, {@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)
|
||||||
@ -1176,9 +1167,7 @@ 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_SEEK_FORWARD_INCREMENT,
|
|
||||||
COMMAND_SEEK_FORWARD,
|
COMMAND_SEEK_FORWARD,
|
||||||
COMMAND_SET_SEEK_BACK_INCREMENT,
|
|
||||||
COMMAND_SEEK_BACK,
|
COMMAND_SEEK_BACK,
|
||||||
COMMAND_SET_SPEED_AND_PITCH,
|
COMMAND_SET_SPEED_AND_PITCH,
|
||||||
COMMAND_SET_SHUFFLE_MODE,
|
COMMAND_SET_SHUFFLE_MODE,
|
||||||
@ -1212,46 +1201,42 @@ 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 seek forward increment. */
|
|
||||||
int COMMAND_SET_SEEK_FORWARD_INCREMENT = 8;
|
|
||||||
/** Command to seek forward into the current window. */
|
/** Command to seek forward into the current window. */
|
||||||
int COMMAND_SEEK_FORWARD = 9;
|
int COMMAND_SEEK_FORWARD = 8;
|
||||||
/** Command to set the seek back increment. */
|
|
||||||
int COMMAND_SET_SEEK_BACK_INCREMENT = 10;
|
|
||||||
/** Command to seek back into the current window. */
|
/** Command to seek back into the current window. */
|
||||||
int COMMAND_SEEK_BACK = 11;
|
int COMMAND_SEEK_BACK = 9;
|
||||||
/** 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 = 10;
|
||||||
/** Command to enable shuffling. */
|
/** Command to enable shuffling. */
|
||||||
int COMMAND_SET_SHUFFLE_MODE = 13;
|
int COMMAND_SET_SHUFFLE_MODE = 11;
|
||||||
/** Command to set the repeat mode. */
|
/** Command to set the repeat mode. */
|
||||||
int COMMAND_SET_REPEAT_MODE = 14;
|
int COMMAND_SET_REPEAT_MODE = 12;
|
||||||
/** Command to get the {@link MediaItem} of the current window. */
|
/** Command to get the {@link MediaItem} of the current window. */
|
||||||
int COMMAND_GET_CURRENT_MEDIA_ITEM = 15;
|
int COMMAND_GET_CURRENT_MEDIA_ITEM = 13;
|
||||||
/** Command to get the current timeline and its {@link MediaItem MediaItems}. */
|
/** Command to get the current timeline and its {@link MediaItem MediaItems}. */
|
||||||
int COMMAND_GET_MEDIA_ITEMS = 16;
|
int COMMAND_GET_MEDIA_ITEMS = 14;
|
||||||
/** Command to get the {@link MediaItem MediaItems} metadata. */
|
/** Command to get the {@link MediaItem MediaItems} metadata. */
|
||||||
int COMMAND_GET_MEDIA_ITEMS_METADATA = 17;
|
int COMMAND_GET_MEDIA_ITEMS_METADATA = 15;
|
||||||
/** Command to set the {@link MediaItem MediaItems} metadata. */
|
/** Command to set the {@link MediaItem MediaItems} metadata. */
|
||||||
int COMMAND_SET_MEDIA_ITEMS_METADATA = 18;
|
int COMMAND_SET_MEDIA_ITEMS_METADATA = 16;
|
||||||
/** Command to change the {@link MediaItem MediaItems} in the playlist. */
|
/** Command to change the {@link MediaItem MediaItems} in the playlist. */
|
||||||
int COMMAND_CHANGE_MEDIA_ITEMS = 19;
|
int COMMAND_CHANGE_MEDIA_ITEMS = 17;
|
||||||
/** Command to get the player current {@link AudioAttributes}. */
|
/** Command to get the player current {@link AudioAttributes}. */
|
||||||
int COMMAND_GET_AUDIO_ATTRIBUTES = 20;
|
int COMMAND_GET_AUDIO_ATTRIBUTES = 18;
|
||||||
/** Command to get the player volume. */
|
/** Command to get the player volume. */
|
||||||
int COMMAND_GET_VOLUME = 21;
|
int COMMAND_GET_VOLUME = 19;
|
||||||
/** Command to get the device volume and whether it is muted. */
|
/** Command to get the device volume and whether it is muted. */
|
||||||
int COMMAND_GET_DEVICE_VOLUME = 22;
|
int COMMAND_GET_DEVICE_VOLUME = 20;
|
||||||
/** Command to set the player volume. */
|
/** Command to set the player volume. */
|
||||||
int COMMAND_SET_VOLUME = 23;
|
int COMMAND_SET_VOLUME = 21;
|
||||||
/** Command to set the device volume and mute it. */
|
/** Command to set the device volume and mute it. */
|
||||||
int COMMAND_SET_DEVICE_VOLUME = 24;
|
int COMMAND_SET_DEVICE_VOLUME = 22;
|
||||||
/** Command to increase and decrease the device volume and mute it. */
|
/** Command to increase and decrease the device volume and mute it. */
|
||||||
int COMMAND_ADJUST_DEVICE_VOLUME = 25;
|
int COMMAND_ADJUST_DEVICE_VOLUME = 23;
|
||||||
/** Command to set and clear the surface on which to render the video. */
|
/** Command to set and clear the surface on which to render the video. */
|
||||||
int COMMAND_SET_VIDEO_SURFACE = 26;
|
int COMMAND_SET_VIDEO_SURFACE = 24;
|
||||||
/** Command to get the text that should currently be displayed by the player. */
|
/** Command to get the text that should currently be displayed by the player. */
|
||||||
int COMMAND_GET_TEXT = 27;
|
int COMMAND_GET_TEXT = 25;
|
||||||
|
|
||||||
/** Represents an invalid {@link Command}. */
|
/** Represents an invalid {@link Command}. */
|
||||||
int COMMAND_INVALID = -1;
|
int COMMAND_INVALID = -1;
|
||||||
@ -1625,19 +1610,9 @@ public interface Player {
|
|||||||
*/
|
*/
|
||||||
void seekTo(int windowIndex, long positionMs);
|
void seekTo(int windowIndex, long positionMs);
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the {@link #seekForward()} increment.
|
|
||||||
*
|
|
||||||
* @param seekForwardIncrementMs The seek forward increment, in milliseconds.
|
|
||||||
* @throws IllegalArgumentException If {@code seekForwardIncrementMs} is non-positive.
|
|
||||||
*/
|
|
||||||
void setSeekForwardIncrement(@IntRange(from = 1) long seekForwardIncrementMs);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link #seekForward()} increment.
|
* Returns the {@link #seekForward()} increment.
|
||||||
*
|
*
|
||||||
* <p>The default value is {@link #DEFAULT_SEEK_FORWARD_INCREMENT_MS}.
|
|
||||||
*
|
|
||||||
* @return The seek forward increment, in milliseconds.
|
* @return The seek forward increment, in milliseconds.
|
||||||
* @see Listener#onSeekForwardIncrementChanged(long)
|
* @see Listener#onSeekForwardIncrementChanged(long)
|
||||||
*/
|
*/
|
||||||
@ -1646,19 +1621,9 @@ public interface Player {
|
|||||||
/** Seeks forward in the current window by {@link #getSeekForwardIncrement()} milliseconds. */
|
/** Seeks forward in the current window by {@link #getSeekForwardIncrement()} milliseconds. */
|
||||||
void seekForward();
|
void seekForward();
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the {@link #seekBack()} increment.
|
|
||||||
*
|
|
||||||
* @param seekBackIncrementMs The seek back increment, in milliseconds.
|
|
||||||
* @throws IllegalArgumentException If {@code seekBackIncrementMs} is non-positive.
|
|
||||||
*/
|
|
||||||
void setSeekBackIncrement(@IntRange(from = 1) long seekBackIncrementMs);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link #seekBack()} increment.
|
* Returns the {@link #seekBack()} increment.
|
||||||
*
|
*
|
||||||
* <p>The default value is {@link #DEFAULT_SEEK_BACK_INCREMENT_MS}.
|
|
||||||
*
|
|
||||||
* @return The seek back increment, in milliseconds.
|
* @return The seek back increment, in milliseconds.
|
||||||
* @see Listener#onSeekBackIncrementChanged(long)
|
* @see Listener#onSeekBackIncrementChanged(long)
|
||||||
*/
|
*/
|
||||||
|
@ -828,6 +828,8 @@ public interface ExoPlayer extends Player {
|
|||||||
analyticsCollector,
|
analyticsCollector,
|
||||||
useLazyPreparation,
|
useLazyPreparation,
|
||||||
seekParameters,
|
seekParameters,
|
||||||
|
C.DEFAULT_SEEK_FORWARD_INCREMENT_MS,
|
||||||
|
C.DEFAULT_SEEK_BACK_INCREMENT_MS,
|
||||||
livePlaybackSpeedControl,
|
livePlaybackSpeedControl,
|
||||||
releaseTimeoutMs,
|
releaseTimeoutMs,
|
||||||
pauseAtEndOfMediaItems,
|
pauseAtEndOfMediaItems,
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2;
|
package com.google.android.exoplayer2;
|
||||||
|
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkArgument;
|
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkState;
|
import static com.google.android.exoplayer2.util.Assertions.checkState;
|
||||||
import static com.google.android.exoplayer2.util.Util.castNonNull;
|
import static com.google.android.exoplayer2.util.Util.castNonNull;
|
||||||
@ -89,6 +88,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
@Nullable private final AnalyticsCollector analyticsCollector;
|
@Nullable private final AnalyticsCollector analyticsCollector;
|
||||||
private final Looper applicationLooper;
|
private final Looper applicationLooper;
|
||||||
private final BandwidthMeter bandwidthMeter;
|
private final BandwidthMeter bandwidthMeter;
|
||||||
|
private final long seekForwardIncrementMs;
|
||||||
|
private final long seekBackIncrementMs;
|
||||||
private final Clock clock;
|
private final Clock clock;
|
||||||
|
|
||||||
@RepeatMode private int repeatMode;
|
@RepeatMode private int repeatMode;
|
||||||
@ -104,8 +105,6 @@ 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 seekForwardIncrementMs;
|
|
||||||
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;
|
||||||
@ -128,6 +127,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
* loads and other initial preparation steps happen immediately. If true, these initial
|
* loads and other initial preparation steps happen immediately. If true, these initial
|
||||||
* preparations are triggered only when the player starts buffering the media.
|
* preparations are triggered only when the player starts buffering the media.
|
||||||
* @param seekParameters The {@link SeekParameters}.
|
* @param seekParameters The {@link SeekParameters}.
|
||||||
|
* @param seekForwardIncrementMs The {@link #seekForward()} increment in milliseconds.
|
||||||
|
* @param seekBackIncrementMs The {@link #seekBack()} increment in milliseconds.
|
||||||
* @param livePlaybackSpeedControl The {@link LivePlaybackSpeedControl}.
|
* @param livePlaybackSpeedControl The {@link LivePlaybackSpeedControl}.
|
||||||
* @param releaseTimeoutMs The timeout for calls to {@link #release()} in milliseconds.
|
* @param releaseTimeoutMs The timeout for calls to {@link #release()} in milliseconds.
|
||||||
* @param pauseAtEndOfMediaItems Whether to pause playback at the end of each media item.
|
* @param pauseAtEndOfMediaItems Whether to pause playback at the end of each media item.
|
||||||
@ -149,6 +150,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
@Nullable AnalyticsCollector analyticsCollector,
|
@Nullable AnalyticsCollector analyticsCollector,
|
||||||
boolean useLazyPreparation,
|
boolean useLazyPreparation,
|
||||||
SeekParameters seekParameters,
|
SeekParameters seekParameters,
|
||||||
|
long seekForwardIncrementMs,
|
||||||
|
long seekBackIncrementMs,
|
||||||
LivePlaybackSpeedControl livePlaybackSpeedControl,
|
LivePlaybackSpeedControl livePlaybackSpeedControl,
|
||||||
long releaseTimeoutMs,
|
long releaseTimeoutMs,
|
||||||
boolean pauseAtEndOfMediaItems,
|
boolean pauseAtEndOfMediaItems,
|
||||||
@ -173,6 +176,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
this.analyticsCollector = analyticsCollector;
|
this.analyticsCollector = analyticsCollector;
|
||||||
this.useLazyPreparation = useLazyPreparation;
|
this.useLazyPreparation = useLazyPreparation;
|
||||||
this.seekParameters = seekParameters;
|
this.seekParameters = seekParameters;
|
||||||
|
this.seekForwardIncrementMs = seekForwardIncrementMs;
|
||||||
|
this.seekBackIncrementMs = seekBackIncrementMs;
|
||||||
this.pauseAtEndOfMediaItems = pauseAtEndOfMediaItems;
|
this.pauseAtEndOfMediaItems = pauseAtEndOfMediaItems;
|
||||||
this.applicationLooper = applicationLooper;
|
this.applicationLooper = applicationLooper;
|
||||||
this.clock = clock;
|
this.clock = clock;
|
||||||
@ -197,8 +202,6 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
.addAll(
|
.addAll(
|
||||||
COMMAND_PLAY_PAUSE,
|
COMMAND_PLAY_PAUSE,
|
||||||
COMMAND_PREPARE_STOP,
|
COMMAND_PREPARE_STOP,
|
||||||
COMMAND_SET_SEEK_FORWARD_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 +220,6 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
.build();
|
.build();
|
||||||
mediaMetadata = MediaMetadata.EMPTY;
|
mediaMetadata = MediaMetadata.EMPTY;
|
||||||
playlistMetadata = MediaMetadata.EMPTY;
|
playlistMetadata = MediaMetadata.EMPTY;
|
||||||
seekForwardIncrementMs = DEFAULT_SEEK_FORWARD_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 =
|
||||||
@ -719,35 +720,11 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
oldMaskingWindowIndex);
|
oldMaskingWindowIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSeekForwardIncrement(long seekForwardIncrementMs) {
|
|
||||||
checkArgument(seekForwardIncrementMs > 0);
|
|
||||||
if (this.seekForwardIncrementMs != seekForwardIncrementMs) {
|
|
||||||
this.seekForwardIncrementMs = seekForwardIncrementMs;
|
|
||||||
listeners.queueEvent(
|
|
||||||
Player.EVENT_SEEK_FORWARD_INCREMENT_CHANGED,
|
|
||||||
listener -> listener.onSeekForwardIncrementChanged(seekForwardIncrementMs));
|
|
||||||
listeners.flushEvents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSeekForwardIncrement() {
|
public long getSeekForwardIncrement() {
|
||||||
return seekForwardIncrementMs;
|
return seekForwardIncrementMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSeekBackIncrement(long seekBackIncrementMs) {
|
|
||||||
checkArgument(seekBackIncrementMs > 0);
|
|
||||||
if (this.seekBackIncrementMs != seekBackIncrementMs) {
|
|
||||||
this.seekBackIncrementMs = seekBackIncrementMs;
|
|
||||||
listeners.queueEvent(
|
|
||||||
Player.EVENT_SEEK_BACK_INCREMENT_CHANGED,
|
|
||||||
listener -> listener.onSeekBackIncrementChanged(seekBackIncrementMs));
|
|
||||||
listeners.flushEvents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSeekBackIncrement() {
|
public long getSeekBackIncrement() {
|
||||||
return seekBackIncrementMs;
|
return seekBackIncrementMs;
|
||||||
|
@ -24,6 +24,7 @@ import static com.google.android.exoplayer2.Renderer.MSG_SET_SKIP_SILENCE_ENABLE
|
|||||||
import static com.google.android.exoplayer2.Renderer.MSG_SET_VIDEO_FRAME_METADATA_LISTENER;
|
import static com.google.android.exoplayer2.Renderer.MSG_SET_VIDEO_FRAME_METADATA_LISTENER;
|
||||||
import static com.google.android.exoplayer2.Renderer.MSG_SET_VIDEO_OUTPUT;
|
import static com.google.android.exoplayer2.Renderer.MSG_SET_VIDEO_OUTPUT;
|
||||||
import static com.google.android.exoplayer2.Renderer.MSG_SET_VOLUME;
|
import static com.google.android.exoplayer2.Renderer.MSG_SET_VOLUME;
|
||||||
|
import static com.google.android.exoplayer2.util.Assertions.checkArgument;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
@ -38,6 +39,7 @@ import android.view.Surface;
|
|||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
import android.view.TextureView;
|
import android.view.TextureView;
|
||||||
|
import androidx.annotation.IntRange;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import com.google.android.exoplayer2.analytics.AnalyticsCollector;
|
import com.google.android.exoplayer2.analytics.AnalyticsCollector;
|
||||||
@ -127,6 +129,8 @@ public class SimpleExoPlayer extends BasePlayer
|
|||||||
@C.VideoScalingMode private int videoScalingMode;
|
@C.VideoScalingMode private int videoScalingMode;
|
||||||
private boolean useLazyPreparation;
|
private boolean useLazyPreparation;
|
||||||
private SeekParameters seekParameters;
|
private SeekParameters seekParameters;
|
||||||
|
private long seekForwardIncrementMs;
|
||||||
|
private long seekBackIncrementMs;
|
||||||
private LivePlaybackSpeedControl livePlaybackSpeedControl;
|
private LivePlaybackSpeedControl livePlaybackSpeedControl;
|
||||||
private long releaseTimeoutMs;
|
private long releaseTimeoutMs;
|
||||||
private long detachSurfaceTimeoutMs;
|
private long detachSurfaceTimeoutMs;
|
||||||
@ -163,6 +167,8 @@ public class SimpleExoPlayer extends BasePlayer
|
|||||||
* <li>{@link C.VideoScalingMode}: {@link C#VIDEO_SCALING_MODE_DEFAULT}
|
* <li>{@link C.VideoScalingMode}: {@link C#VIDEO_SCALING_MODE_DEFAULT}
|
||||||
* <li>{@code useLazyPreparation}: {@code true}
|
* <li>{@code useLazyPreparation}: {@code true}
|
||||||
* <li>{@link SeekParameters}: {@link SeekParameters#DEFAULT}
|
* <li>{@link SeekParameters}: {@link SeekParameters#DEFAULT}
|
||||||
|
* <li>{@code seekForwardIncrementMs}: {@link C#DEFAULT_SEEK_FORWARD_INCREMENT_MS}
|
||||||
|
* <li>{@code seekBackIncrementMs}: {@link C#DEFAULT_SEEK_BACK_INCREMENT_MS}
|
||||||
* <li>{@code releaseTimeoutMs}: {@link ExoPlayer#DEFAULT_RELEASE_TIMEOUT_MS}
|
* <li>{@code releaseTimeoutMs}: {@link ExoPlayer#DEFAULT_RELEASE_TIMEOUT_MS}
|
||||||
* <li>{@code detachSurfaceTimeoutMs}: {@link #DEFAULT_DETACH_SURFACE_TIMEOUT_MS}
|
* <li>{@code detachSurfaceTimeoutMs}: {@link #DEFAULT_DETACH_SURFACE_TIMEOUT_MS}
|
||||||
* <li>{@code pauseAtEndOfMediaItems}: {@code false}
|
* <li>{@code pauseAtEndOfMediaItems}: {@code false}
|
||||||
@ -260,6 +266,8 @@ public class SimpleExoPlayer extends BasePlayer
|
|||||||
videoScalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
|
videoScalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
|
||||||
useLazyPreparation = true;
|
useLazyPreparation = true;
|
||||||
seekParameters = SeekParameters.DEFAULT;
|
seekParameters = SeekParameters.DEFAULT;
|
||||||
|
seekForwardIncrementMs = C.DEFAULT_SEEK_FORWARD_INCREMENT_MS;
|
||||||
|
seekBackIncrementMs = C.DEFAULT_SEEK_BACK_INCREMENT_MS;
|
||||||
livePlaybackSpeedControl = new DefaultLivePlaybackSpeedControl.Builder().build();
|
livePlaybackSpeedControl = new DefaultLivePlaybackSpeedControl.Builder().build();
|
||||||
clock = Clock.DEFAULT;
|
clock = Clock.DEFAULT;
|
||||||
releaseTimeoutMs = ExoPlayer.DEFAULT_RELEASE_TIMEOUT_MS;
|
releaseTimeoutMs = ExoPlayer.DEFAULT_RELEASE_TIMEOUT_MS;
|
||||||
@ -495,6 +503,36 @@ public class SimpleExoPlayer extends BasePlayer
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link #seekForward()} increment.
|
||||||
|
*
|
||||||
|
* @param seekForwardIncrementMs The seek forward increment, in milliseconds.
|
||||||
|
* @return This builder.
|
||||||
|
* @throws IllegalArgumentException If {@code seekForwardIncrementMs} is non-positive.
|
||||||
|
* @throws IllegalStateException If {@link #build()} has already been called.
|
||||||
|
*/
|
||||||
|
public Builder setSeekForwardIncrementMs(@IntRange(from = 1) long seekForwardIncrementMs) {
|
||||||
|
checkArgument(seekForwardIncrementMs > 0);
|
||||||
|
Assertions.checkState(!buildCalled);
|
||||||
|
this.seekForwardIncrementMs = seekForwardIncrementMs;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link #seekBack()} increment.
|
||||||
|
*
|
||||||
|
* @param seekBackIncrementMs The seek back increment, in milliseconds.
|
||||||
|
* @return This builder.
|
||||||
|
* @throws IllegalArgumentException If {@code seekBackIncrementMs} is non-positive.
|
||||||
|
* @throws IllegalStateException If {@link #build()} has already been called.
|
||||||
|
*/
|
||||||
|
public Builder setSeekBackIncrementMs(@IntRange(from = 1) long seekBackIncrementMs) {
|
||||||
|
checkArgument(seekBackIncrementMs > 0);
|
||||||
|
Assertions.checkState(!buildCalled);
|
||||||
|
this.seekBackIncrementMs = seekBackIncrementMs;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a timeout for calls to {@link #release} and {@link #setForegroundMode}.
|
* Sets a timeout for calls to {@link #release} and {@link #setForegroundMode}.
|
||||||
*
|
*
|
||||||
@ -724,6 +762,8 @@ public class SimpleExoPlayer extends BasePlayer
|
|||||||
analyticsCollector,
|
analyticsCollector,
|
||||||
builder.useLazyPreparation,
|
builder.useLazyPreparation,
|
||||||
builder.seekParameters,
|
builder.seekParameters,
|
||||||
|
builder.seekForwardIncrementMs,
|
||||||
|
builder.seekBackIncrementMs,
|
||||||
builder.livePlaybackSpeedControl,
|
builder.livePlaybackSpeedControl,
|
||||||
builder.releaseTimeoutMs,
|
builder.releaseTimeoutMs,
|
||||||
builder.pauseAtEndOfMediaItems,
|
builder.pauseAtEndOfMediaItems,
|
||||||
@ -1562,24 +1602,12 @@ public class SimpleExoPlayer extends BasePlayer
|
|||||||
player.seekTo(windowIndex, positionMs);
|
player.seekTo(windowIndex, positionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSeekForwardIncrement(long seekForwardIncrementMs) {
|
|
||||||
verifyApplicationThread();
|
|
||||||
player.setSeekForwardIncrement(seekForwardIncrementMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSeekForwardIncrement() {
|
public long getSeekForwardIncrement() {
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
return player.getSeekForwardIncrement();
|
return player.getSeekForwardIncrement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSeekBackIncrement(long seekBackIncrementMs) {
|
|
||||||
verifyApplicationThread();
|
|
||||||
player.setSeekBackIncrement(seekBackIncrementMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSeekBackIncrement() {
|
public long getSeekBackIncrement() {
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
|
@ -36,14 +36,10 @@ import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_PREVIOUS_MEDI
|
|||||||
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_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_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_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.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,9 +8167,7 @@ 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_SEEK_FORWARD_INCREMENT)).isTrue();
|
|
||||||
assertThat(player.isCommandAvailable(COMMAND_SEEK_FORWARD)).isFalse();
|
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_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();
|
||||||
@ -10397,19 +10391,6 @@ public final class ExoPlayerTest {
|
|||||||
player.release();
|
player.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void setSeekForwardIncrement_notifiesSeekForwardIncrementChanged() {
|
|
||||||
ExoPlayer player = new TestExoPlayerBuilder(context).build();
|
|
||||||
Player.Listener listener = mock(Player.Listener.class);
|
|
||||||
player.addListener(listener);
|
|
||||||
long seekForwardIncrementMs = 1000;
|
|
||||||
|
|
||||||
player.setSeekForwardIncrement(seekForwardIncrementMs);
|
|
||||||
|
|
||||||
verify(listener).onSeekForwardIncrementChanged(seekForwardIncrementMs);
|
|
||||||
assertThat(player.getSeekForwardIncrement()).isEqualTo(seekForwardIncrementMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void seekForward_callsOnPositionDiscontinuity() throws Exception {
|
public void seekForward_callsOnPositionDiscontinuity() throws Exception {
|
||||||
ExoPlayer player = new TestExoPlayerBuilder(context).build();
|
ExoPlayer player = new TestExoPlayerBuilder(context).build();
|
||||||
@ -10420,7 +10401,7 @@ public final class ExoPlayerTest {
|
|||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ true,
|
/* isDynamic= */ true,
|
||||||
/* durationUs= */ C.msToUs(2 * DEFAULT_SEEK_FORWARD_INCREMENT_MS)));
|
/* durationUs= */ C.msToUs(2 * C.DEFAULT_SEEK_FORWARD_INCREMENT_MS)));
|
||||||
player.setMediaSource(new FakeMediaSource(fakeTimeline));
|
player.setMediaSource(new FakeMediaSource(fakeTimeline));
|
||||||
|
|
||||||
player.prepare();
|
player.prepare();
|
||||||
@ -10442,8 +10423,9 @@ 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_SEEK_FORWARD_INCREMENT_MS);
|
assertThat(newPositions.get(0).positionMs).isEqualTo(C.DEFAULT_SEEK_FORWARD_INCREMENT_MS);
|
||||||
assertThat(newPositions.get(0).contentPositionMs).isEqualTo(DEFAULT_SEEK_FORWARD_INCREMENT_MS);
|
assertThat(newPositions.get(0).contentPositionMs)
|
||||||
|
.isEqualTo(C.DEFAULT_SEEK_FORWARD_INCREMENT_MS);
|
||||||
|
|
||||||
player.release();
|
player.release();
|
||||||
}
|
}
|
||||||
@ -10456,31 +10438,18 @@ public final class ExoPlayerTest {
|
|||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ true,
|
/* isDynamic= */ true,
|
||||||
/* durationUs= */ C.msToUs(DEFAULT_SEEK_FORWARD_INCREMENT_MS / 2)));
|
/* durationUs= */ C.msToUs(C.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.seekForward();
|
player.seekForward();
|
||||||
|
|
||||||
assertThat(player.getCurrentPosition()).isEqualTo(DEFAULT_SEEK_FORWARD_INCREMENT_MS / 2);
|
assertThat(player.getCurrentPosition()).isEqualTo(C.DEFAULT_SEEK_FORWARD_INCREMENT_MS / 2);
|
||||||
|
|
||||||
player.release();
|
player.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void setSeekBackIncrement_notifiesSeekBackIncrementChanged() {
|
|
||||||
ExoPlayer player = new TestExoPlayerBuilder(context).build();
|
|
||||||
Player.Listener listener = mock(Player.Listener.class);
|
|
||||||
player.addListener(listener);
|
|
||||||
long seekBackIncrementMs = 1000;
|
|
||||||
|
|
||||||
player.setSeekBackIncrement(seekBackIncrementMs);
|
|
||||||
|
|
||||||
verify(listener).onSeekBackIncrementChanged(seekBackIncrementMs);
|
|
||||||
assertThat(player.getSeekBackIncrement()).isEqualTo(seekBackIncrementMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void seekBack_callsOnPositionDiscontinuity() throws Exception {
|
public void seekBack_callsOnPositionDiscontinuity() throws Exception {
|
||||||
ExoPlayer player = new TestExoPlayerBuilder(context).build();
|
ExoPlayer player = new TestExoPlayerBuilder(context).build();
|
||||||
@ -10491,12 +10460,12 @@ public final class ExoPlayerTest {
|
|||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ true,
|
/* isDynamic= */ true,
|
||||||
/* durationUs= */ C.msToUs(3 * DEFAULT_SEEK_BACK_INCREMENT_MS)));
|
/* durationUs= */ C.msToUs(3 * C.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_SEEK_BACK_INCREMENT_MS);
|
player, /* windowIndex= */ 0, /* positionMs= */ 2 * C.DEFAULT_SEEK_BACK_INCREMENT_MS);
|
||||||
player.seekBack();
|
player.seekBack();
|
||||||
|
|
||||||
ArgumentCaptor<Player.PositionInfo> oldPosition =
|
ArgumentCaptor<Player.PositionInfo> oldPosition =
|
||||||
@ -10514,16 +10483,18 @@ public final class ExoPlayerTest {
|
|||||||
assertThat(oldPositions.get(0).positionMs)
|
assertThat(oldPositions.get(0).positionMs)
|
||||||
.isIn(
|
.isIn(
|
||||||
Range.closed(
|
Range.closed(
|
||||||
2 * DEFAULT_SEEK_BACK_INCREMENT_MS - 20, 2 * DEFAULT_SEEK_BACK_INCREMENT_MS));
|
2 * C.DEFAULT_SEEK_BACK_INCREMENT_MS - 20, 2 * C.DEFAULT_SEEK_BACK_INCREMENT_MS));
|
||||||
assertThat(oldPositions.get(0).contentPositionMs)
|
assertThat(oldPositions.get(0).contentPositionMs)
|
||||||
.isIn(
|
.isIn(
|
||||||
Range.closed(
|
Range.closed(
|
||||||
2 * DEFAULT_SEEK_BACK_INCREMENT_MS - 20, 2 * DEFAULT_SEEK_BACK_INCREMENT_MS));
|
2 * C.DEFAULT_SEEK_BACK_INCREMENT_MS - 20, 2 * C.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_SEEK_BACK_INCREMENT_MS - 20, DEFAULT_SEEK_BACK_INCREMENT_MS));
|
.isIn(
|
||||||
|
Range.closed(C.DEFAULT_SEEK_BACK_INCREMENT_MS - 20, C.DEFAULT_SEEK_BACK_INCREMENT_MS));
|
||||||
assertThat(newPositions.get(0).contentPositionMs)
|
assertThat(newPositions.get(0).contentPositionMs)
|
||||||
.isIn(Range.closed(DEFAULT_SEEK_BACK_INCREMENT_MS - 20, DEFAULT_SEEK_BACK_INCREMENT_MS));
|
.isIn(
|
||||||
|
Range.closed(C.DEFAULT_SEEK_BACK_INCREMENT_MS - 20, C.DEFAULT_SEEK_BACK_INCREMENT_MS));
|
||||||
|
|
||||||
player.release();
|
player.release();
|
||||||
}
|
}
|
||||||
@ -10536,12 +10507,12 @@ public final class ExoPlayerTest {
|
|||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ true,
|
/* isDynamic= */ true,
|
||||||
/* durationUs= */ C.msToUs(DEFAULT_SEEK_BACK_INCREMENT_MS)));
|
/* durationUs= */ C.msToUs(C.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_SEEK_BACK_INCREMENT_MS / 2);
|
player, /* windowIndex= */ 0, /* positionMs= */ C.DEFAULT_SEEK_BACK_INCREMENT_MS / 2);
|
||||||
player.seekBack();
|
player.seekBack();
|
||||||
|
|
||||||
assertThat(player.getCurrentPosition()).isEqualTo(0);
|
assertThat(player.getCurrentPosition()).isEqualTo(0);
|
||||||
@ -10773,8 +10744,6 @@ public final class ExoPlayerTest {
|
|||||||
builder.addAll(
|
builder.addAll(
|
||||||
COMMAND_PLAY_PAUSE,
|
COMMAND_PLAY_PAUSE,
|
||||||
COMMAND_PREPARE_STOP,
|
COMMAND_PREPARE_STOP,
|
||||||
COMMAND_SET_SEEK_FORWARD_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,
|
||||||
|
@ -299,21 +299,11 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSeekForwardIncrement(long seekForwardIncrementMs) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSeekForwardIncrement() {
|
public long getSeekForwardIncrement() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSeekBackIncrement(long seekBackIncrementMs) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSeekBackIncrement() {
|
public long getSeekBackIncrement() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user