# ProgressiveDownloader

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

*** ** * ** ***


```
@UnstableApi
public final class ProgressiveDownloader implements Downloader
```

<br />

*** ** * ** ***

A downloader for progressive media streams.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/ProgressiveDownloader#ProgressiveDownloader(androidx.media3.common.MediaItem,androidx.media3.datasource.cache.CacheDataSource.Factory)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory cacheDataSourceFactory )` Creates a new instance. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/ProgressiveDownloader#ProgressiveDownloader(androidx.media3.common.MediaItem,androidx.media3.datasource.cache.CacheDataSource.Factory,java.util.concurrent.Executor)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory cacheDataSourceFactory, https://developer.android.com/reference/java/util/concurrent/Executor.html executor )` Creates a new instance. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/ProgressiveDownloader#ProgressiveDownloader(androidx.media3.common.MediaItem,androidx.media3.datasource.cache.CacheDataSource.Factory,long,long)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory cacheDataSourceFactory, long position, long length )` Creates a new instance. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/ProgressiveDownloader#ProgressiveDownloader(androidx.media3.common.MediaItem,androidx.media3.datasource.cache.CacheDataSource.Factory,java.util.concurrent.Executor,long,long)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory cacheDataSourceFactory, https://developer.android.com/reference/java/util/concurrent/Executor.html executor, long position, long length )` Creates a new instance. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/ProgressiveDownloader#cancel()()` Permanently cancels the downloading by this downloader. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/ProgressiveDownloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/offline/Downloader.ProgressListener progressListener)` Downloads the content. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/ProgressiveDownloader#remove()()` Removes the content. |

## Public constructors

### ProgressiveDownloader

```
public ProgressiveDownloader(
    MediaItem mediaItem,
    CacheDataSource.Factory cacheDataSourceFactory
)
```

Creates a new instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The media item with a uri to the stream to be downloaded. |
| `https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory cacheDataSourceFactory` | A `https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory` for the cache into which the download will be written. |

### ProgressiveDownloader

```
public ProgressiveDownloader(
    MediaItem mediaItem,
    CacheDataSource.Factory cacheDataSourceFactory,
    Executor executor
)
```

Creates a new instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The media item with a uri to the stream to be downloaded. |
| `https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory cacheDataSourceFactory` | A `https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory` for the cache into which the download will be written. |
| `https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | An `https://developer.android.com/reference/java/util/concurrent/Executor.html` used to make requests for the media being downloaded. In the future, providing an `https://developer.android.com/reference/java/util/concurrent/Executor.html` that uses multiple threads may speed up the download by allowing parts of it to be executed in parallel. |

### ProgressiveDownloader

```
public ProgressiveDownloader(
    MediaItem mediaItem,
    CacheDataSource.Factory cacheDataSourceFactory,
    long position,
    long length
)
```

Creates a new instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The media item with a uri to the stream to be downloaded. |
| `https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory cacheDataSourceFactory` | A `https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory` for the cache into which the download will be written. |
| `long position` | The position of the `https://developer.android.com/reference/androidx/media3/datasource/DataSpec` from which the `https://developer.android.com/reference/androidx/media3/exoplayer/offline/ProgressiveDownloader` downloads. |
| `long length` | The length of the `https://developer.android.com/reference/androidx/media3/datasource/DataSpec` for which the `https://developer.android.com/reference/androidx/media3/exoplayer/offline/ProgressiveDownloader` downloads. |

### ProgressiveDownloader

```
public ProgressiveDownloader(
    MediaItem mediaItem,
    CacheDataSource.Factory cacheDataSourceFactory,
    Executor executor,
    long position,
    long length
)
```

Creates a new instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The media item with a uri to the stream to be downloaded. |
| `https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory cacheDataSourceFactory` | A `https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory` for the cache into which the download will be written. |
| `https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | An `https://developer.android.com/reference/java/util/concurrent/Executor.html` used to make requests for the media being downloaded. In the future, providing an `https://developer.android.com/reference/java/util/concurrent/Executor.html` that uses multiple threads may speed up the download by allowing parts of it to be executed in parallel. |
| `long position` | The position of the `https://developer.android.com/reference/androidx/media3/datasource/DataSpec` from which the `https://developer.android.com/reference/androidx/media3/exoplayer/offline/ProgressiveDownloader` downloads. |
| `long length` | The length of the `https://developer.android.com/reference/androidx/media3/datasource/DataSpec` for which the `https://developer.android.com/reference/androidx/media3/exoplayer/offline/ProgressiveDownloader` downloads. |

## Public methods

### cancel

```
public void cancel()
```

Permanently cancels the downloading by this downloader. The caller should also interrupt the downloading thread immediately after calling this method.

Once canceled, `https://developer.android.com/reference/androidx/media3/exoplayer/offline/Downloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener)` cannot be called again.

### download

```
public void download(@Nullable Downloader.ProgressListener progressListener)
```

Downloads the content.

If downloading fails, this method can be called again to resume the download. It cannot be called again after the download has been `https://developer.android.com/reference/androidx/media3/exoplayer/offline/Downloader#cancel()`.

If downloading is canceled whilst this method is executing, then it is expected that it will return reasonably quickly. However, there are no guarantees about how the method will return, meaning that it can return without throwing, or by throwing any of its documented exceptions. The caller must use its own knowledge about whether downloading has been canceled to determine whether this is why the method has returned, rather than relying on the method returning in a particular way.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/offline/Downloader.ProgressListener progressListener` | A listener to receive progress updates, or `null`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If the download failed to complete successfully. |
| `https://developer.android.com/reference/java/lang/InterruptedException.html` | If the download was interrupted. |
| `https://developer.android.com/reference/java/util/concurrent/CancellationException.html` | If the download was canceled. |

### remove

```
public void remove()
```

Removes the content.