public abstract class DownloadHelper extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
DownloadHelper.Callback
A callback to be notified when the
DownloadHelper is prepared. |
Constructor and Description |
---|
DownloadHelper() |
Modifier and Type | Method and Description |
---|---|
abstract DownloadAction |
getDownloadAction(byte[] data,
List<TrackKey> trackKeys)
Builds a
DownloadAction for downloading the specified tracks. |
abstract int |
getPeriodCount()
Returns the number of periods for which media is available.
|
abstract DownloadAction |
getRemoveAction(byte[] data)
Builds a
DownloadAction for removing the media. |
abstract TrackGroupArray |
getTrackGroups(int periodIndex)
Returns the track groups for the given period.
|
void |
prepare(DownloadHelper.Callback callback)
Initializes the helper for starting a download.
|
protected abstract void |
prepareInternal()
Called on a background thread during preparation.
|
public void prepare(DownloadHelper.Callback callback)
callback
- A callback to be notified when preparation completes or fails. The callback
will be invoked on the calling thread unless that thread does not have an associated Looper
, in which case it will be called on the application's main thread.protected abstract void prepareInternal() throws IOException
IOException
- If preparation fails.public abstract int getPeriodCount()
public abstract TrackGroupArray getTrackGroups(int periodIndex)
periodIndex
- The period index.TrackGroupArray.EMPTY
for single stream
content.public abstract DownloadAction getDownloadAction(@Nullable byte[] data, List<TrackKey> trackKeys)
DownloadAction
for downloading the specified tracks. Must not be called until
after preparation completes.data
- Application provided data to store in DownloadAction.data
.trackKeys
- The selected tracks. If empty, all streams will be downloaded.DownloadAction
.public abstract DownloadAction getRemoveAction(@Nullable byte[] data)
DownloadAction
for removing the media. May be called in any state.data
- Application provided data to store in DownloadAction.data
.DownloadAction
.