# 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)

*** ** * ** ***


```
public final class CommandButton.DisplayConstraints.Builder
```

<br />

*** ** * ** ***

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

## Summary

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

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

## Public constructors

### Builder

```
public Builder()
```

Creates the builder.

## Public methods

### build

```
public CommandButton.DisplayConstraints build()
```

Builds the display constraints.

### setAllowCustomCommandsForSlot

```
@CanIgnoreReturnValue
public CommandButton.DisplayConstraints.Builder setAllowCustomCommandsForSlot(
    @CommandButton.Slot int slot,
    boolean allowCustomCommands
)
```

Sets whether `https://developer.android.com/reference/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/androidx/media3/session/CommandButton.Slot int slot` | The `https://developer.android.com/reference/androidx/media3/session/CommandButton.Slot`. |
| `boolean allowCustomCommands` | Whether `https://developer.android.com/reference/androidx/media3/session/SessionCommand#COMMAND_CODE_CUSTOM()` are allowed for buttons in this slot. |

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

### setAllowedPlayerCommandsForSlot

```
@CanIgnoreReturnValue
public CommandButton.DisplayConstraints.Builder setAllowedPlayerCommandsForSlot(
    @CommandButton.Slot int slot,
    @Nullable Player.Commands allowedPlayerCommands
)
```

Sets the allowed `https://developer.android.com/reference/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/androidx/media3/common/Player.Commands`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/session/CommandButton.Slot int slot` | The `https://developer.android.com/reference/androidx/media3/session/CommandButton.Slot`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player.Commands allowedPlayerCommands` | The allowed `https://developer.android.com/reference/androidx/media3/common/Player.Commands` for buttons in this slot, or null to allow all `https://developer.android.com/reference/androidx/media3/common/Player.Commands` . |

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

### setAllowedSessionCommandsForSlot

```
@CanIgnoreReturnValue
public CommandButton.DisplayConstraints.Builder setAllowedSessionCommandsForSlot(
    @CommandButton.Slot int slot,
    @Nullable SessionCommands allowedSessionCommands
)
```

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

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

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/session/CommandButton.Slot int slot` | The `https://developer.android.com/reference/androidx/media3/session/CommandButton.Slot`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/session/SessionCommands allowedSessionCommands` | The allowed `https://developer.android.com/reference/androidx/media3/session/SessionCommands` for buttons in this slot, or null to allow all `https://developer.android.com/reference/androidx/media3/session/SessionCommands`. |

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

### setMaxButtonsForSlot

```
@CanIgnoreReturnValue
public CommandButton.DisplayConstraints.Builder setMaxButtonsForSlot(@CommandButton.Slot int slot, int maxButtons)
```

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

The default values are:

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

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

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