Package com.google.android.exoplayer2.offline

## Class DownloadRequest

- java.lang.Object
- - com.google.android.exoplayer2.offline.DownloadRequest

- All Implemented Interfaces:
    `Parcelable`

      public final class DownloadRequest
      extends Object
      implements Parcelable

  Defines content to be downloaded.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `DownloadRequest.Builder` | A builder for download requests.
    `static class` | `DownloadRequest.UnsupportedRequestException` | Thrown when the encoded request data belongs to an unsupported request type.

    - ### Nested classes/interfaces inherited from interface android.os.Parcelable

      `Parcelable.ClassLoaderCreator<T extends Object>, Parcelable.Creator<T extends Object>`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static Parcelable.Creator<DownloadRequest>` | `CREATOR` |
    `String` | `customCacheKey` | Custom key for cache indexing, or null.
    `byte[]` | `data` | Application defined data associated with the download.
    `String` | `id` | The unique content id.
    `byte[]` | `keySetId` | The key set id of the offline licence if the content is protected with DRM.
    `String` | `mimeType` | The MIME type of this content.
    `List<StreamKey>` | `streamKeys` | Stream keys to be downloaded.
    `Uri` | `uri` | The uri being downloaded.

    - ### Fields inherited from interface android.os.Parcelable

      `CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `DownloadRequest` | `copyWithId​(String id)` | Returns a copy with the specified ID.
    `DownloadRequest` | `copyWithKeySetId​(byte[] keySetId)` | Returns a copy with the specified key set ID.
    `DownloadRequest` | `copyWithMergedRequest​(DownloadRequest newRequest)` | Returns the result of merging `newRequest` into this request.
    `int` | `describeContents()` |
    `boolean` | `equals​(Object o)` |
    `int` | `hashCode()` |
    `MediaItem` | `toMediaItem()` | Returns a `MediaItem` for the content defined by the request.
    `String` | `toString()` |
    `void` | `writeToParcel​(Parcel dest, int flags)` |

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### id

          public final String id

      The unique content id.

    - #### uri

          public final Uri uri

      The uri being downloaded.

    - #### mimeType

          @Nullable
          public final 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 `uri`.

    - #### streamKeys

          public final List<StreamKey> streamKeys

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

    - #### keySetId

          @Nullable
          public final byte[] keySetId

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

    - #### customCacheKey

          @Nullable
          public final 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.

    - #### CREATOR

          public static final Parcelable.Creator<DownloadRequest> CREATOR

  - ### Method Detail

    - #### copyWithId

          public DownloadRequest copyWithId​(String id)

      Returns a copy with the specified ID.
      Parameters:
        `id` - The ID of the copy.
      Returns:
        The copy with the specified ID.

    - #### copyWithKeySetId

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

      Returns a copy with the specified key set ID.
      Parameters:
        `keySetId` - The key set ID of the copy.
      Returns:
        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 `id`.

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

      Parameters:
        `newRequest` - The request being merged.
      Returns:
        The merged result.
      Throws:
        `IllegalArgumentException` - If the requests do not have the same `id`.

    - #### toMediaItem

          public MediaItem toMediaItem()

      Returns a `MediaItem` for the content defined by the request.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals​(@Nullable
                                Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public final int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### describeContents

          public int describeContents()

      Specified by:
        `describeContents` in interface `Parcelable`

    - #### writeToParcel

          public void writeToParcel​(Parcel dest,
                                    int flags)

      Specified by:
        `writeToParcel` in interface `Parcelable`