# 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
public final class Player.Commands.Builder
```

<br />

*** ** * ** ***

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

## Summary

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

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

## Public constructors

### Builder

```
public Builder()
```

Creates a builder.

## Public methods

### add

```
@CanIgnoreReturnValue
public Player.Commands.Builder add(@Player.Command int command)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/Player.Command int command` | A `https://developer.android.com/reference/androidx/media3/common/Player.Command`. |

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

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

### addAll

```
@CanIgnoreReturnValue
public Player.Commands.Builder addAll(@Player.Command int[] commands)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/Player.Command int[] commands` | The `https://developer.android.com/reference/androidx/media3/common/Player.Command` to add. |

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

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

### addAll

```
@CanIgnoreReturnValue
public Player.Commands.Builder addAll(Player.Commands commands)
```

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

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

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

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

### addAllCommands

```
@CanIgnoreReturnValue
public Player.Commands.Builder addAllCommands()
```

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

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

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

### addAllReadOnlyCommands

```
@CanIgnoreReturnValue
public Player.Commands.Builder addAllReadOnlyCommands()
```

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

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

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

### addIf

```
@CanIgnoreReturnValue
public Player.Commands.Builder addIf(@Player.Command int command, boolean condition)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/Player.Command int command` | A `https://developer.android.com/reference/androidx/media3/common/Player.Command`. |
| `boolean condition` | A condition. |

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

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

### build

```
public Player.Commands build()
```

Builds a `https://developer.android.com/reference/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
public Player.Commands.Builder remove(@Player.Command int command)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/Player.Command int command` | A `https://developer.android.com/reference/androidx/media3/common/Player.Command`. |

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

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

### removeAll

```
@CanIgnoreReturnValue
public Player.Commands.Builder removeAll(@Player.Command int[] commands)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/Player.Command int[] commands` | The `https://developer.android.com/reference/androidx/media3/common/Player.Command` to remove. |

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

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

### removeIf

```
@CanIgnoreReturnValue
public Player.Commands.Builder removeIf(@Player.Command int command, boolean condition)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/Player.Command int command` | A `https://developer.android.com/reference/androidx/media3/common/Player.Command`. |
| `boolean condition` | A condition. |

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

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