Class: shaka.offline.DownloadManager

Constructor

new DownloadManager(networkingEnginenon-null, onProgress, onInitData)

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
onInitData function
Implements:
Source:

Members

(private) destroyed_ :boolean

Type:
  • boolean
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) onInitData_ :function(!Uint8Array, string)

A callback for when a segment has new PSSH data and we pass on the initData to storage
Type:
  • function(!Uint8Array, string)
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, isInitSegment, 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
isInitSegment boolean
onDownloaded function(BufferSource):!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>