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

*** ** * ** ***


```
public final class DefaultBandwidthMeter.Builder
```

<br />

*** ** * ** ***

Builder for a bandwidth meter.

## Summary

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

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

## Public constructors

### Builder

```
public Builder(Context context)
```

Creates a builder with default parameters and without listener.

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

## Public methods

### build

```
public DefaultBandwidthMeter build()
```

Builds the bandwidth meter.

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

### setClock

```
@CanIgnoreReturnValue
public DefaultBandwidthMeter.Builder setClock(Clock clock)
```

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

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

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

### setInitialBitrateEstimate

```
@CanIgnoreReturnValue
public DefaultBandwidthMeter.Builder setInitialBitrateEstimate(String countryCode)
```

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 |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html countryCode` | The ISO 3166-1 alpha-2 country code of the country whose default bitrate estimates should be used. |

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

### setInitialBitrateEstimate

```
@CanIgnoreReturnValue
public DefaultBandwidthMeter.Builder setInitialBitrateEstimate(long initialBitrateEstimate)
```

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

| Parameters |
|---|---|
| `long initialBitrateEstimate` | The initial bitrate estimate in bits per second. |

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

### setInitialBitrateEstimate

```
@CanIgnoreReturnValue
public DefaultBandwidthMeter.Builder setInitialBitrateEstimate(
    @C.NetworkType int networkType,
    long initialBitrateEstimate
)
```

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/androidx/media3/common/C.NetworkType int networkType` | The `https://developer.android.com/reference/androidx/media3/common/C.NetworkType` this initial estimate is for. |
| `long initialBitrateEstimate` | The initial bitrate estimate in bits per second. |

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

### setInitialBitrateSupplier

```
@CanIgnoreReturnValue
public DefaultBandwidthMeter.Builder setInitialBitrateSupplier(
    DefaultBandwidthMeter.InitialBitrateSupplier initialBitrateSupplier
)
```

Sets the `https://developer.android.com/reference/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 |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.InitialBitrateSupplier initialBitrateSupplier` | The `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.InitialBitrateSupplier`. |

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

### setResetOnNetworkTypeChange

```
@CanIgnoreReturnValue
public DefaultBandwidthMeter.Builder setResetOnNetworkTypeChange(boolean resetOnNetworkTypeChange)
```

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

| Parameters |
|---|---|
| `boolean resetOnNetworkTypeChange` | Whether to reset if the network type changes. |

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

### setSlidingWindowMaxWeight

```
@CanIgnoreReturnValue
public DefaultBandwidthMeter.Builder setSlidingWindowMaxWeight(int slidingWindowMaxWeight)
```

Sets the maximum weight for the sliding window.

| Parameters |
|---|---|
| `int slidingWindowMaxWeight` | The maximum weight for the sliding window. |

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