Constructor
new DownloadManager(storageEngine, netEnginenon-null, retryParams)
This manages downloading segments and notifying the app of progress.
Parameters:
| Name | Type | Description |
|---|---|---|
storageEngine |
shaka.offline.IStorageEngine | |
netEngine |
shaka.net.NetworkingEngine | |
retryParams |
shakaExtern.RetryParameters |
- Implements:
- Source:
Members
-
(private) downloadActual_ :number
-
Type:
- number
- Source:
-
(private) downloadExpected_ :number
-
Type:
- number
- Source:
-
(private, nullable) manifest_ :shakaExtern.ManifestDB
-
Type:
- Source:
-
(private) netEngine_ :shaka.net.NetworkingEngine
-
Type:
- Source:
-
(private, non-null) progressListeners_ :Array.<function(number, number)>
-
Type:
- Array.<function(number, number)>
- Source:
-
(private) promise_ :Promise
-
Type:
- Promise
- Source:
-
(private, nullable) retryParams_ :shakaExtern.RetryParameters
-
Type:
- Source:
-
(private, non-null) segments_ :Object.<string, !Array.<shaka.offline.DownloadManager.Segment>>
-
Type:
- Object.<string, !Array.<shaka.offline.DownloadManager.Segment>>
- Source:
-
(private) storageEngine_ :shaka.offline.IStorageEngine
-
Type:
- Source:
-
(private, non-null) storedSegmentIds_ :Array.<number>
-
The IDs of the segments that have been stored for an in-progress download(). This is used to cleanup in destroy().
Type:
- Array.<number>
- Source:
Methods
-
addSegment(type, ref, bandwidthSize, onStore)
-
Adds a segment to the list to be downloaded.
Parameters:
Name Type Description typestring refshaka.media.SegmentReference | shaka.media.InitSegmentReference bandwidthSizenumber onStorefunction(number) A callback for when the segment has been saved to storage. The parameter will be the id the segment was saved under. - Source:
-
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
-
downloadAndStore(manifest) → (non-null) {Promise.<number>}
-
Downloads all the segments, stores them in the database, and stores the given manifest object.
Parameters:
Name Type Description manifestshakaExtern.ManifestDB - Source:
Returns:
- Type
- Promise.<number>
-
(private) downloadSegment_(segment) → (non-null) {Promise}
-
Downloads the given segment and calls the callback.
Parameters:
Name Type Description segmentshaka.offline.DownloadManager.Segment - Source:
Returns:
- Type
- Promise
-
followProgress(callback)
-
Parameters:
Name Type Description callbackfunction(number, number) - Source:
-
(private) markAsDone_(segmentnon-null)
-
Parameters:
Name Type Description segmentshaka.offline.DownloadManager.Segment - Source:
-
(private) markAsPending_(segmentnon-null)
-
Parameters:
Name Type Description segmentshaka.offline.DownloadManager.Segment - Source:
-
(private) updateProgress_()
-
Calls the progress callback.
- Source:
Type Definitions
-
Segment
-
Type:
- {uris: !Array.<string>, startByte: number, endByte: ?number, bandwidthSize: number, onStore: function(number)}
Properties:
Name Type Attributes Description urisArray.<string> The URIs to download the segment. startBytenumber The byte index the segment starts at. endBytenumber <nullable>
The byte index the segment ends at, if present. bandwidthSizenumber The size of the segment as estimated by the bandwidth and segment duration. onStorefunction(number) A callback for when a segment as been added to the storage. - Source: