Class: shaka.offline.DownloadManager

Constructor

new DownloadManager(onProgress)

This manages downloading segments.
Parameters:
Name Type Description
onProgress function(number, number)
Implements:
Source:

Members

(private) destroyed_ :boolean

Type:
  • boolean
Source:

(private) downloadedBytes_ :number

When a segment is downloaded, the actual size of the segment will be added to this value so that we know exactly how many bytes we have downloaded.
Type:
  • number
Source:

(private) downloadedEstimatedBytes_ :number

When a segment is downloaded, the estimated size of that segment will be added to this value. It will allow us to track how much progress we have made in downloading all segments.
Type:
  • number
Source:

(private) expectedEstimatedBytes_ :number

When we queue a segment to be downloaded, the estimated size of that segment will be added to this value. This will allow us to estimate how many bytes of content we plan to download.
Type:
  • number
Source:

(private, non-null) groups_ :Object.<number, !Array.<shaka.offline.DownloadRequest>>

We sill store download requests in groups. The groups will be downloaded in parallel but the segments in each group will be done serially.
Type:
Source:

(private) onProgress_ :function(number, number)

Callback for after a segment has been downloaded. The first parameter will be the progress of the download. It will be a number between 0.0 (0% complete) and 1.0 (100% complete). The second parameter will be the the total number of bytes that have been downloaded.
Type:
  • function(number, number)
Source:

(private, non-null) promise_ :Promise

Type:
  • Promise
Source:

Methods

(private) checkDestroyed_()

Check if the download manager has been destroyed. If so, throw an error to kill the promise chain.
Source:

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

Destroys the object, 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

download(netnon-null) → (non-null) {Promise}

Parameters:
Name Type Description
net shaka.net.NetworkingEngine
Source:
Returns:
Type
Promise

(private) downloadGroup_(netnon-null, groupnon-null) → (non-null) {Promise}

Parameters:
Name Type Description
net shaka.net.NetworkingEngine
group Array.<shaka.offline.DownloadRequest>
Source:
Returns:
Type
Promise

(private) downloadSegment_(netnon-null, segment) → (non-null) {Promise}

Parameters:
Name Type Description
net shaka.net.NetworkingEngine
segment shaka.offline.DownloadRequest
Source:
Returns:
Type
Promise

queue(group, request, estimatedByteLength, onDownloaded)

Add a request to be downloaded as part of a group.
Parameters:
Name Type Description
group number The group to add this segment to. If the group does not exists, a new group will be created.
request shakaExtern.Request
estimatedByteLength number
onDownloaded function(!ArrayBuffer):!Promise A callback for when a request has been downloaded and can be used by the caller. Callback should return a promise so that downloading will not continue until we are done with the current response.
Source: