# Player.Commands.Builder

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

*** ** * ** ***


```
@UnstableApi
class Player.Commands.Builder
```

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder#Builder()()` Creates a builder. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder#add(int)(@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command command: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Adds a `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder#addAll(int...)(@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command commands: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!)` Adds `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder#addAll(androidx.media3.common.Player.Commands)(commands: https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands!)` Adds `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder#addAllCommands()()` Adds all existing `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder#addAllReadOnlyCommands()()` Adds all existing `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command` that provide read access to the `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`, excluding all commands that allow to modify the state of the player. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder#addIf(int,boolean)(@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command command: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, condition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Adds a `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command` if the provided condition is true. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder#build()()` Builds a `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands` instance. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder#remove(int)(@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command command: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Removes a `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder#removeAll(int...)(@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command commands: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!)` Removes `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder#removeIf(int,boolean)(@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command command: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, condition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Removes a `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command` if the provided condition is true. |

## Public constructors

### Builder

```
Builder()
```

Creates a builder.

## Public functions

### add

```
@CanIgnoreReturnValue
fun add(@Player.Command command: Int): Player.Commands.Builder!
```

Adds a `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command command: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | This builder. |

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

### addAll

```
@CanIgnoreReturnValue
fun addAll(@Player.Command commands: IntArray<Int>!): Player.Commands.Builder!
```

Adds `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command commands: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command` to add. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | This builder. |

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

### addAll

```
@CanIgnoreReturnValue
fun addAll(commands: Player.Commands!): Player.Commands.Builder!
```

Adds `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands`.

| Parameters |
|---|---|
| `commands: https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands!` | The set of `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command` to add. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | This builder. |

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

### addAllCommands

```
@CanIgnoreReturnValue
fun addAllCommands(): Player.Commands.Builder!
```

Adds all existing `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | This builder. |

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

### addAllReadOnlyCommands

```
@CanIgnoreReturnValue
fun addAllReadOnlyCommands(): Player.Commands.Builder!
```

Adds all existing `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command` that provide read access to the `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`, excluding all commands that allow to modify the state of the player.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | This builder. |

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

### addIf

```
@CanIgnoreReturnValue
fun addIf(@Player.Command command: Int, condition: Boolean): Player.Commands.Builder!
```

Adds a `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command` if the provided condition is true. Does nothing otherwise.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command command: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`. |
| `condition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | A condition. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | This builder. |

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

### build

```
fun build(): Player.Commands!
```

Builds a `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands` instance.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If this method has already been called. |

### remove

```
@CanIgnoreReturnValue
fun remove(@Player.Command command: Int): Player.Commands.Builder!
```

Removes a `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command command: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | This builder. |

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

### removeAll

```
@CanIgnoreReturnValue
fun removeAll(@Player.Command commands: IntArray<Int>!): Player.Commands.Builder!
```

Removes `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command commands: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command` to remove. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | This builder. |

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

### removeIf

```
@CanIgnoreReturnValue
fun removeIf(@Player.Command command: Int, condition: Boolean): Player.Commands.Builder!
```

Removes a `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command` if the provided condition is true. Does nothing otherwise.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command command: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`. |
| `condition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | A condition. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands.Builder!` | This builder. |

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