# DefaultBandwidthMeter.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/upstream/DefaultBandwidthMeter.java+class:androidx.media3.exoplayer.upstream.DefaultBandwidthMeter.Builder)

*** ** * ** ***


```
class DefaultBandwidthMeter.Builder
```

<br />

*** ** * ** ***

Builder for a bandwidth meter.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder#Builder(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html!)` Creates a builder with default parameters and without listener. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder#build()()` Builds the bandwidth meter. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder#setClock(androidx.media3.common.util.Clock)(clock: https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock!)` Sets the clock used to estimate bandwidth from data transfers. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder#setInitialBitrateEstimate(java.lang.String)(countryCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Sets the initial bitrate estimates to the default values of the specified country. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder#setInitialBitrateEstimate(long)(initialBitrateEstimate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the initial bitrate estimate in bits per second that should be assumed when a bandwidth estimate is unavailable. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder#setInitialBitrateEstimate(int,long)( @https://developer.android.com/reference/kotlin/androidx/media3/common/C.NetworkType networkType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, initialBitrateEstimate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Sets the initial bitrate estimate in bits per second that should be assumed when a bandwidth estimate is unavailable and the current network connection is of the specified type. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder#setInitialBitrateSupplier(androidx.media3.exoplayer.upstream.DefaultBandwidthMeter.InitialBitrateSupplier)( initialBitrateSupplier: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.InitialBitrateSupplier! )` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.InitialBitrateSupplier` to use for obtaining the initial bitrate estimate when a bandwidth estimate is unavailable. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder#setResetOnNetworkTypeChange(boolean)(resetOnNetworkTypeChange: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether to reset if the network type changes. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder#setSlidingWindowMaxWeight(int)(slidingWindowMaxWeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the maximum weight for the sliding window. |

## Public constructors

### Builder

```
Builder(context: Context!)
```

Creates a builder with default parameters and without listener.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html!` | A context. |

## Public functions

### build

```
fun build(): DefaultBandwidthMeter!
```

Builds the bandwidth meter.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter!` | A bandwidth meter with the configured properties. |

### setClock

```
@CanIgnoreReturnValue
fun setClock(clock: Clock!): DefaultBandwidthMeter.Builder!
```

Sets the clock used to estimate bandwidth from data transfers. Should only be set for testing purposes.

| Parameters |
|---|---|
| `clock: https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock!` | The clock used to estimate bandwidth from data transfers. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | This builder. |

### setInitialBitrateEstimate

```
@CanIgnoreReturnValue
fun setInitialBitrateEstimate(countryCode: String!): DefaultBandwidthMeter.Builder!
```

Sets the initial bitrate estimates to the default values of the specified country. The initial estimates are used when a bandwidth estimate is unavailable.

| Parameters |
|---|---|
| `countryCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The ISO 3166-1 alpha-2 country code of the country whose default bitrate estimates should be used. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | This builder. |

### setInitialBitrateEstimate

```
@CanIgnoreReturnValue
fun setInitialBitrateEstimate(initialBitrateEstimate: Long): DefaultBandwidthMeter.Builder!
```

Sets the initial bitrate estimate in bits per second that should be assumed when a bandwidth estimate is unavailable.

| Parameters |
|---|---|
| `initialBitrateEstimate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The initial bitrate estimate in bits per second. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | This builder. |

### setInitialBitrateEstimate

```
@CanIgnoreReturnValue
fun setInitialBitrateEstimate(
    @C.NetworkType networkType: Int,
    initialBitrateEstimate: Long
): DefaultBandwidthMeter.Builder!
```

Sets the initial bitrate estimate in bits per second that should be assumed when a bandwidth estimate is unavailable and the current network connection is of the specified type.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.NetworkType networkType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/C.NetworkType` this initial estimate is for. |
| `initialBitrateEstimate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The initial bitrate estimate in bits per second. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | This builder. |

### setInitialBitrateSupplier

```
@CanIgnoreReturnValue
fun setInitialBitrateSupplier(
    initialBitrateSupplier: DefaultBandwidthMeter.InitialBitrateSupplier!
): DefaultBandwidthMeter.Builder!
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.InitialBitrateSupplier` to use for obtaining the initial bitrate estimate when a bandwidth estimate is unavailable.

By default, no supplier is set and the meter falls back to its internal default logic.

| Parameters |
|---|---|
| `initialBitrateSupplier: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.InitialBitrateSupplier!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.InitialBitrateSupplier`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | This builder. |

### setResetOnNetworkTypeChange

```
@CanIgnoreReturnValue
fun setResetOnNetworkTypeChange(resetOnNetworkTypeChange: Boolean): DefaultBandwidthMeter.Builder!
```

Sets whether to reset if the network type changes. The default value is `true`.

| Parameters |
|---|---|
| `resetOnNetworkTypeChange: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to reset if the network type changes. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | This builder. |

### setSlidingWindowMaxWeight

```
@CanIgnoreReturnValue
fun setSlidingWindowMaxWeight(slidingWindowMaxWeight: Int): DefaultBandwidthMeter.Builder!
```

Sets the maximum weight for the sliding window.

| Parameters |
|---|---|
| `slidingWindowMaxWeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum weight for the sliding window. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.Builder!` | This builder. |