# DownloadHelper

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

*** ** * ** ***

<br />

```
@UnstableApi
class DownloadHelper
```

<br />

*** ** * ** ***

A helper for initializing and removing downloads.

The helper extracts track information from the media, selects tracks for downloading, and creates `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest` based on the selected tracks.

A typical usage of DownloadHelper follows these steps:

1. Build the helper using a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory` instance.
2. Prepare the helper using `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#prepare(androidx.media3.exoplayer.offline.DownloadHelper.Callback)` and wait for the callback.
3. Optional: Inspect the selected tracks using `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getMappedTrackInfo(int)` and `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getTrackSelections(int,int)`, and make adjustments using `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#clearTrackSelections(int)`, `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#replaceTrackSelections(int,androidx.media3.common.TrackSelectionParameters)` and `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#addTrackSelection(int,androidx.media3.common.TrackSelectionParameters)`.
4. Create a download request for the selected track using `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getDownloadRequest(byte[])`.
5. Release the helper using `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#release()`.

## Summary

| ### Nested types |
|---|
| `interface https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback` A callback to be notified when the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper` is prepared. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory` A factory of `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper`. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.LiveContentUnsupportedException : https://developer.android.com/reference/java/io/IOException.html` Thrown at an attempt to download live content. |

| ### Constants |
|---|---|
| `const https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.Parameters!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#DEFAULT_TRACK_SELECTOR_PARAMETERS()` Default track selection parameters for downloading. |
| `const https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.Parameters!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#DEFAULT_TRACK_SELECTOR_PARAMETERS_WITHOUT_CONTEXT()` **This property is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#DEFAULT_TRACK_SELECTOR_PARAMETERS()` instead. <br /> |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#DownloadHelper(androidx.media3.common.MediaItem,androidx.media3.exoplayer.source.MediaSource,androidx.media3.common.TrackSelectionParameters,androidx.media3.exoplayer.RendererCapabilitiesList)( mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, mediaSource: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource?, trackSelectionParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters!, rendererCapabilities: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/RendererCapabilitiesList! )` Creates download helper. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#DownloadHelper(androidx.media3.common.MediaItem,androidx.media3.exoplayer.source.MediaSource,androidx.media3.common.TrackSelectionParameters,androidx.media3.exoplayer.RendererCapabilitiesList,boolean)( mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, mediaSource: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource?, trackSelectionParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters!, rendererCapabilities: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/RendererCapabilitiesList!, debugLoggingEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Creates download helper. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#addAudioLanguagesToSelection(java.lang.String...)(languages: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!)` Convenience method to add selections of tracks for all specified audio languages. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#addTextLanguagesToSelection(boolean,java.lang.String...)( selectUndeterminedTextLanguage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, languages: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>! )` Convenience method to add selections of tracks for all specified text languages. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#addTrackSelection(int,androidx.media3.common.TrackSelectionParameters)( periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, trackSelectionParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters! )` Adds a selection of tracks to be downloaded. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#addTrackSelectionForSingleRenderer(int,int,androidx.media3.exoplayer.trackselection.DefaultTrackSelector.Parameters,java.util.List<androidx.media3.exoplayer.trackselection.DefaultTrackSelector.SelectionOverride>)( periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, rendererIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, trackSelectorParameters: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.Parameters!, overrides: (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/exoplayer/trackselection/DefaultTrackSelector.SelectionOverride!>! )` Convenience method to add a selection of tracks to be downloaded for a single renderer. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#clearTrackSelections(int)(periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Clears the selection of tracks for a period. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#createMediaSource(androidx.media3.exoplayer.offline.DownloadRequest,androidx.media3.datasource.DataSource.Factory)( downloadRequest: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!, dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory! )` Equivalent to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#createMediaSource(androidx.media3.exoplayer.offline.DownloadRequest,androidx.media3.datasource.DataSource.Factory,androidx.media3.exoplayer.drm.DrmSessionManager)`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#createMediaSource(androidx.media3.exoplayer.offline.DownloadRequest,androidx.media3.datasource.DataSource.Factory,androidx.media3.exoplayer.drm.DrmSessionManager)( downloadRequest: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!, dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory!, drmSessionManager: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionManager? )` Utility method to create a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource` that only exposes the tracks defined in ` downloadRequest`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper!` | `[forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(android.content.Context,androidx.media3.common.MediaItem))(context: https://developer.android.com/reference/android/content/Context.html!, mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper!` | `[forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(android.content.Context,androidx.media3.common.MediaItem,androidx.media3.datasource.DataSource.Factory))( context: https://developer.android.com/reference/android/content/Context.html!, mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory! )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper!` | `[forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(android.content.Context,androidx.media3.common.MediaItem,androidx.media3.datasource.DataSource.Factory,boolean))( context: https://developer.android.com/reference/android/content/Context.html!, mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory!, debugLoggingEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper!` | `[forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(android.content.Context,androidx.media3.common.MediaItem,androidx.media3.exoplayer.RenderersFactory,androidx.media3.datasource.DataSource.Factory))( context: https://developer.android.com/reference/android/content/Context.html!, mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, renderersFactory: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/RenderersFactory?, dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory? )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper!` | `[forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(androidx.media3.common.MediaItem,androidx.media3.common.TrackSelectionParameters,androidx.media3.exoplayer.RenderersFactory,androidx.media3.datasource.DataSource.Factory))( mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, trackSelectionParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters!, renderersFactory: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/RenderersFactory?, dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory? )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper!` | `[forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(android.content.Context,androidx.media3.common.MediaItem,androidx.media3.exoplayer.RenderersFactory,androidx.media3.datasource.DataSource.Factory,boolean))( context: https://developer.android.com/reference/android/content/Context.html!, mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, renderersFactory: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/RenderersFactory?, dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory?, debugLoggingEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper!` | `[forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(androidx.media3.common.MediaItem,androidx.media3.common.TrackSelectionParameters,androidx.media3.exoplayer.RenderersFactory,androidx.media3.datasource.DataSource.Factory,boolean))( mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, trackSelectionParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters!, renderersFactory: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/RenderersFactory?, dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory?, debugLoggingEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper!` | `[forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(androidx.media3.common.MediaItem,androidx.media3.common.TrackSelectionParameters,androidx.media3.exoplayer.RenderersFactory,androidx.media3.datasource.DataSource.Factory,androidx.media3.exoplayer.drm.DrmSessionManager))( mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, trackSelectionParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters!, renderersFactory: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/RenderersFactory?, dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory?, drmSessionManager: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionManager? )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper!` | `[forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(androidx.media3.common.MediaItem,androidx.media3.common.TrackSelectionParameters,androidx.media3.exoplayer.RenderersFactory,androidx.media3.datasource.DataSource.Factory,androidx.media3.exoplayer.drm.DrmSessionManager,boolean))( mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, trackSelectionParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters!, renderersFactory: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/RenderersFactory?, dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory?, drmSessionManager: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionManager?, debugLoggingEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.Parameters!` | `[getDefaultTrackSelectorParameters](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getDefaultTrackSelectorParameters(android.content.Context))(context: https://developer.android.com/reference/android/content/Context.html!)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#DEFAULT_TRACK_SELECTOR_PARAMETERS()` instead. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getDownloadRequest(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>?)` Builds a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest` for downloading the selected tracks. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getDownloadRequest(java.lang.String,byte[])(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?)` Builds a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest` for downloading the selected tracks. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getDownloadRequest(byte[],long,long)( data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?, startPositionMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, durationMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Builds a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest` for downloading the selected tracks and time range. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getDownloadRequest(java.lang.String,byte[],long,long)( id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?, startPositionMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, durationMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Builds a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest` for downloading the selected tracks and time range. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getManifest()()` Returns the manifest, or null if no manifest is loaded. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/MappingTrackSelector.MappedTrackInfo!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getMappedTrackInfo(int)(periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the mapped track info for the given period. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getPeriodCount()()` Returns the number of periods for which media is available. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/TrackGroupArray!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getTrackGroups(int)(periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the track groups for the given period. |
| `(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/exoplayer/trackselection/ExoTrackSelection!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getTrackSelections(int,int)(periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, rendererIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns all `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection` for a period and renderer. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Tracks!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getTracks(int)(periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns `https://developer.android.com/reference/kotlin/androidx/media3/common/Tracks` for the given period. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#prepare(androidx.media3.exoplayer.offline.DownloadHelper.Callback)(callback: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback!)` Initializes the helper for starting a download. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#release()()` Releases the helper and all resources it is holding. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#replaceTrackSelections(int,androidx.media3.common.TrackSelectionParameters)( periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, trackSelectionParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters! )` Replaces a selection of tracks to be downloaded. |

## Constants

### DEFAULT_TRACK_SELECTOR_PARAMETERS

```
const val DEFAULT_TRACK_SELECTOR_PARAMETERS: DefaultTrackSelector.Parameters!
```

Default track selection parameters for downloading.

### DEFAULT_TRACK_SELECTOR_PARAMETERS_WITHOUT_CONTEXT

```
const val DEFAULT_TRACK_SELECTOR_PARAMETERS_WITHOUT_CONTEXT: DefaultTrackSelector.Parameters!
```

> [!CAUTION]
> **This property is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#DEFAULT_TRACK_SELECTOR_PARAMETERS()` instead.

## Public constructors

### DownloadHelper

```
DownloadHelper(
    mediaItem: MediaItem!,
    mediaSource: MediaSource?,
    trackSelectionParameters: TrackSelectionParameters!,
    rendererCapabilities: RendererCapabilitiesList!
)
```

Creates download helper.

| Parameters |
|---|---|
| `mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!` | The media item. |
| `mediaSource: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource?` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource` for which tracks are selected, or null if no track selection needs to be made. |
| `trackSelectionParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters` for selecting tracks for downloading. |
| `rendererCapabilities: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/RendererCapabilitiesList!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/RendererCapabilitiesList` of the renderers for which tracks are selected. |

### DownloadHelper

```
DownloadHelper(
    mediaItem: MediaItem!,
    mediaSource: MediaSource?,
    trackSelectionParameters: TrackSelectionParameters!,
    rendererCapabilities: RendererCapabilitiesList!,
    debugLoggingEnabled: Boolean
)
```

Creates download helper.

| Parameters |
|---|---|
| `mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!` | The media item. |
| `mediaSource: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource?` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource` to be prepared, or null if no preparation needs to be done. |
| `trackSelectionParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters` for selecting tracks for downloading. |
| `rendererCapabilities: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/RendererCapabilitiesList!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/RendererCapabilitiesList` of the renderers for which tracks are selected. |
| `debugLoggingEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to log debug information. |

## Public functions

### addAudioLanguagesToSelection

```
fun addAudioLanguagesToSelection(languages: Array<String!>!): Unit
```

Convenience method to add selections of tracks for all specified audio languages. If an audio track in one of the specified languages is not available, the default fallback audio track is used instead. Must not be called until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback#onPrepared(androidx.media3.exoplayer.offline.DownloadHelper,boolean)` is triggered and the passed `tracksInfoAvailable` is `true`.

| Parameters |
|---|---|
| `languages: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | A list of audio languages for which tracks should be added to the download selection, as IETF BCP 47 conformant tags. |

### addTextLanguagesToSelection

```
fun addTextLanguagesToSelection(
    selectUndeterminedTextLanguage: Boolean,
    languages: Array<String!>!
): Unit
```

Convenience method to add selections of tracks for all specified text languages. Must not be called until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback#onPrepared(androidx.media3.exoplayer.offline.DownloadHelper,boolean)` is triggered and the passed `tracksInfoAvailable` is `true`.

| Parameters |
|---|---|
| `selectUndeterminedTextLanguage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether a text track with undetermined language should be selected for downloading if no track with one of the specified `languages` is available. |
| `languages: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | A list of text languages for which tracks should be added to the download selection, as IETF BCP 47 conformant tags. |

### addTrackSelection

```
fun addTrackSelection(
    periodIndex: Int,
    trackSelectionParameters: TrackSelectionParameters!
): Unit
```

Adds a selection of tracks to be downloaded. Must not be called until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback#onPrepared(androidx.media3.exoplayer.offline.DownloadHelper,boolean)` is triggered and the passed ` tracksInfoAvailable` is `true`.

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The period index this track selection is added for. |
| `trackSelectionParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters` to obtain the new selection of tracks. |

### addTrackSelectionForSingleRenderer

```
fun addTrackSelectionForSingleRenderer(
    periodIndex: Int,
    rendererIndex: Int,
    trackSelectorParameters: DefaultTrackSelector.Parameters!,
    overrides: (Mutable)List<DefaultTrackSelector.SelectionOverride!>!
): Unit
```

Convenience method to add a selection of tracks to be downloaded for a single renderer. Must not be called until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback#onPrepared(androidx.media3.exoplayer.offline.DownloadHelper,boolean)` is triggered and the passed `tracksInfoAvailable` is `true`.

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The period index the track selection is added for. |
| `rendererIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The renderer index the track selection is added for. |
| `trackSelectorParameters: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.Parameters!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.Parameters` to obtain the new selection of tracks. |
| `overrides: (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/exoplayer/trackselection/DefaultTrackSelector.SelectionOverride!>!` | A list of `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.SelectionOverride` to apply to the ` trackSelectorParameters`. If empty, `trackSelectorParameters` are used as they are. |

### clearTrackSelections

```
fun clearTrackSelections(periodIndex: Int): Unit
```

Clears the selection of tracks for a period. Must not be called until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback#onPrepared(androidx.media3.exoplayer.offline.DownloadHelper,boolean)` is triggered and the passed ` tracksInfoAvailable` is `true`.

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The period index for which track selections are cleared. |

### createMediaSource

```
java-static fun createMediaSource(
    downloadRequest: DownloadRequest!,
    dataSourceFactory: DataSource.Factory!
): MediaSource!
```

Equivalent to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#createMediaSource(androidx.media3.exoplayer.offline.DownloadRequest,androidx.media3.datasource.DataSource.Factory,androidx.media3.exoplayer.drm.DrmSessionManager)`.

### createMediaSource

```
java-static fun createMediaSource(
    downloadRequest: DownloadRequest!,
    dataSourceFactory: DataSource.Factory!,
    drmSessionManager: DrmSessionManager?
): MediaSource!
```

Utility method to create a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource` that only exposes the tracks defined in ` downloadRequest`.

| Parameters |
|---|---|
| `downloadRequest: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest!` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest`. |
| `dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory!` | A factory for `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource`s to read the media. |
| `drmSessionManager: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionManager?` | An optional `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionManager` to be passed to the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource` that only exposes the tracks defined in `downloadRequest`. |

### forMediaItem

```
java-static fun [forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(android.content.Context,androidx.media3.common.MediaItem))(context: Context!, mediaItem: MediaItem!): DownloadHelper!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead.

### forMediaItem

```
java-static fun [forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(android.content.Context,androidx.media3.common.MediaItem,androidx.media3.datasource.DataSource.Factory))(
    context: Context!,
    mediaItem: MediaItem!,
    dataSourceFactory: DataSource.Factory!
): DownloadHelper!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead.

### forMediaItem

```
java-static fun [forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(android.content.Context,androidx.media3.common.MediaItem,androidx.media3.datasource.DataSource.Factory,boolean))(
    context: Context!,
    mediaItem: MediaItem!,
    dataSourceFactory: DataSource.Factory!,
    debugLoggingEnabled: Boolean
): DownloadHelper!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead.

### forMediaItem

```
java-static fun [forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(android.content.Context,androidx.media3.common.MediaItem,androidx.media3.exoplayer.RenderersFactory,androidx.media3.datasource.DataSource.Factory))(
    context: Context!,
    mediaItem: MediaItem!,
    renderersFactory: RenderersFactory?,
    dataSourceFactory: DataSource.Factory?
): DownloadHelper!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead.

### forMediaItem

```
java-static fun [forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(androidx.media3.common.MediaItem,androidx.media3.common.TrackSelectionParameters,androidx.media3.exoplayer.RenderersFactory,androidx.media3.datasource.DataSource.Factory))(
    mediaItem: MediaItem!,
    trackSelectionParameters: TrackSelectionParameters!,
    renderersFactory: RenderersFactory?,
    dataSourceFactory: DataSource.Factory?
): DownloadHelper!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead.

### forMediaItem

```
java-static fun [forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(android.content.Context,androidx.media3.common.MediaItem,androidx.media3.exoplayer.RenderersFactory,androidx.media3.datasource.DataSource.Factory,boolean))(
    context: Context!,
    mediaItem: MediaItem!,
    renderersFactory: RenderersFactory?,
    dataSourceFactory: DataSource.Factory?,
    debugLoggingEnabled: Boolean
): DownloadHelper!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead.

### forMediaItem

```
java-static fun [forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(androidx.media3.common.MediaItem,androidx.media3.common.TrackSelectionParameters,androidx.media3.exoplayer.RenderersFactory,androidx.media3.datasource.DataSource.Factory,boolean))(
    mediaItem: MediaItem!,
    trackSelectionParameters: TrackSelectionParameters!,
    renderersFactory: RenderersFactory?,
    dataSourceFactory: DataSource.Factory?,
    debugLoggingEnabled: Boolean
): DownloadHelper!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead.

### forMediaItem

```
java-static fun [forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(androidx.media3.common.MediaItem,androidx.media3.common.TrackSelectionParameters,androidx.media3.exoplayer.RenderersFactory,androidx.media3.datasource.DataSource.Factory,androidx.media3.exoplayer.drm.DrmSessionManager))(
    mediaItem: MediaItem!,
    trackSelectionParameters: TrackSelectionParameters!,
    renderersFactory: RenderersFactory?,
    dataSourceFactory: DataSource.Factory?,
    drmSessionManager: DrmSessionManager?
): DownloadHelper!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead.

### forMediaItem

```
java-static fun [forMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#forMediaItem(androidx.media3.common.MediaItem,androidx.media3.common.TrackSelectionParameters,androidx.media3.exoplayer.RenderersFactory,androidx.media3.datasource.DataSource.Factory,androidx.media3.exoplayer.drm.DrmSessionManager,boolean))(
    mediaItem: MediaItem!,
    trackSelectionParameters: TrackSelectionParameters!,
    renderersFactory: RenderersFactory?,
    dataSourceFactory: DataSource.Factory?,
    drmSessionManager: DrmSessionManager?,
    debugLoggingEnabled: Boolean
): DownloadHelper!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Factory#create(androidx.media3.common.MediaItem)` instead.

### getDefaultTrackSelectorParameters

```
java-static fun [getDefaultTrackSelectorParameters](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getDefaultTrackSelectorParameters(android.content.Context))(context: Context!): DefaultTrackSelector.Parameters!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#DEFAULT_TRACK_SELECTOR_PARAMETERS()` instead.

### getDownloadRequest

```
fun getDownloadRequest(data: ByteArray<Byte>?): DownloadRequest!
```

Builds a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest` for downloading the selected tracks. Must not be called until after preparation completes. The uri of the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest` will be used as content id.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | Application provided data to store in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#data()`. |

### getDownloadRequest

```
fun getDownloadRequest(id: String!, data: ByteArray<Byte>?): DownloadRequest!
```

Builds a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest` for downloading the selected tracks. Must not be called until after preparation completes.

| Parameters |
|---|---|
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The unique content id. |
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | Application provided data to store in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#data()`. |

### getDownloadRequest

```
fun getDownloadRequest(
    data: ByteArray<Byte>?,
    startPositionMs: Long,
    durationMs: Long
): DownloadRequest!
```

Builds a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest` for downloading the selected tracks and time range. Must not be called until preparation completes.

This method is only supported for progressive streams.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | Application provided data to store in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#data()`. |
| `startPositionMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The start position (in milliseconds) of the media that download should cover from, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if the download should cover from the default start position. |
| `durationMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The end position (in milliseconds) of the media that download should cover to, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if the download should cover to the end of the media. If the `endPositionMs` is larger than the duration of the media, then the download will cover to the end of the media. |

### getDownloadRequest

```
fun getDownloadRequest(
    id: String!,
    data: ByteArray<Byte>?,
    startPositionMs: Long,
    durationMs: Long
): DownloadRequest!
```

Builds a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest` for downloading the selected tracks and time range. Must not be called until preparation completes.

This method is only supported for progressive streams.

| Parameters |
|---|---|
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The unique content id. |
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | Application provided data to store in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest#data()`. |
| `startPositionMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The start position (in milliseconds) of the media that download should cover from, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if the download should cover from the default start position. |
| `durationMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The duration (in milliseconds) of the media that download should cover, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if the download should cover to the end of the media. If the end position resolved from `startPositionMs` and `durationMs` is beyond the duration of the media, then the download will just cover to the end of the media. |

### getManifest

```
fun getManifest(): Any?
```

Returns the manifest, or null if no manifest is loaded. Must not be called until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback#onPrepared(androidx.media3.exoplayer.offline.DownloadHelper,boolean)` is triggered.

### getMappedTrackInfo

```
fun getMappedTrackInfo(periodIndex: Int): MappingTrackSelector.MappedTrackInfo!
```

Returns the mapped track info for the given period. Must not be called until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback#onPrepared(androidx.media3.exoplayer.offline.DownloadHelper,boolean)` is triggered and the passed ` tracksInfoAvailable` is `true`.

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The period index. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/MappingTrackSelector.MappedTrackInfo!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/MappingTrackSelector.MappedTrackInfo` for the period. |

### getPeriodCount

```
fun getPeriodCount(): Int
```

Returns the number of periods for which media is available. Must not be called until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback#onPrepared(androidx.media3.exoplayer.offline.DownloadHelper,boolean)` is triggered.

### getTrackGroups

```
fun getTrackGroups(periodIndex: Int): TrackGroupArray!
```

Returns the track groups for the given period. Must not be called until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback#onPrepared(androidx.media3.exoplayer.offline.DownloadHelper,boolean)` is triggered and the passed ` tracksInfoAvailable` is `true`.

Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper#getMappedTrackInfo(int)` to get the track groups mapped to renderers.

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The period index. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/TrackGroupArray!` | The track groups for the period. May be `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/TrackGroupArray#EMPTY()` for single stream content. |

### getTrackSelections

```
fun getTrackSelections(periodIndex: Int, rendererIndex: Int): (Mutable)List<ExoTrackSelection!>!
```

Returns all `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection` for a period and renderer. Must not be called until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback#onPrepared(androidx.media3.exoplayer.offline.DownloadHelper,boolean)` is triggered and the passed `tracksInfoAvailable` is `true`.

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The period index. |
| `rendererIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The renderer index. |

| Returns |
|---|---|
| `(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/exoplayer/trackselection/ExoTrackSelection!>!` | A list of selected `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection`. |

### getTracks

```
fun getTracks(periodIndex: Int): Tracks!
```

Returns `https://developer.android.com/reference/kotlin/androidx/media3/common/Tracks` for the given period. Must not be called until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback#onPrepared(androidx.media3.exoplayer.offline.DownloadHelper,boolean)` is triggered and the passed ` tracksInfoAvailable` is `true`.

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The period index. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Tracks!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Tracks` for the period. May be `https://developer.android.com/reference/kotlin/androidx/media3/common/Tracks#EMPTY()` for single stream content. |

### prepare

```
fun prepare(callback: DownloadHelper.Callback!): Unit
```

Initializes the helper for starting a download.

| Parameters |
|---|---|
| `callback: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback!` | A callback to be notified when preparation completes or fails. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If the download helper has already been prepared. |

### release

```
fun release(): Unit
```

Releases the helper and all resources it is holding.

### replaceTrackSelections

```
fun replaceTrackSelections(
    periodIndex: Int,
    trackSelectionParameters: TrackSelectionParameters!
): Unit
```

Replaces a selection of tracks to be downloaded. Must not be called until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadHelper.Callback#onPrepared(androidx.media3.exoplayer.offline.DownloadHelper,boolean)` is triggered and the passed ` tracksInfoAvailable` is `true`.

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The period index for which the track selection is replaced. |
| `trackSelectionParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackSelectionParameters` to obtain the new selection of tracks. |