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

*** ** * ** ***


```
@UnstableApi
public final class DownloadRequest implements Parcelable
```

<br />

*** ** * ** ***

Defines content to be downloaded.

## Summary

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

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

| ### Public fields |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest.ByteRange` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#byteRange()` The byte range to be downloaded. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#customCacheKey()` Custom key for cache indexing, or null. |
| `final byte[]` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#data()` Application defined data associated with the download. |
| `final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#id()` The unique content id. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable byte[]` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#keySetId()` The key set id of the offline licence if the content is protected with DRM. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#mimeType()` The MIME type of this content. |
| `final https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/StreamKey>` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#streamKeys()` Stream keys to be downloaded. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest.TimeRange` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#timeRange()` The time range to be downloaded. |
| `final https://developer.android.com/reference/android/net/Uri.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#uri()` The uri being downloaded. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#copyWithId(java.lang.String)(https://developer.android.com/reference/java/lang/String.html id)` Returns a copy with the specified ID. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#copyWithKeySetId(byte[])(@https://developer.android.com/reference/androidx/annotation/Nullable byte[] keySetId)` Returns a copy with the specified key set ID. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#copyWithMergedRequest(androidx.media3.exoplayer.offline.DownloadRequest)(https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest newRequest)` Returns the result of merging `newRequest` into this request. |
| `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#describeContents()()` |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html o)` |
| `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#hashCode()()` |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#toMediaItem()()` Returns a `https://developer.android.com/reference/androidx/media3/common/MediaItem` for the content defined by the request. |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#toMediaItem(androidx.media3.common.MediaItem.Builder)(https://developer.android.com/reference/androidx/media3/common/MediaItem.Builder builder)` Propagates the content information defined by the request to the `https://developer.android.com/reference/androidx/media3/common/MediaItem.Builder` and returns a `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#toString()()` |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest#writeToParcel(android.os.Parcel,int)(https://developer.android.com/reference/android/os/Parcel.html dest, int flags)` |

| ### Inherited Constants |
|---|
| From [android.os.Parcelable](https://developer.android.com/reference/android/os/Parcelable.html) |---|---| | `static final int` | `https://developer.android.com/reference/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR = 1` | | `static final int` | `https://developer.android.com/reference/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE = 1` | |

## Constants

### CREATOR

```
public static final Parcelable.Creator<DownloadRequest> CREATOR
```

## Public fields

### byteRange

```
public final @Nullable DownloadRequest.ByteRange byteRange
```

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

### customCacheKey

```
public final @Nullable String customCacheKey
```

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

### data

```
public final byte[] data
```

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

### id

```
public final String id
```

The unique content id.

### keySetId

```
public final @Nullable byte[] keySetId
```

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

### mimeType

```
public final @Nullable String mimeType
```

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/androidx/media3/exoplayer/offline/DownloadRequest#uri()`.

### streamKeys

```
public final List<StreamKey> streamKeys
```

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

### timeRange

```
public final @Nullable DownloadRequest.TimeRange timeRange
```

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

### uri

```
public final Uri uri
```

The uri being downloaded.

## Public methods

### copyWithId

```
public DownloadRequest copyWithId(String id)
```

Returns a copy with the specified ID.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html id` | The ID of the copy. |

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

### copyWithKeySetId

```
public DownloadRequest copyWithKeySetId(@Nullable byte[] keySetId)
```

Returns a copy with the specified key set ID.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable byte[] keySetId` | The key set ID of the copy. |

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

### copyWithMergedRequest

```
public DownloadRequest copyWithMergedRequest(DownloadRequest newRequest)
```

Returns the result of merging `newRequest` into this request. The requests must have the same `https://developer.android.com/reference/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 |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadRequest newRequest` | The request being merged. |

| Returns |
|---|---|
| `https://developer.android.com/reference/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/androidx/media3/exoplayer/offline/DownloadRequest#id()`. |

### describeContents

```
public int describeContents()
```

### equals

```
public boolean equals(@Nullable Object o)
```

### hashCode

```
public int hashCode()
```

### toMediaItem

```
public MediaItem toMediaItem()
```

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

### toMediaItem

```
public MediaItem toMediaItem(MediaItem.Builder builder)
```

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

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

### toString

```
public String toString()
```

### writeToParcel

```
public void writeToParcel(Parcel dest, int flags)
```