Constructor
new DownloadManager(networkingEnginenon-null)
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 |
- Implements:
- Source:
Members
abortCallbacks_ :Array.<function(): !Promise>
A list of callback functions to cancel any in-progress downloads.
Type:
- Array.<function(): !Promise>
- Source:
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:
Methods
abortAll() → {Promise}
Aborts all in-progress downloads.
- Source:
Returns:
A promise that will resolve once the downloads are fully
aborted.
- Type
- Promise
destroy() → {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
fetchSegment_(request) → {Promise.<BufferSource>}
Download a segment and return the data in the response.
Parameters:
Name | Type | Description |
---|---|---|
request |
shaka.extern.Request |
- Source:
Returns:
- Type
- Promise.<BufferSource>
onInitData_()
A callback for when a segment has new PSSH data and we pass
on the initData to storage
- Source:
onProgress_()
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.
- Source:
queue(groupId, request, estimatedByteLength, isInitSegment, onDownloaded) → {Promise}
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:
Returns:
Resolved when this request is complete.
- Type
- Promise
queueWork(groupId, callback) → {Promise}
Add additional async work to the group work queue.
Parameters:
Name | Type | Description |
---|---|---|
groupId |
number | The group to add this group to. If the group does not exist, a new group will be created. |
callback |
function():!Promise | The callback for the async work. Downloading for this group will be blocked until the Promise returned by |callback| resolves. |
- Source:
Returns:
Resolved when this work is complete.
- Type
- Promise
setCallbacks(onProgress, onInitData)
Parameters:
Name | Type | Description |
---|---|---|
onProgress |
function(number, number) | |
onInitData |
function(!Uint8Array, string) |
- Source:
waitToFinish() → {Promise.<number>}
Get a promise that will resolve when all currently queued downloads have
finished.
- Source:
Returns:
- Type
- Promise.<number>