Class OfflineDownloadInfo

java.lang.Object
com.jwplayer.pub.api.offline.OfflineDownloadInfo

public class OfflineDownloadInfo extends Object
A snapshot of one downloaded, or partially downloaded, media item.

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 Details

  • Method Details

    • getMediaId

      public String 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 -1 when the total size is not yet known.
    • getState

      public OfflineDownloadState getState()
      What this download is currently doing.

      Use this to decide what a downloads screen should show: distinct treatment for OfflineDownloadState.PAUSED and OfflineDownloadState.FAILED rather than one "not finished" bucket, a spinner for OfflineDownloadState.QUEUED, and so on. To retry a failed download, request it again through OfflineDownloadManager.prepareMediaDownload(android.content.Context, com.jwplayer.pub.api.media.playlists.PlaylistItem); the SDK exposes no direct resume call.

    • getFailureReason

      @Nullable public Exception getFailureReason()
      Why this download failed, or null if it has not failed. Non-null exactly when getState() is OfflineDownloadState.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 IOException synthesized from that code - a marker, not a diagnosis.

      The runtime type is not fixed: the real cause can be any Exception, including a RuntimeException. Do not cast it to IOException.

    • isComplete

      public boolean isComplete()
      Whether the download finished. Equivalent to getState() == OfflineDownloadState.COMPLETED.

      Incomplete items still occupy the bytes reported by getBytesDownloaded() - a paused or failed download keeps what it already wrote.

    • getPlaylistItem

      @Nullable public PlaylistItem getPlaylistItem()
      The item needed to play this download back offline, or null when 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 but getState() is not OfflineDownloadState.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 MediaDrmCallback is not carried; only whether the item used Widevine is stored. A host using a custom MediaDrmCallback must re-attach it to this item's DrmConfig before playback.

      Equivalent to OfflineDownloadManager.getDownloadedPlaylistItem(String) for this item's media id.

    • toString

      public String toString()
      Overrides:
      toString in class Object