Class OfflineDownloadInfo
Returned by OfflineDownloadManager.getDownloads(android.content.Context). Everything a
downloads screen normally needs is here, so a full inventory costs one call rather than a lookup
per item.
-
Constructor Summary
ConstructorsConstructorDescriptionOfflineDownloadInfo(String mediaId, long bytesDownloaded, float percentDownloaded, OfflineDownloadState state, Exception failureReason, PlaylistItem playlistItem) -
Method Summary
Modifier and TypeMethodDescriptionlongBytes written to disk so far for this item.Non-null exactly whengetState()isOfflineDownloadState.FAILED.The media id this download was requested with.floatProgress from 0 to 100, or-1when the total size is not yet known.The item needed to play this download back offline, ornullwhen the stored data could not be parsed.getState()What this download is currently doing.booleanWhether the download finished.toString()
-
Constructor Details
-
OfflineDownloadInfo
public OfflineDownloadInfo(String mediaId, long bytesDownloaded, float percentDownloaded, OfflineDownloadState state, @Nullable Exception failureReason, @Nullable PlaylistItem playlistItem)
-
-
Method Details
-
getMediaId
The media id this download was requested with. -
getBytesDownloaded
public long getBytesDownloaded()Bytes written to disk so far for this item. -
getPercentDownloaded
public float getPercentDownloaded()Progress from 0 to 100, or-1when the total size is not yet known. -
getState
What this download is currently doing.Use this to decide what a downloads screen should show: distinct treatment for
OfflineDownloadState.PAUSEDandOfflineDownloadState.FAILEDrather than one "not finished" bucket, a spinner forOfflineDownloadState.QUEUED, and so on. To retry a failed download, request it again throughOfflineDownloadManager.prepareMediaDownload(android.content.Context, com.jwplayer.pub.api.media.playlists.PlaylistItem); the SDK exposes no direct resume call. -
getFailureReason
Non-null exactly whengetState()isOfflineDownloadState.FAILED.The player library persists only a failure-reason code in its download index, not the original exception, so this is an exception synthesized from that code - useful as a marker and a message, but not a stack trace into the actual failure.
-
isComplete
public boolean isComplete()Whether the download finished. Equivalent togetState() == OfflineDownloadState.COMPLETED.Incomplete items still occupy the bytes reported by
getBytesDownloaded()- a paused or failed download keeps what it already wrote. -
getPlaylistItem
The item needed to play this download back offline, ornullwhen the stored data could not be parsed.Non-null does not mean the download is playable: a partially downloaded item also has one, and handing it to the player would play incomplete media. Check
isComplete()first. When this is null butgetState()is notOfflineDownloadState.FAILED, the stored metadata is corrupt rather than the download having failed.The item is reconstructed from the fields persisted with the download, not the original object the download was requested with. Anything that cannot be persisted is absent - in particular a host-supplied
MediaDrmCallbackis not carried; only whether the item used Widevine is stored. A host using a customMediaDrmCallbackmust re-attach it to this item'sDrmConfigbefore playback.Equivalent to
OfflineDownloadManager.getDownloadedPlaylistItem(String)for this item's media id. -
toString
-