M - The type of the manifest object.K - The type of the streams key object.public abstract class SegmentDownloader<M extends FilterableManifest<M,K>,K> extends java.lang.Object implements Downloader
| Modifier and Type | Class and Description |
|---|---|
protected static class |
SegmentDownloader.Segment
Smallest unit of content to be downloaded.
|
| Constructor and Description |
|---|
SegmentDownloader(android.net.Uri manifestUri,
java.util.List<K> streamKeys,
DownloaderConstructorHelper constructorHelper) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Interrupts any current download operation and prevents future operations from running.
|
void |
download()
Downloads the selected streams in the media.
|
long |
getDownloadedBytes()
Returns the total number of downloaded bytes.
|
float |
getDownloadPercentage()
Returns the estimated download percentage, or
C.PERCENTAGE_UNSET if no estimate is
available. |
protected abstract M |
getManifest(DataSource dataSource,
android.net.Uri uri)
Loads and parses the manifest.
|
protected abstract java.util.List<SegmentDownloader.Segment> |
getSegments(DataSource dataSource,
M manifest,
boolean allowIncompleteList)
Returns a list of all downloadable
SegmentDownloader.Segments for a given manifest. |
void |
remove()
Removes the media.
|
public SegmentDownloader(android.net.Uri manifestUri,
java.util.List<K> streamKeys,
DownloaderConstructorHelper constructorHelper)
manifestUri - The Uri of the manifest to be downloaded.streamKeys - Keys defining which streams in the manifest should be selected for download.
If empty, all streams are downloaded.constructorHelper - A DownloaderConstructorHelper instance.public final void download()
throws java.io.IOException,
java.lang.InterruptedException
download in interface Downloaderjava.io.IOException - Thrown when there is an error downloading.java.lang.InterruptedException - If the thread has been interrupted.public void cancel()
Downloadercancel in interface Downloaderpublic final long getDownloadedBytes()
DownloadergetDownloadedBytes in interface Downloaderpublic final float getDownloadPercentage()
DownloaderC.PERCENTAGE_UNSET if no estimate is
available.getDownloadPercentage in interface Downloaderpublic final void remove()
throws java.lang.InterruptedException
Downloaderremove in interface Downloaderjava.lang.InterruptedException - Thrown if the thread was interrupted.protected abstract M getManifest(DataSource dataSource, android.net.Uri uri) throws java.io.IOException
dataSource - The DataSource through which to load.uri - The manifest uri.java.io.IOException - If an error occurs reading data.protected abstract java.util.List<SegmentDownloader.Segment> getSegments(DataSource dataSource, M manifest, boolean allowIncompleteList) throws java.lang.InterruptedException, java.io.IOException
SegmentDownloader.Segments for a given manifest.dataSource - The DataSource through which to load any required data.manifest - The manifest containing the segments.allowIncompleteList - Whether to continue in the case that a load error prevents all
segments from being listed. If true then a partial segment list will be returned. If false
an IOException will be thrown.SegmentDownloader.Segments.java.lang.InterruptedException - Thrown if the thread was interrupted.java.io.IOException - Thrown if allowPartialIndex is false and a load error occurs, or if
the media is not in a form that allows for its segments to be listed.