# CommandButton.DisplayConstraints.Builder

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

*** ** * ** ***


```
class CommandButton.DisplayConstraints.Builder
```

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder#Builder()()` Creates the builder. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints!` | `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder#build()()` Builds the display constraints. |
| `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder#setAllowCustomCommandsForSlot(int,boolean)( @https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.Slot slot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, allowCustomCommands: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Sets whether `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionCommand#COMMAND_CODE_CUSTOM()` are allowed for buttons in the given slot. |
| `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder#setAllowedPlayerCommandsForSlot(int,androidx.media3.common.Player.Commands)( @https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.Slot slot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, allowedPlayerCommands: https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands? )` Sets the allowed `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands` for buttons in the given slot. |
| `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder#setAllowedSessionCommandsForSlot(int,androidx.media3.session.SessionCommands)( @https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.Slot slot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, allowedSessionCommands: https://developer.android.com/reference/kotlin/androidx/media3/session/SessionCommands? )` Sets the allowed non-custom `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionCommands` for buttons in the given slot. |
| `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder#setMaxButtonsForSlot(int,int)(@https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.Slot slot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxButtons: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the maximum number of buttons that can be displayed in a slot. |

## Public constructors

### Builder

```
Builder()
```

Creates the builder.

## Public functions

### build

```
fun build(): CommandButton.DisplayConstraints!
```

Builds the display constraints.

### setAllowCustomCommandsForSlot

```
@CanIgnoreReturnValue
fun setAllowCustomCommandsForSlot(
    @CommandButton.Slot slot: Int,
    allowCustomCommands: Boolean
): CommandButton.DisplayConstraints.Builder!
```

Sets whether `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionCommand#COMMAND_CODE_CUSTOM()` are allowed for buttons in the given slot.

The default value is `true`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.Slot slot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.Slot`. |
| `allowCustomCommands: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionCommand#COMMAND_CODE_CUSTOM()` are allowed for buttons in this slot. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder!` | This builder. |

### setAllowedPlayerCommandsForSlot

```
@CanIgnoreReturnValue
fun setAllowedPlayerCommandsForSlot(
    @CommandButton.Slot slot: Int,
    allowedPlayerCommands: Player.Commands?
): CommandButton.DisplayConstraints.Builder!
```

Sets the allowed `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands` for buttons in the given slot.

The default value (`null`) does not restrict the allowed `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.Slot slot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.Slot`. |
| `allowedPlayerCommands: https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands?` | The allowed `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands` for buttons in this slot, or null to allow all `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands` . |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder!` | This builder. |

### setAllowedSessionCommandsForSlot

```
@CanIgnoreReturnValue
fun setAllowedSessionCommandsForSlot(
    @CommandButton.Slot slot: Int,
    allowedSessionCommands: SessionCommands?
): CommandButton.DisplayConstraints.Builder!
```

Sets the allowed non-custom `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionCommands` for buttons in the given slot.

The default value (`null`) does not restrict the allowed `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionCommands`.

This setting has no effect on whether `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionCommand#COMMAND_CODE_CUSTOM()` are allowed. Use `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder#setAllowCustomCommandsForSlot(int,boolean)` instead.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.Slot slot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.Slot`. |
| `allowedSessionCommands: https://developer.android.com/reference/kotlin/androidx/media3/session/SessionCommands?` | The allowed `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionCommands` for buttons in this slot, or null to allow all `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionCommands`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder!` | This builder. |

### setMaxButtonsForSlot

```
@CanIgnoreReturnValue
fun setMaxButtonsForSlot(@CommandButton.Slot slot: Int, maxButtons: Int): CommandButton.DisplayConstraints.Builder!
```

Sets the maximum number of buttons that can be displayed in a slot.

The default values are:

- `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton#SLOT_CENTRAL()`, `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton#SLOT_BACK()`, `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton#SLOT_FORWARD()`: 1
- `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton#SLOT_BACK_SECONDARY()`, `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton#SLOT_FORWARD_SECONDARY()`: 0
- `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton#SLOT_OVERFLOW()`: `https://developer.android.com/reference/java/lang/Integer.html#MAX_VALUE`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.Slot slot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.Slot`. |
| `maxButtons: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum number of buttons that can be displayed in this slot. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton.DisplayConstraints.Builder!` | This builder. |