Class Download
- All Implemented Interfaces:
Serializable
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The download is completedstatic final int
At least one chunk download failed and the download is in error statestatic final int
The download is pausedstatic final int
The download is currently downloadingstatic final int
The download is queued for loading -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Get all available (remote) audio tracks or null if no audio tracks are available.long
Returns the size in bytes of the currently download data on disk.Returns the content DRM configuration.long
Returns the total size of all selected tracks of this download.Returns a Bundle with the extra header key:values that will be added to the requests.getId()
The local folder that contains the files for this download.Returns the path to the local Manifest.boolean
The flag specifying the video tracks should be merged or notReturns a Bundle with the extra query params that will be added to the requests.int[]
Get the array of selected audio tracks by indexint[]
int
Get the index of the selected trick-play trackint
Get the index of the selected video tracklong
getSize
(int mediaType, int trackIndex) Returns the size of the chunk with the given media type, i.eSdkConsts.VIDEO
,SdkConsts.AUDIO
,SdkConsts.TEXT
, orSdkConsts.OTHER
, and its track index.long
getSize
(int mediaType, int trackIndex, boolean isTrickPlay) Returns the size of the chunk with the given media type, i.eSdkConsts.VIDEO
,SdkConsts.AUDIO
,SdkConsts.TEXT
, orSdkConsts.OTHER
, and its track index.int
getState()
Get the current state of this downloadcom.castlabs.sdk.downloader.TrackDownload[]
Get all available (remote) subtitle tracks or null if no subtitle tracks are available.All available (remote) trick-play representations.All available (remote) video representations.int
hashCode()
void
setHeaderParams
(Bundle headers) Sets the headers to add to the download requests.void
setQueryParams
(Bundle queryParams) Sets the query params to add to the download requests.void
setSelectedAudioTracks
(int[] selectedAudioTracks) Set the array of selected audio tracksvoid
setSelectedSubtitleTracks
(int[] selectedSubtitleTracks) Set the selected subtitle tracks by indexvoid
setSelectedTrickPlayTrackQuality
(int selectedTrickPlayTrackQuality) Set the selected trick-play track quality using its index in the list of available representations.void
setSelectedVideoTrackQuality
(int selectedVideoTrackQuality) Set the selected video track quality using its index in the list of available representations.toString()
-
Field Details
-
STATE_QUEUED
public static final int STATE_QUEUEDThe download is queued for loading- See Also:
-
STATE_LOADING
public static final int STATE_LOADINGThe download is currently downloading- See Also:
-
STATE_ERROR
public static final int STATE_ERRORAt least one chunk download failed and the download is in error state- See Also:
-
STATE_DONE
public static final int STATE_DONEThe download is completed- See Also:
-
STATE_IDLE
public static final int STATE_IDLEThe download is paused- See Also:
-
-
Constructor Details
-
Download
public Download(@NonNull String id, @NonNull String remoteUrl, @NonNull File localBaseFolder, boolean mergeVideoTracks) Create Download with specified Id, manifest URL and base folder for storage.- Parameters:
id
- Current download IdremoteUrl
- Manifest remote URLlocalBaseFolder
- Base folder for storing current download
-
-
Method Details
-
getId
- Returns:
- The unique ID that identifies this download
-
getRemoteUrl
- Returns:
- The remote URL that us the primary source for this download
-
getLocalBaseFolder
The local folder that contains the files for this download. Each download usually has a unique folder that contains all files related to this download.- Returns:
- The local folder that contains the files for this download
-
getMergeVideoTracks
public boolean getMergeVideoTracks()The flag specifying the video tracks should be merged or not- Returns:
- The merge video tracks flag
-
getVideoTrackQualities
All available (remote) video representations. This represents all video qualities that are available on the remote, not only the locally available representations.- Returns:
- All available video representations
-
getTrickPlayTrackQualities
All available (remote) trick-play representations. This represents all trick-play qualities that are available on the remote, not only the locally available representations.- Returns:
- All available trick-play representations
-
getDownloadedSize
public long getDownloadedSize()Returns the size in bytes of the currently download data on disk.- Returns:
- Currently downloaded data
-
getAudioTracks
Get all available (remote) audio tracks or null if no audio tracks are available. This represents all audio tracks that are available on the remote, not only the locally available tracks.- Returns:
- The available (remote) audio tracks
-
getSubtitleTracks
Get all available (remote) subtitle tracks or null if no subtitle tracks are available. This represents all subtitle tracks that are available on the remote, not only the locally available tracks.- Returns:
- The available (remote) subtitle tracks
-
getSelectedVideoTrackQuality
public int getSelectedVideoTrackQuality()Get the index of the selected video track- Returns:
- The index of the selected video track.
-
setSelectedVideoTrackQuality
public void setSelectedVideoTrackQuality(int selectedVideoTrackQuality) Set the selected video track quality using its index in the list of available representations.- Parameters:
selectedVideoTrackQuality
- The video track quality index
-
getSelectedTrickPlayTrackQuality
public int getSelectedTrickPlayTrackQuality()Get the index of the selected trick-play track- Returns:
- The index of the selected trick-play track.
-
setSelectedTrickPlayTrackQuality
public void setSelectedTrickPlayTrackQuality(int selectedTrickPlayTrackQuality) Set the selected trick-play track quality using its index in the list of available representations.- Parameters:
selectedTrickPlayTrackQuality
- The trick-play track quality index
-
getSelectedAudioTracks
@Nullable public int[] getSelectedAudioTracks()Get the array of selected audio tracks by index- Returns:
- The array of selected audio tracks by index
-
setSelectedAudioTracks
public void setSelectedAudioTracks(@Nullable int[] selectedAudioTracks) Set the array of selected audio tracks- Parameters:
selectedAudioTracks
- The selected audio tracks
-
getSelectedSubtitleTracks
@Nullable public int[] getSelectedSubtitleTracks()- Returns:
- The array of selected subtitle tracks by index
-
setSelectedSubtitleTracks
public void setSelectedSubtitleTracks(@Nullable int[] selectedSubtitleTracks) Set the selected subtitle tracks by index- Parameters:
selectedSubtitleTracks
- The selected subtitle tracks by index
-
getLocalManifestUrl
Returns the path to the local Manifest. Once the download is completed, this path can be used to start playback of the local content.- Returns:
- The path to the local manifest
-
getDrmConfiguration
Returns the content DRM configuration.- Returns:
- Content DRM configuration
-
getState
public int getState()Get the current state of this download- Returns:
- The current state of this download
-
getEstimatedSize
public long getEstimatedSize()Returns the total size of all selected tracks of this download.Note that the manifest size only will be returned when no tracks are selected.
Please also note that the number of bytes returned here is an estimate of the total size of the download. Depending on the download source, i.e. file, DASH, or SmoothStreaming, information from the source is used to create this estimate. For example, for SmoothStreaming content, a track size is estimated based on the bitrate and the duration of the track. The same is true for segmented DASH. If a DASH source is based on single files, we try to use the information from the manifest that is used to generate the range requests to estimate the size. The latter is more accurate than simply using the specified bitrate, but it is still an estimate.
- Returns:
- The estimated size in bytes of this download
-
getSize
public long getSize(int mediaType, int trackIndex) Returns the size of the chunk with the given media type, i.eSdkConsts.VIDEO
,SdkConsts.AUDIO
,SdkConsts.TEXT
, orSdkConsts.OTHER
, and its track index.- Parameters:
mediaType
- The media typetrackIndex
- The track index- Returns:
- The size in bytes or 0
-
getSize
public long getSize(int mediaType, int trackIndex, boolean isTrickPlay) Returns the size of the chunk with the given media type, i.eSdkConsts.VIDEO
,SdkConsts.AUDIO
,SdkConsts.TEXT
, orSdkConsts.OTHER
, and its track index.- Parameters:
mediaType
- The media typetrackIndex
- The track indexisTrickPlay
- Whether the track is trick-play or not- Returns:
- The size in bytes or 0
-
equals
-
hashCode
public int hashCode() -
toString
-
getSubtitleTrackDownloads
public com.castlabs.sdk.downloader.TrackDownload[] getSubtitleTrackDownloads() -
getHeaderParams
Returns a Bundle with the extra header key:values that will be added to the requests.This Bundle will contain the headers informed with the
SdkConsts.INTENT_HEADER_PARAMS_BUNDLE
key in the Bundle passed toDownloadServiceBinder.prepareDownload(Context, Bundle, Downloader.ModelReadyCallback)
.- Returns:
- a Bundle with the extra header key:values that will be added to the requests.
-
setHeaderParams
Sets the headers to add to the download requests.If null, all already existing headers will be cleared.
- Parameters:
headers
- a Bundle containing headers to add to the download requests
-
getQueryParams
Returns a Bundle with the extra query params that will be added to the requests.This Bundle will contain the query params informed with the
SdkConsts.INTENT_QUERY_PARAMS_BUNDLE
key in the Bundle passed toDownloadServiceBinder.prepareDownload(Context, Bundle, Downloader.ModelReadyCallback)
.- Returns:
- a Bundle with the extra query params that will be added to the requests.
-
setQueryParams
Sets the query params to add to the download requests.If null, all already existing query params will be cleared.
- Parameters:
queryParams
- a Bundle containing query params to add to the download requests
-