Class: shaka.offline.DownloadManager

Constructor

new DownloadManager(networkingEnginenon-null, onProgress)

Create a new download manager. It will use (but not own) |networkingEngine| and call |onProgress| after each download.
Parameters:
Name Type Description
networkingEngine shaka.net.NetworkingEngine
onProgress function
Implements:
Source:

Members

(private) destroyed_ :boolean

Type:
  • boolean
Source:

(private) downloadedBytes_ :number

When a segment is downloaded, the actual size of the segment is added to this value. We use this to know how large the final asset is.
Type:
  • number
Source:

(private) downloadedEstimatedBytes_ :number

We track progress using the estimated size (not the actual size) since the denominator (current / total) will be based on estimates.
Type:
  • number
Source:

(private) expectedEstimatedBytes_ :number

When we queue a segment, the estimated size is added to this value. This is used to track progress (downloaded / expected).
Type:
  • number
Source:

(private, non-null) groups_ :Map.<number, !Promise>

We group downloads. Within each group, the requests are executed in series. Between groups, the requests are executed in parallel. We store the promise chain that is doing the work.
Type:
  • Map.<number, !Promise>
Source:

(private) onProgress_ :function(number, number)

A callback for when a segment has been downloaded. The first parameter is the progress of all segments, a number between 0.0 (0% complete) and 1.0 (100% complete). The second parameter is the total number of bytes that have been downloaded.
Type:
  • function(number, number)
Source:

Methods

(export) destroy() → (non-null) {Promise}

Request that this object be destroyed, releasing all resources and shutting down all operations. Returns a Promise which is resolved when destruction is complete. This Promise should never be rejected.
Implements:
Source:
Returns:
Type
Promise

(async, private) fetchSegment_(request) → (non-null) {Promise.<!ArrayBuffer>}

Download a segment and return the data in the response.
Parameters:
Name Type Description
request shaka.extern.Request
Source:
Returns:
Type
Promise.<!ArrayBuffer>

queue(groupId, request, estimatedByteLength, onDownloaded)

Add a request to be downloaded as part of a group.
Parameters:
Name Type Description
groupId number The group to add this segment to. If the group does not exist, a new group will be created.
request shaka.extern.Request
estimatedByteLength number
onDownloaded function(!ArrayBuffer):!Promise The callback for when this request has been downloaded. Downloading for |group| will pause until the promise returned by |onDownloaded| resolves.
Source:

(async) waitToFinish() → (non-null) {Promise.<number>}

Get a promise that will resolve when all currently queued downloads have finished.
Source:
Returns:
Type
Promise.<number>