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()
      Non-null exactly when getState() is OfflineDownloadState.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 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