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.Why this download failed, or null if it has not 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
Why this download failed, or null if it has not failed. Non-null exactly whengetState()isOfflineDownloadState.FAILED.When the failure was delivered to
MediaDownloadResultListener.onMediaDownloadFailed(String, Exception)with an exception in the current process run, this is that same instance, so its message and stack trace describe the real failure. The instance is shared with every caller - do not modify it.Otherwise (a failure from an earlier process run, or one delivered with no exception) only a failure-reason code is persisted, and this is an
IOExceptionsynthesized from that code - a marker, not a diagnosis.The runtime type is not fixed: the real cause can be any
Exception, including aRuntimeException. Do not cast it toIOException. -
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
-