# DownloadRequest

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)

*** ** * ** ***

<br />

```
@UnstableApi
class DownloadRequest : Parcelable
```

<br />

*** ** * ** ***

Defines content to be downloaded.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.Builder` A builder for download requests. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.ByteRange : https://developer.android.com/reference/android/os/Parcelable.html` Defines the byte range. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.TimeRange : https://developer.android.com/reference/android/os/Parcelable.html` Defines the time range. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.UnsupportedRequestException : https://developer.android.com/reference/java/io/IOException.html` Thrown when the encoded request data belongs to an unsupported request type. |

| ### Constants |
|---|---|
| `const https://developer.android.com/reference/android/os/Parcelable.Creator.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#CREATOR()` |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#copyWithId(java.lang.String)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns a copy with the specified ID. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#copyWithKeySetId(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>?)` Returns a copy with the specified key set ID. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#copyWithMergedRequest(androidx.media3.exoplayer.offline.DownloadRequest)(newRequest: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!)` Returns the result of merging `newRequest` into this request. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#describeContents()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#equals(java.lang.Object)(o: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#hashCode()()` |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#toMediaItem()()` Returns a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` for the content defined by the request. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#toMediaItem(androidx.media3.common.MediaItem.Builder)(builder: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.Builder!)` Propagates the content information defined by the request to the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.Builder` and returns a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#toString()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#writeToParcel(android.os.Parcel,int)(dest: https://developer.android.com/reference/android/os/Parcel.html!, flags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.ByteRange?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#byteRange()` The byte range to be downloaded. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#customCacheKey()` Custom key for cache indexing, or null. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#data()` Application defined data associated with the download. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#id()` The unique content id. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#keySetId()` The key set id of the offline licence if the content is protected with DRM. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#mimeType()` The MIME type of this content. |
| `(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!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#streamKeys()` Stream keys to be downloaded. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest.TimeRange?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#timeRange()` The time range to be downloaded. |
| `https://developer.android.com/reference/android/net/Uri.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#uri()` The uri being downloaded. |

### Inherited Constants

From [android.os.Parcelable](https://developer.android.com/reference/android/os/Parcelable.html) `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR = 1` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE = 1`

## Constants

### CREATOR

```
const val CREATOR: Parcelable.Creator<DownloadRequest!>!
```

## Public functions

### copyWithId

```
fun copyWithId(id: String!): DownloadRequest!
```

Returns a copy with the specified ID.

| Parameters |
|---|---|
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The ID of the copy. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | The copy with the specified ID. |

### copyWithKeySetId

```
fun copyWithKeySetId(keySetId: ByteArray<Byte>?): DownloadRequest!
```

Returns a copy with the specified key set ID.

| Parameters |
|---|---|
| `keySetId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | The key set ID of the copy. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | The copy with the specified key set ID. |

### copyWithMergedRequest

```
fun copyWithMergedRequest(newRequest: DownloadRequest!): DownloadRequest!
```

Returns the result of merging `newRequest` into this request. The requests must have the same `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#id()`.

The resulting request contains the stream keys from both requests. For all other member variables, those in `newRequest` are preferred.

| Parameters |
|---|---|
| `newRequest: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | The request being merged. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | The merged result. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the requests do not have the same `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#id()`. |

### describeContents

```
fun describeContents(): Int
```

### equals

```
fun equals(o: Any?): Boolean
```

### hashCode

```
fun hashCode(): Int
```

### toMediaItem

```
fun toMediaItem(): MediaItem!
```

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` for the content defined by the request.

### toMediaItem

```
fun toMediaItem(builder: MediaItem.Builder!): MediaItem!
```

Propagates the content information defined by the request to the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.Builder` and returns a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`.

| Parameters |
|---|---|
| `builder: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.Builder!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.Builder` to be propagated. |

### toString

```
fun toString(): String!
```

### writeToParcel

```
fun writeToParcel(dest: Parcel!, flags: Int): Unit
```

## Public properties

### byteRange

```
val byteRange: DownloadRequest.ByteRange?
```

The byte range to be downloaded. Must be null for DASH, HLS and SmoothStreaming downloads.

### customCacheKey

```
val customCacheKey: String?
```

Custom key for cache indexing, or null. Must be null for DASH, HLS and SmoothStreaming downloads.

### data

```
val data: Array<Byte>!
```

Application defined data associated with the download. May be empty.

### id

```
val id: String!
```

The unique content id.

### keySetId

```
val keySetId: Array<Byte>?
```

The key set id of the offline licence if the content is protected with DRM.

### mimeType

```
val mimeType: String?
```

The MIME type of this content. Used as a hint to infer the content's type (DASH, HLS, SmoothStreaming). If null, a `DownloadService` will infer the content type from the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#uri()`.

### streamKeys

```
val streamKeys: (Mutable)List<StreamKey!>!
```

Stream keys to be downloaded. If empty, all streams will be downloaded.

### timeRange

```
val timeRange: DownloadRequest.TimeRange?
```

The time range to be downloaded. Must be null progressive downloads.

### uri

```
val uri: Uri!
```

The uri being downloaded.