# DownloadBuilder

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

*** ** * ** ***


```
@UnstableApi
class DownloadBuilder
```

<br />

*** ** * ** ***

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

Defines default values for each field (except `id`) to facilitate `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download` creation for tests. Tests must avoid depending on the default values but explicitly set tested parameters during test initialization.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#DownloadBuilder(java.lang.String)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Creates a download builder for "uri" and no stream keys. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#DownloadBuilder(androidx.media3.exoplayer.offline.DownloadRequest)(request: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!)` Creates a download builder based on the attributes of the specified request. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#build()()` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setBytesDownloaded(long)(bytesDownloaded: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setCacheKey(java.lang.String)(cacheKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setContentLength(long)(contentLength: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setCustomMetadata(byte[])(customMetadata: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setFailureReason(int)(failureReason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setKeySetId(byte[])(keySetId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setMimeType(java.lang.String)(mimeType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setPercentDownloaded(float)(percentDownloaded: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setStartTimeMs(long)(startTimeMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setState(int)(@https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download.State state: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setStopReason(int)(stopReason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setStreamKeys(androidx.media3.common.StreamKey...)(streamKeys: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey!>!)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setUpdateTimeMs(long)(updateTimeMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setUri(java.lang.String)(uri: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DownloadBuilder#setUri(android.net.Uri)(uri: https://developer.android.com/reference/android/net/Uri.html!)` |

## Public constructors

### DownloadBuilder

```
DownloadBuilder(id: String!)
```

Creates a download builder for "uri" and no stream keys.

| Parameters |
|---|---|
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The unique content identifier for the download. |

### DownloadBuilder

```
DownloadBuilder(request: DownloadRequest!)
```

Creates a download builder based on the attributes of the specified request.

| Parameters |
|---|---|
| `request: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest` defining the content to download. |

## Public functions

### build

```
fun build(): Download!
```

### setBytesDownloaded

```
@CanIgnoreReturnValue
fun setBytesDownloaded(bytesDownloaded: Long): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadProgress#bytesDownloaded()` |   |

### setCacheKey

```
@CanIgnoreReturnValue
fun setCacheKey(cacheKey: String?): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#customCacheKey()` |   |

### setContentLength

```
@CanIgnoreReturnValue
fun setContentLength(contentLength: Long): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#contentLength()` |   |

### setCustomMetadata

```
@CanIgnoreReturnValue
fun setCustomMetadata(customMetadata: ByteArray<Byte>!): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#data()` |   |

### setFailureReason

```
@CanIgnoreReturnValue
fun setFailureReason(failureReason: Int): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#failureReason()` |   |

### setKeySetId

```
@CanIgnoreReturnValue
fun setKeySetId(keySetId: ByteArray<Byte>!): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#keySetId()` |   |

### setMimeType

```
@CanIgnoreReturnValue
fun setMimeType(mimeType: String!): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#mimeType()` |   |

### setPercentDownloaded

```
@CanIgnoreReturnValue
fun setPercentDownloaded(percentDownloaded: Float): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadProgress#percentDownloaded()` |   |

### setStartTimeMs

```
@CanIgnoreReturnValue
fun setStartTimeMs(startTimeMs: Long): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#startTimeMs()` |   |

### setState

```
@CanIgnoreReturnValue
fun setState(@Download.State state: Int): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#state()` |   |

### setStopReason

```
@CanIgnoreReturnValue
fun setStopReason(stopReason: Int): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#stopReason()` |   |

### setStreamKeys

```
@CanIgnoreReturnValue
fun setStreamKeys(streamKeys: Array<StreamKey!>!): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#streamKeys()` |   |

### setUpdateTimeMs

```
@CanIgnoreReturnValue
fun setUpdateTimeMs(updateTimeMs: Long): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#updateTimeMs()` |   |

### setUri

```
@CanIgnoreReturnValue
fun setUri(uri: String!): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#uri()` |   |

### setUri

```
@CanIgnoreReturnValue
fun setUri(uri: Uri!): DownloadBuilder!
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#uri()` |   |