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

*** ** * ** ***


```
class DownloadRequest.Builder
```

<br />

*** ** * ** ***

A builder for download requests.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder#Builder(java.lang.String,android.net.Uri)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, uri: https://developer.android.com/reference/android/net/Uri.html!)` Creates a new instance with the specified id and uri. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder#build()()` |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder#setByteRange(long,long)(offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the byte range to be downloaded. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder#setCustomCacheKey(java.lang.String)(customCacheKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#customCacheKey()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder#setData(byte[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?)` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#data()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder#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>?)` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#keySetId()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder#setMimeType(java.lang.String)(mimeType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#mimeType()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder#setStreamKeys(java.util.List<androidx.media3.common.StreamKey>)(streamKeys: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey!>?)` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#streamKeys()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder#setTimeRange(long,long)(startPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, durationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the time range to be downloaded. |

## Public constructors

### Builder

```
Builder(id: String!, uri: Uri!)
```

Creates a new instance with the specified id and uri.

## Public functions

### build

```
fun build(): DownloadRequest!
```

### setByteRange

```
@CanIgnoreReturnValue
fun setByteRange(offset: Long, length: Long): DownloadRequest.Builder!
```

Sets the byte range to be downloaded.

This will be ignored for DASH, HLS and SmoothStreaming downloads.

| Parameters |
|---|---|
| `offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The offset that the download should start from. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The length from the `offset` to be downloaded, or @link C#LENGTH_UNSET} if the media should be downloaded to the end. |

### setCustomCacheKey

```
@CanIgnoreReturnValue
fun setCustomCacheKey(customCacheKey: String?): DownloadRequest.Builder!
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#customCacheKey()`.

### setData

```
@CanIgnoreReturnValue
fun setData(data: ByteArray<Byte>?): DownloadRequest.Builder!
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#data()`.

### setKeySetId

```
@CanIgnoreReturnValue
fun setKeySetId(keySetId: ByteArray<Byte>?): DownloadRequest.Builder!
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#keySetId()`.

### setMimeType

```
@CanIgnoreReturnValue
fun setMimeType(mimeType: String?): DownloadRequest.Builder!
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#mimeType()`.

### setStreamKeys

```
@CanIgnoreReturnValue
fun setStreamKeys(streamKeys: (Mutable)List<StreamKey!>?): DownloadRequest.Builder!
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#streamKeys()`.

### setTimeRange

```
@CanIgnoreReturnValue
fun setTimeRange(startPositionUs: Long, durationUs: Long): DownloadRequest.Builder!
```

Sets the time range to be downloaded.

This will be ignored progressive downloads.

| Parameters |
|---|---|
| `startPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The start position in microseconds that the download should start from. |
| `durationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The duration in microseconds from the `startPositionUs` to be downloaded, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if the media should be downloaded to the end. |