Package com.google.android.exoplayer2
Class SeekParameters
- java.lang.Object
-
- com.google.android.exoplayer2.SeekParameters
-
public final class SeekParameters extends Object
Parameters that apply to seeking.The predefined
EXACT
,CLOSEST_SYNC
,PREVIOUS_SYNC
andNEXT_SYNC
parameters are suitable for most use cases. Seeking to sync points is typically faster but less accurate than exact seeking.In the general case, an instance specifies a maximum tolerance before (
toleranceBeforeUs
) and after (toleranceAfterUs
) a requested seek position (x
). If one or more sync points falls within the window[x - toleranceBeforeUs, x + toleranceAfterUs]
then the seek will be performed to the sync point within the window that's closest tox
. If no sync point falls within the window then the seek will be performed tox - toleranceBeforeUs
. Internally the player may need to seek to an earlier sync point and discard media until this position is reached.
-
-
Field Summary
Fields Modifier and Type Field Description static SeekParameters
CLOSEST_SYNC
Parameters for seeking to the closest sync point.static SeekParameters
DEFAULT
Default parameters.static SeekParameters
EXACT
Parameters for exact seeking.static SeekParameters
NEXT_SYNC
Parameters for seeking to the sync point immediately after a requested seek position.static SeekParameters
PREVIOUS_SYNC
Parameters for seeking to the sync point immediately before a requested seek position.long
toleranceAfterUs
The maximum time that the actual position seeked to may exceed the requested seek position, in microseconds.long
toleranceBeforeUs
The maximum time that the actual position seeked to may precede the requested seek position, in microseconds.
-
Constructor Summary
Constructors Constructor Description SeekParameters(long toleranceBeforeUs, long toleranceAfterUs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
int
hashCode()
long
resolveSeekPositionUs(long positionUs, long firstSyncUs, long secondSyncUs)
Resolves a seek based on the parameters, given the requested seek position and two candidate sync points.
-
-
-
Field Detail
-
EXACT
public static final SeekParameters EXACT
Parameters for exact seeking.
-
CLOSEST_SYNC
public static final SeekParameters CLOSEST_SYNC
Parameters for seeking to the closest sync point.
-
PREVIOUS_SYNC
public static final SeekParameters PREVIOUS_SYNC
Parameters for seeking to the sync point immediately before a requested seek position.
-
NEXT_SYNC
public static final SeekParameters NEXT_SYNC
Parameters for seeking to the sync point immediately after a requested seek position.
-
DEFAULT
public static final SeekParameters DEFAULT
Default parameters.
-
toleranceBeforeUs
public final long toleranceBeforeUs
The maximum time that the actual position seeked to may precede the requested seek position, in microseconds.
-
toleranceAfterUs
public final long toleranceAfterUs
The maximum time that the actual position seeked to may exceed the requested seek position, in microseconds.
-
-
Constructor Detail
-
SeekParameters
public SeekParameters(long toleranceBeforeUs, long toleranceAfterUs)
- Parameters:
toleranceBeforeUs
- The maximum time that the actual position seeked to may precede the requested seek position, in microseconds. Must be non-negative.toleranceAfterUs
- The maximum time that the actual position seeked to may exceed the requested seek position, in microseconds. Must be non-negative.
-
-
Method Detail
-
resolveSeekPositionUs
public long resolveSeekPositionUs(long positionUs, long firstSyncUs, long secondSyncUs)
Resolves a seek based on the parameters, given the requested seek position and two candidate sync points.- Parameters:
positionUs
- The requested seek position, in microseocnds.firstSyncUs
- The first candidate seek point, in micrseconds.secondSyncUs
- The second candidate seek point, in microseconds. May equalfirstSyncUs
if there's only one candidate.- Returns:
- The resolved seek position, in microseconds.
-
-