# DefaultLoadControl.Builder

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

*** ** * ** ***


```
class DefaultLoadControl.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#Builder()()` Constructs a new instance. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#build()()` Creates a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setAllocator(androidx.media3.exoplayer.upstream.DefaultAllocator)(allocator: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultAllocator!)` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultAllocator` used by the loader. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setBackBuffer(int,boolean)( backBufferDurationMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, retainBackBufferFromKeyframe: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Sets the back buffer duration, and whether the back buffer is retained from the previous keyframe. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setBufferDurationsMs(int,int,int,int)( minBufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxBufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bufferForPlaybackMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bufferForPlaybackAfterRebufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Sets the buffer duration parameters for both streaming and local on-device playback. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setBufferDurationsMsForLocalPlayback(int,int,int,int)( minBufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxBufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bufferForPlaybackMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bufferForPlaybackAfterRebufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Sets the buffer duration parameters for local on-device playback. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setBufferDurationsMsForStreaming(int,int,int,int)( minBufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxBufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bufferForPlaybackMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bufferForPlaybackAfterRebufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Sets the buffer duration parameters for streaming playback. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setPlayerTargetBufferBytes(java.lang.String,int)( playerName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, playerTargetBufferBytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Sets the target buffer size in bytes for a player with the specified `playerName`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setPrioritizeTimeOverSizeThresholds(boolean)( prioritizeTimeOverSizeThresholds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Sets whether the load control prioritizes buffer time constraints over buffer size constraints for streaming and local on-device playback. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setPrioritizeTimeOverSizeThresholdsForLocalPlayback(boolean)( prioritizeTimeOverSizeThresholds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Sets whether the load control prioritizes buffer time constraints over buffer size constraints for local on-device playback. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setPrioritizeTimeOverSizeThresholdsForStreaming(boolean)( prioritizeTimeOverSizeThresholds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Sets whether the load control prioritizes buffer time constraints over buffer size constraints for streaming playback. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setTargetBufferBytes(int)(targetBufferBytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the target buffer size in bytes for each player. |

## Public constructors

### Builder

```
Builder()
```

Constructs a new instance.

## Public functions

### build

```
fun build(): DefaultLoadControl!
```

Creates a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl`.

### setAllocator

```
@CanIgnoreReturnValue
fun setAllocator(allocator: DefaultAllocator!): DefaultLoadControl.Builder!
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultAllocator` used by the loader.

| Parameters |
|---|---|
| `allocator: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultAllocator!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultAllocator`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | This builder, for convenience. |

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

### setBackBuffer

```
@CanIgnoreReturnValue
fun setBackBuffer(
    backBufferDurationMs: Int,
    retainBackBufferFromKeyframe: Boolean
): DefaultLoadControl.Builder!
```

Sets the back buffer duration, and whether the back buffer is retained from the previous keyframe.

| Parameters |
|---|---|
| `backBufferDurationMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The back buffer duration in milliseconds. |
| `retainBackBufferFromKeyframe: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the back buffer is retained from the previous keyframe. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | This builder, for convenience. |

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

### setBufferDurationsMs

```
@CanIgnoreReturnValue
fun setBufferDurationsMs(
    minBufferMs: Int,
    maxBufferMs: Int,
    bufferForPlaybackMs: Int,
    bufferForPlaybackAfterRebufferMs: Int
): DefaultLoadControl.Builder!
```

Sets the buffer duration parameters for both streaming and local on-device playback.

Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setBufferDurationsMsForStreaming(int,int,int,int)` or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setBufferDurationsMsForLocalPlayback(int,int,int,int)` to set them separately for each use case.

| Parameters |
|---|---|
| `minBufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The minimum duration of media that the player will attempt to ensure is buffered at all times, in milliseconds. |
| `maxBufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum duration of media that the player will attempt to buffer, in milliseconds. |
| `bufferForPlaybackMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The duration of media that must be buffered for playback to start or resume following a user action such as a seek, in milliseconds. |
| `bufferForPlaybackAfterRebufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The default duration of media that must be buffered for playback to resume after a rebuffer, in milliseconds. A rebuffer is defined to be caused by buffer depletion rather than a user action. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | This builder, for convenience. |

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

### setBufferDurationsMsForLocalPlayback

```
@CanIgnoreReturnValue
fun setBufferDurationsMsForLocalPlayback(
    minBufferMs: Int,
    maxBufferMs: Int,
    bufferForPlaybackMs: Int,
    bufferForPlaybackAfterRebufferMs: Int
): DefaultLoadControl.Builder!
```

Sets the buffer duration parameters for local on-device playback.

Playbacks are considered to be on-device if the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LocalConfiguration#uri()` has an empty scheme or one of the schemes in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl#LOCAL_PLAYBACK_SCHEMES()`.

| Parameters |
|---|---|
| `minBufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The minimum duration of media that the player will attempt to ensure is buffered at all times, in milliseconds. |
| `maxBufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum duration of media that the player will attempt to buffer, in milliseconds. |
| `bufferForPlaybackMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The duration of media that must be buffered for playback to start or resume following a user action such as a seek, in milliseconds. |
| `bufferForPlaybackAfterRebufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The default duration of media that must be buffered for playback to resume after a rebuffer, in milliseconds. A rebuffer is defined to be caused by buffer depletion rather than a user action. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | This builder, for convenience. |

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

### setBufferDurationsMsForStreaming

```
@CanIgnoreReturnValue
fun setBufferDurationsMsForStreaming(
    minBufferMs: Int,
    maxBufferMs: Int,
    bufferForPlaybackMs: Int,
    bufferForPlaybackAfterRebufferMs: Int
): DefaultLoadControl.Builder!
```

Sets the buffer duration parameters for streaming playback.

Playbacks are considered to be streaming if the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LocalConfiguration#uri()` is none of the schemes in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl#LOCAL_PLAYBACK_SCHEMES()`.

| Parameters |
|---|---|
| `minBufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The minimum duration of media that the player will attempt to ensure is buffered at all times, in milliseconds. |
| `maxBufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum duration of media that the player will attempt to buffer, in milliseconds. |
| `bufferForPlaybackMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The duration of media that must be buffered for playback to start or resume following a user action such as a seek, in milliseconds. |
| `bufferForPlaybackAfterRebufferMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The default duration of media that must be buffered for playback to resume after a rebuffer, in milliseconds. A rebuffer is defined to be caused by buffer depletion rather than a user action. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | This builder, for convenience. |

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

### setPlayerTargetBufferBytes

```
@CanIgnoreReturnValue
fun setPlayerTargetBufferBytes(
    playerName: String!,
    playerTargetBufferBytes: Int
): DefaultLoadControl.Builder!
```

Sets the target buffer size in bytes for a player with the specified `playerName`. When not set or set to `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()`, the target buffer size of a player will be the value set via `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setTargetBufferBytes(int)` if it is not `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()`, otherwise it will be calculated based on the selected tracks of the player.

For the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId#PRELOAD()` with `PlayerId.PRELOAD.name`, the default target buffer bytes is `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl#DEFAULT_TARGET_BUFFER_BYTES_FOR_PRELOAD()`.

| Parameters |
|---|---|
| `playerName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The name of the player. The same name must be set to the player via `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer.Builder#setName(java.lang.String)` in order to be effective at the created `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl`. |
| `playerTargetBufferBytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The target buffer size in bytes for the specified player. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | This builder, for convenience. |

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

### setPrioritizeTimeOverSizeThresholds

```
@CanIgnoreReturnValue
fun setPrioritizeTimeOverSizeThresholds(
    prioritizeTimeOverSizeThresholds: Boolean
): DefaultLoadControl.Builder!
```

Sets whether the load control prioritizes buffer time constraints over buffer size constraints for streaming and local on-device playback.

Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setPrioritizeTimeOverSizeThresholdsForStreaming(boolean)` or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setPrioritizeTimeOverSizeThresholdsForLocalPlayback(boolean)` to set them separately for each use case.

| Parameters |
|---|---|
| `prioritizeTimeOverSizeThresholds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the load control prioritizes buffer time constraints over buffer size constraints. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | This builder, for convenience. |

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

### setPrioritizeTimeOverSizeThresholdsForLocalPlayback

```
@CanIgnoreReturnValue
fun setPrioritizeTimeOverSizeThresholdsForLocalPlayback(
    prioritizeTimeOverSizeThresholds: Boolean
): DefaultLoadControl.Builder!
```

Sets whether the load control prioritizes buffer time constraints over buffer size constraints for local on-device playback.

Playbacks are considered to be on-device if the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LocalConfiguration#uri()` has an empty scheme or one of the schemes in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl#LOCAL_PLAYBACK_SCHEMES()`.

| Parameters |
|---|---|
| `prioritizeTimeOverSizeThresholds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the load control prioritizes buffer time constraints over buffer size constraints. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | This builder, for convenience. |

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

### setPrioritizeTimeOverSizeThresholdsForStreaming

```
@CanIgnoreReturnValue
fun setPrioritizeTimeOverSizeThresholdsForStreaming(
    prioritizeTimeOverSizeThresholds: Boolean
): DefaultLoadControl.Builder!
```

Sets whether the load control prioritizes buffer time constraints over buffer size constraints for streaming playback.

Playbacks are considered to be streaming if the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LocalConfiguration#uri()` is none of the schemes in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl#LOCAL_PLAYBACK_SCHEMES()`.

| Parameters |
|---|---|
| `prioritizeTimeOverSizeThresholds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the load control prioritizes buffer time constraints over buffer size constraints. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | This builder, for convenience. |

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

### setTargetBufferBytes

```
@CanIgnoreReturnValue
fun setTargetBufferBytes(targetBufferBytes: Int): DefaultLoadControl.Builder!
```

Sets the target buffer size in bytes for each player. If set to `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()`, the target buffer size of a player will be calculated based on the selected tracks of the player.

This value will be ignored for the players with a `playerName` that has target buffer size set via `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder#setPlayerTargetBufferBytes(java.lang.String,int)`.

| Parameters |
|---|---|
| `targetBufferBytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The target buffer size in bytes. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLoadControl.Builder!` | This builder, for convenience. |

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