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

*** ** * ** ***


```
@UnstableApi
public interface Downloader
```

<br />

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

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

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

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

*** ** * ** ***

Downloads and removes a piece of content.

## Summary

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

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/Downloader#cancel()()` Permanently cancels the downloading by this downloader. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/Downloader#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. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/Downloader#remove()()` Removes the content. |

## Public methods

### cancel

```
abstract 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

```
abstract 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

```
abstract void remove()
```

Removes the content.