ProgressiveDownloader


@UnstableApi
class ProgressiveDownloader : Downloader


A downloader for progressive media streams.

Summary

Public constructors

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

Creates a new instance.

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

Creates a new instance.

Public functions

Unit

Permanently cancels the downloading by this downloader.

Unit

Downloads the content.

Unit

Removes the content.

Public constructors

ProgressiveDownloader

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

Creates a new instance.

Parameters
mediaItem: MediaItem!

The media item with a uri to the stream to be downloaded.

cacheDataSourceFactory: CacheDataSource.Factory!

A 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!

The media item with a uri to the stream to be downloaded.

cacheDataSourceFactory: CacheDataSource.Factory!

A CacheDataSource.Factory for the cache into which the download will be written.

executor: 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 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 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.

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?

A listener to receive progress updates, or null.

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.

remove

fun remove(): Unit

Removes the content.