Downloaderpublic final class ProgressiveDownloader extends Object implements Downloader
Downloader.ProgressListener| Constructor | Description |
|---|---|
ProgressiveDownloader(Uri uri,
String customCacheKey,
CacheDataSource.Factory cacheDataSourceFactory) |
Deprecated.
|
ProgressiveDownloader(Uri uri,
String customCacheKey,
CacheDataSource.Factory cacheDataSourceFactory,
Executor executor) |
Deprecated.
|
ProgressiveDownloader(MediaItem mediaItem,
CacheDataSource.Factory cacheDataSourceFactory) |
Creates a new instance.
|
ProgressiveDownloader(MediaItem mediaItem,
CacheDataSource.Factory cacheDataSourceFactory,
Executor executor) |
Creates a new instance.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
cancel() |
Permanently cancels the downloading by this downloader.
|
void |
download(Downloader.ProgressListener progressListener) |
Downloads the content.
|
void |
remove() |
Removes the content.
|
@Deprecated public ProgressiveDownloader(Uri uri, @Nullable String customCacheKey, CacheDataSource.Factory cacheDataSourceFactory)
public ProgressiveDownloader(MediaItem mediaItem, CacheDataSource.Factory cacheDataSourceFactory)
mediaItem - The media item with a uri to the stream to be downloaded.cacheDataSourceFactory - A CacheDataSource.Factory for the cache into which the
download will be written.@Deprecated public ProgressiveDownloader(Uri uri, @Nullable String customCacheKey, CacheDataSource.Factory cacheDataSourceFactory, Executor executor)
public ProgressiveDownloader(MediaItem mediaItem, CacheDataSource.Factory cacheDataSourceFactory, Executor executor)
mediaItem - The media item with a uri to the stream to be downloaded.cacheDataSourceFactory - A CacheDataSource.Factory for the cache into which the
download will be written.executor - An Executor used to make requests for the media being downloaded. In
the future, providing an Executor that uses multiple threads may speed up the
download by allowing parts of it to be executed in parallel.public void download(@Nullable
Downloader.ProgressListener progressListener)
throws IOException,
InterruptedException
DownloaderIf 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.
download in interface DownloaderprogressListener - A listener to receive progress updates, or null.IOException - If the download failed to complete successfully.InterruptedException - If the download was interrupted.public void cancel()
DownloaderOnce canceled, Downloader.download(com.google.android.exoplayer2.offline.Downloader.ProgressListener) cannot be called again.
cancel in interface Downloaderpublic void remove()
Downloaderremove in interface Downloader