# RemoteCastPlayer.Builder

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

*** ** * ** ***


```
@UnstableApi
public final class RemoteCastPlayer.Builder
```

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer` instances.

See `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#Builder(android.content.Context)` for the list of default values.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#Builder(android.content.Context)(https://developer.android.com/reference/android/content/Context.html context)` Creates a builder. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer` | `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#build()()` Builds and returns a `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer` instance. |
| `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#setMaxSeekToPreviousPositionMs(long)( @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) long maxSeekToPreviousPositionMs )` Sets the maximum position for which `https://developer.android.com/reference/androidx/media3/common/BasePlayer#seekToPrevious()` seeks to the previous `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#setMediaItemConverter(androidx.media3.cast.MediaItemConverter)(https://developer.android.com/reference/androidx/media3/cast/MediaItemConverter mediaItemConverter)` Sets the `https://developer.android.com/reference/androidx/media3/cast/MediaItemConverter` that will be used by the player to convert `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#setSeekBackIncrementMs(long)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) long seekBackIncrementMs)` Sets the `https://developer.android.com/reference/androidx/media3/common/BasePlayer#seekBack()` increment. |
| `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#setSeekForwardIncrementMs(long)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) long seekForwardIncrementMs)` Sets the `https://developer.android.com/reference/androidx/media3/common/BasePlayer#seekForward()` increment. |
| `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#setTrackSelector(androidx.media3.cast.CastTrackSelector)(https://developer.android.com/reference/androidx/media3/cast/CastTrackSelector trackSelector)` Sets the `https://developer.android.com/reference/androidx/media3/cast/CastTrackSelector` that will be used by the player to handle `https://developer.android.com/reference/androidx/media3/common/TrackSelectionParameters`. |

## Public constructors

### Builder

```
public Builder(Context context)
```

Creates a builder.

The builder uses the following default values:

- `https://developer.android.com/reference/androidx/media3/cast/MediaItemConverter`: `https://developer.android.com/reference/androidx/media3/cast/DefaultMediaItemConverter`.
- `https://developer.android.com/reference/androidx/media3/cast/CastTrackSelector`: By default, `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_TRACK_SELECTION_PARAMETERS()` is not supported, and therefore `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer#setTrackSelectionParameters(androidx.media3.common.TrackSelectionParameters)` is a no-op. Calling `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#setTrackSelector(androidx.media3.cast.CastTrackSelector)` makes `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_TRACK_SELECTION_PARAMETERS()` allowed on the created `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer`, but the application responsible for implementing `https://developer.android.com/reference/androidx/media3/cast/CastTrackSelector#evaluate(androidx.media3.cast.CastTrackSelector.CastTrackSelectorRequest)`.
- `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#setSeekBackIncrementMs(long)`: `https://developer.android.com/reference/androidx/media3/common/C#DEFAULT_SEEK_BACK_INCREMENT_MS()`.
- `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#setSeekForwardIncrementMs(long)`: `https://developer.android.com/reference/androidx/media3/common/C#DEFAULT_SEEK_FORWARD_INCREMENT_MS()`.
- `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#setMaxSeekToPreviousPositionMs(long)`: `https://developer.android.com/reference/androidx/media3/common/C#DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | A `https://developer.android.com/reference/android/content/Context.html`. |

## Public methods

### build

```
public RemoteCastPlayer build()
```

Builds and returns a `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer` instance.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If any of the following condition occurs: - This method has already been called. - The `https://developer.android.com/reference/androidx/media3/cast/Cast` has not been initialized via `https://developer.android.com/reference/androidx/media3/cast/Cast#initialize()` before this method is called. |

### setMaxSeekToPreviousPositionMs

```
@CanIgnoreReturnValue
public RemoteCastPlayer.Builder setMaxSeekToPreviousPositionMs(
    @IntRange(from = 0) long maxSeekToPreviousPositionMs
)
```

Sets the maximum position for which `https://developer.android.com/reference/androidx/media3/common/BasePlayer#seekToPrevious()` seeks to the previous `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) long maxSeekToPreviousPositionMs` | The maximum position, in milliseconds. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder` | This builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `maxSeekToPreviousPositionMs` is negative. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#build()` has already been called. |

### setMediaItemConverter

```
@CanIgnoreReturnValue
public RemoteCastPlayer.Builder setMediaItemConverter(MediaItemConverter mediaItemConverter)
```

Sets the `https://developer.android.com/reference/androidx/media3/cast/MediaItemConverter` that will be used by the player to convert `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/cast/MediaItemConverter mediaItemConverter` | A `https://developer.android.com/reference/androidx/media3/cast/MediaItemConverter`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder` | This builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#build()` has already been called. |

### setSeekBackIncrementMs

```
@CanIgnoreReturnValue
public RemoteCastPlayer.Builder setSeekBackIncrementMs(@IntRange(from = 1) long seekBackIncrementMs)
```

Sets the `https://developer.android.com/reference/androidx/media3/common/BasePlayer#seekBack()` increment.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) long seekBackIncrementMs` | The seek back increment, in milliseconds. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder` | This builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `seekBackIncrementMs` is non-positive. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#build()` has already been called. |

### setSeekForwardIncrementMs

```
@CanIgnoreReturnValue
public RemoteCastPlayer.Builder setSeekForwardIncrementMs(@IntRange(from = 1) long seekForwardIncrementMs)
```

Sets the `https://developer.android.com/reference/androidx/media3/common/BasePlayer#seekForward()` increment.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) long seekForwardIncrementMs` | The seek forward increment, in milliseconds. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder` | This builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `seekForwardIncrementMs` is non-positive. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#build()` has already been called. |

### setTrackSelector

```
@CanIgnoreReturnValue
public RemoteCastPlayer.Builder setTrackSelector(CastTrackSelector trackSelector)
```

Sets the `https://developer.android.com/reference/androidx/media3/cast/CastTrackSelector` that will be used by the player to handle `https://developer.android.com/reference/androidx/media3/common/TrackSelectionParameters`.

Calling this setter enables `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_TRACK_SELECTION_PARAMETERS()` for the created `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer`.

The provided `https://developer.android.com/reference/androidx/media3/cast/CastTrackSelector` must take care of all options in `https://developer.android.com/reference/androidx/media3/common/TrackSelectionParameters` that the application uses.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/cast/CastTrackSelector trackSelector` | A `https://developer.android.com/reference/androidx/media3/cast/CastTrackSelector`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder` | This builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If `https://developer.android.com/reference/androidx/media3/cast/RemoteCastPlayer.Builder#build()` has already been called. |