# SeekParameters

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/SeekParameters.java+class:androidx.media3.exoplayer.SeekParameters)

*** ** * ** ***


```
@UnstableApi
public final class SeekParameters
```

<br />

*** ** * ** ***

Parameters that apply to seeking.

The predefined `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#EXACT()`, `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#CLOSEST_SYNC()`, `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#PREVIOUS_SYNC()` and `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#NEXT_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 (`https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#toleranceBeforeUs()`) and after (`https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#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 to `x`. If no sync point falls within the window then the seek will be performed to `x - toleranceBeforeUs`. Internally the player may need to seek to an earlier sync point and discard media until this position is reached.

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters` | `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#CLOSEST_SYNC()` Parameters for seeking to the closest sync point. |
| `static final https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters` | `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#DEFAULT()` Default parameters. |
| `static final https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters` | `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#EXACT()` Parameters for exact seeking. |
| `static final https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters` | `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#NEXT_SYNC()` Parameters for seeking to the sync point immediately after a requested seek position. |
| `static final https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters` | `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#PREVIOUS_SYNC()` Parameters for seeking to the sync point immediately before a requested seek position. |

| ### Public fields |
|---|---|
| `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#toleranceAfterUs()` The maximum time that the actual position seeked to may exceed the requested seek position, in microseconds. |
| `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#toleranceBeforeUs()` The maximum time that the actual position seeked to may precede the requested seek position, in microseconds. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#SeekParameters(long,long)(long toleranceBeforeUs, long toleranceAfterUs)` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html obj)` |
| `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#hashCode()()` |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/SeekParameters#resolveSeekPositionUs(long,long,long)( long positionUs, long firstSyncUs, long secondSyncUs )` Resolves a seek based on the parameters, given the requested seek position and two candidate sync points. |

## Constants

### CLOSEST_SYNC

```
public static final SeekParameters CLOSEST_SYNC
```

Parameters for seeking to the closest sync point.

### DEFAULT

```
public static final SeekParameters DEFAULT
```

Default parameters.

### EXACT

```
public static final SeekParameters EXACT
```

Parameters for exact seeking.

### NEXT_SYNC

```
public static final SeekParameters NEXT_SYNC
```

Parameters for seeking to the sync point immediately after a requested seek position.

### PREVIOUS_SYNC

```
public static final SeekParameters PREVIOUS_SYNC
```

Parameters for seeking to the sync point immediately before a requested seek position.

## Public fields

### toleranceAfterUs

```
public final long toleranceAfterUs
```

The maximum time that the actual position seeked to may exceed the requested seek position, in microseconds.

### toleranceBeforeUs

```
public final long toleranceBeforeUs
```

The maximum time that the actual position seeked to may precede the requested seek position, in microseconds.

## Public constructors

### SeekParameters

```
public SeekParameters(long toleranceBeforeUs, long toleranceAfterUs)
```

| Parameters |
|---|---|
| `long toleranceBeforeUs` | The maximum time that the actual position seeked to may precede the requested seek position, in microseconds. Must be non-negative. |
| `long toleranceAfterUs` | The maximum time that the actual position seeked to may exceed the requested seek position, in microseconds. Must be non-negative. |

## Public methods

### equals

```
public boolean equals(@Nullable Object obj)
```

### hashCode

```
public int hashCode()
```

### 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 |
|---|---|
| `long positionUs` | The requested seek position, in microseconds. |
| `long firstSyncUs` | The first candidate seek point, in microseconds. |
| `long secondSyncUs` | The second candidate seek point, in microseconds. May equal ` firstSyncUs` if there's only one candidate. |

| Returns |
|---|---|
| `long` | The resolved seek position, in microseconds. |