# ProgressiveDownloader

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/exoplayer/offline/ProgressiveDownloader "View this page in Java")

<br />

```
@UnstableApi
class ProgressiveDownloader : Downloader
```

<br />

*** ** * ** ***

A downloader for progressive media streams.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                         ### Public constructors                                                                                                                                                                                                                                                                                                                                                                                                                                         |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ProgressiveDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/ProgressiveDownloader#ProgressiveDownloader(androidx.media3.common.MediaItem,androidx.media3.datasource.cache.CacheDataSource.Factory))`(` ` mediaItem: `[MediaItem](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem)`!,` ` cacheDataSourceFactory: `[CacheDataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheDataSource.Factory)`!` `)` Creates a new instance.                                                                                                                                                                                                                                                                                                                                         |
| [ProgressiveDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/ProgressiveDownloader#ProgressiveDownloader(androidx.media3.common.MediaItem,androidx.media3.datasource.cache.CacheDataSource.Factory,java.util.concurrent.Executor))`(` ` mediaItem: `[MediaItem](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem)`!,` ` cacheDataSourceFactory: `[CacheDataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheDataSource.Factory)`!,` ` executor: `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)`!` `)` Creates a new instance.                                                                                                                                                                                                   |
| [ProgressiveDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/ProgressiveDownloader#ProgressiveDownloader(androidx.media3.common.MediaItem,androidx.media3.datasource.cache.CacheDataSource.Factory,long,long))`(` ` mediaItem: `[MediaItem](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem)`!,` ` cacheDataSourceFactory: `[CacheDataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheDataSource.Factory)`!,` ` position: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` length: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) `)` Creates a new instance.                                                                                                                                       |
| [ProgressiveDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/ProgressiveDownloader#ProgressiveDownloader(androidx.media3.common.MediaItem,androidx.media3.datasource.cache.CacheDataSource.Factory,java.util.concurrent.Executor,long,long))`(` ` mediaItem: `[MediaItem](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem)`!,` ` cacheDataSourceFactory: `[CacheDataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheDataSource.Factory)`!,` ` executor: `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)`!,` ` position: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` length: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) `)` Creates a new instance. |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [cancel](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/ProgressiveDownloader#cancel())`()` Permanently cancels the downloading by this downloader.                                                                                                                                                                                                 |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [download](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/ProgressiveDownloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener))`(progressListener: `[Downloader.ProgressListener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Downloader.ProgressListener)`?)` Downloads the content. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [remove](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/ProgressiveDownloader#remove())`()` Removes the content.                                                                                                                                                                                                                                    |

## Public constructors

### ProgressiveDownloader

```
ProgressiveDownloader(
    mediaItem: MediaItem!,
    cacheDataSourceFactory: CacheDataSource.Factory!
)
```

Creates a new instance.  

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

### ProgressiveDownloader

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

Creates a new instance.  

|                                                                           Parameters                                                                            |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `mediaItem: `[MediaItem](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem)`!`                                                    | The media item with a uri to the stream to be downloaded.                                                                                                                                                                                                                                                                                                               |
| `cacheDataSourceFactory: `[CacheDataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheDataSource.Factory)`!` | A[CacheDataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheDataSource.Factory)for the cache into which the download will be written.                                                                                                                                                                               |
| `executor: `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)`!`                                                           | An[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)used to make requests for the media being downloaded. In the future, providing an[Executor](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

```
ProgressiveDownloader(
    mediaItem: MediaItem!,
    cacheDataSourceFactory: CacheDataSource.Factory!,
    position: Long,
    length: Long
)
```

Creates a new instance.  

|                                                                           Parameters                                                                            |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `mediaItem: `[MediaItem](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem)`!`                                                    | The media item with a uri to the stream to be downloaded.                                                                                                                                                                                                                |
| `cacheDataSourceFactory: `[CacheDataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheDataSource.Factory)`!` | A[CacheDataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheDataSource.Factory)for the cache into which the download will be written.                                                                                |
| `position: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                                       | The position of the[DataSpec](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec)from which the[ProgressiveDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/ProgressiveDownloader)downloads. |
| `length: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                                         | The length of the[DataSpec](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec)for which the[ProgressiveDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/ProgressiveDownloader)downloads.    |

### ProgressiveDownloader

```
ProgressiveDownloader(
    mediaItem: MediaItem!,
    cacheDataSourceFactory: CacheDataSource.Factory!,
    executor: Executor!,
    position: Long,
    length: Long
)
```

Creates a new instance.  

|                                                                           Parameters                                                                            |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `mediaItem: `[MediaItem](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem)`!`                                                    | The media item with a uri to the stream to be downloaded.                                                                                                                                                                                                                                                                                                               |
| `cacheDataSourceFactory: `[CacheDataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheDataSource.Factory)`!` | A[CacheDataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheDataSource.Factory)for the cache into which the download will be written.                                                                                                                                                                               |
| `executor: `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)`!`                                                           | An[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)used to make requests for the media being downloaded. In the future, providing an[Executor](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. |
| `position: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                                       | The position of the[DataSpec](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec)from which the[ProgressiveDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/ProgressiveDownloader)downloads.                                                                                                |
| `length: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                                         | The length of the[DataSpec](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec)for which the[ProgressiveDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/ProgressiveDownloader)downloads.                                                                                                   |

## Public functions

### cancel

```
fun cancel(): Unit
```

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

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

### download

```
fun download(progressListener: Downloader.ProgressListener?): Unit
```

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[canceled](https://developer.android.com/reference/kotlin/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                                                                             |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------|
| `progressListener: `[Downloader.ProgressListener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Downloader.ProgressListener)`?` | A listener to receive progress updates, or`null`. |

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

### remove

```
fun remove(): Unit
```

Removes the content.