# Downloader

# Downloader

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

*** ** * ** ***

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

<br />

```
@UnstableApi
interface Downloader
```

<br />

Known direct subclasses  
[FakeDownloader](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader),[ProgressiveDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/ProgressiveDownloader),[SegmentDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader)  

|---------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| [FakeDownloader](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader)          | A fake[Downloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Downloader). |
| [ProgressiveDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/ProgressiveDownloader) | A downloader for progressive media streams.                                                                      |
| [SegmentDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/SegmentDownloader)         | Base class for multi segment stream downloaders.                                                                 |

Known indirect subclasses  
[DashDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/offline/DashDownloader),[HlsDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/offline/HlsDownloader),[SsDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader)  

|-------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [DashDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/offline/DashDownloader)        | A downloader for DASH streams.            |
| [HlsDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/offline/HlsDownloader)           | A downloader for HLS streams.             |
| [SsDownloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader) | A downloader for SmoothStreaming streams. |

*** ** * ** ***

Downloads and removes a piece of content.

## Summary

|                                                                                               ### Nested types                                                                                                |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `interface `[Downloader.ProgressListener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Downloader.ProgressListener) Receives progress updates during download operations. |

|                             ### 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/Downloader#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/Downloader#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/Downloader#remove())`()` Removes the content.                                                                                                                                                                                                                                    |

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