ProgressiveDownloader
@UnstableApi
public final class ProgressiveDownloader implements Downloader
A downloader for progressive media streams.
Summary
Public constructors |
|---|
ProgressiveDownloader(Creates a new instance. |
ProgressiveDownloader(Creates a new instance. |
ProgressiveDownloader(Creates a new instance. |
ProgressiveDownloader(Creates a new instance. |
Public methods |
|
|---|---|
void |
cancel()Permanently cancels the downloading by this downloader. |
void |
download(@Nullable Downloader.ProgressListener progressListener)Downloads the content. |
void |
remove()Removes the content. |
Public constructors
ProgressiveDownloader
public ProgressiveDownloader(
MediaItem mediaItem,
CacheDataSource.Factory cacheDataSourceFactory
)
Creates a new instance.
| Parameters | |
|---|---|
MediaItem mediaItem |
The media item with a uri to the stream to be downloaded. |
CacheDataSource.Factory cacheDataSourceFactory |
A |
ProgressiveDownloader
public ProgressiveDownloader(
MediaItem mediaItem,
CacheDataSource.Factory cacheDataSourceFactory,
Executor executor
)
Creates a new instance.
| Parameters | |
|---|---|
MediaItem mediaItem |
The media item with a uri to the stream to be downloaded. |
CacheDataSource.Factory cacheDataSourceFactory |
A |
Executor executor |
An |
ProgressiveDownloader
public ProgressiveDownloader(
MediaItem mediaItem,
CacheDataSource.Factory cacheDataSourceFactory,
long position,
long length
)
Creates a new instance.
| Parameters | |
|---|---|
MediaItem mediaItem |
The media item with a uri to the stream to be downloaded. |
CacheDataSource.Factory cacheDataSourceFactory |
A |
long position |
The position of the |
long length |
The length of the |
ProgressiveDownloader
public ProgressiveDownloader(
MediaItem mediaItem,
CacheDataSource.Factory cacheDataSourceFactory,
Executor executor,
long position,
long length
)
Creates a new instance.
| Parameters | |
|---|---|
MediaItem mediaItem |
The media item with a uri to the stream to be downloaded. |
CacheDataSource.Factory cacheDataSourceFactory |
A |
Executor executor |
An |
long position |
The position of the |
long length |
The length of the |
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, download 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 canceled.
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 | |
|---|---|
@Nullable Downloader.ProgressListener progressListener |
A listener to receive progress updates, or |
| Throws | |
|---|---|
java.io.IOException |
If the download failed to complete successfully. |
java.lang.InterruptedException |
If the download was interrupted. |
java.util.concurrent.CancellationException |
If the download was canceled. |