Constructor
(export) new Storage(playeropt, non-null)
This manages persistent offline data including storage, listing, and deleting
stored manifests. Playback of offline manifests are done through the Player
using a special URI (see shaka.offline.OfflineUri).
First, check support() to see if offline is supported by the platform.
Second, configure() the storage object with callbacks to your application.
Third, call store(), remove(), or list() as needed.
When done, call destroy().
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
player |
shaka.Player |
<optional> |
A player instance to share a networking engine and configuration with. When initializing with a player, storage is only valid as long as |destroy| has not been called on the player instance. When omitted, storage will manage its own networking engine and configuration. |
- Implements:
- Source:
Members
(private, non-null) openOperations_ :Array.<!Promise>
A list of open operations that are being performed by this instance of
|shaka.offline.Storage|.
Type:
- Array.<!Promise>
- Source:
(private, non-null) segmentsFromStore_ :Array.<number>
A list of segment ids for all the segments that were added during the
current store. If the store fails or is aborted, these need to be
removed from storage.
Type:
- Array.<number>
- Source:
(inner, constant) destroyNetworkingEngine :boolean
Storage should only destroy the networking engine if it was initialized
without a player instance. Store this as a flag here to avoid including
the player object in the destoyer's closure.
Type:
- boolean
- Source:
Methods
(export, static) deleteAll(playernon-null) → (non-null) {Promise}
Delete the on-disk storage and all the content it contains. This should not
be done regularly; only do it when storage is rendered unusable.
Parameters:
Name | Type | Description |
---|---|---|
player |
shaka.Player |
- Source:
Returns:
- Type
- Promise
(private, static) deleteAll_(networkingEnginenon-null, drmConfig) → (non-null) {Promise}
Parameters:
Name | Type | Description |
---|---|---|
networkingEngine |
shaka.net.NetworkingEngine | |
drmConfig |
shaka.extern.DrmConfiguration |
- Source:
Returns:
- Type
- Promise
(private, static) deleteLicenseFor_(netnon-null, drmConfignon-null, variantsnon-null, offlineSessionIdsnon-null) → (non-null) {Promise}
Parameters:
Name | Type | Description |
---|---|---|
net |
shaka.net.NetworkingEngine | |
drmConfig |
shaka.extern.DrmConfiguration | |
variants |
Array.<shaka.extern.Variant> | |
offlineSessionIds |
Array.<string> |
- Source:
Returns:
- Type
- Promise
(private, static) forEachSegment_(stream, startTime, callback)
Parameters:
Name | Type | Description |
---|---|---|
stream |
shaka.extern.Stream | |
startTime |
number | |
callback |
function(!shaka.media.SegmentReference) |
- Source:
(private, static) getAllManifests_() → (non-null) {Promise.<!Array.<shaka.extern.Manifest>>}
- Source:
Returns:
- Type
- Promise.<!Array.<shaka.extern.Manifest>>
(private, static) getAllSegmentIds_(manifest) → (non-null) {Array.<number>}
Parameters:
Name | Type | Description |
---|---|---|
manifest |
shaka.extern.ManifestDB |
- Source:
Returns:
- Type
- Array.<number>
(private, static) getStreamSet_(manifest) → (non-null) {Array.<shaka.extern.Stream>}
Get a collection of streams that are in the manifest. This collection will
only have one instance of each stream (similar to a set).
Parameters:
Name | Type | Description |
---|---|---|
manifest |
shaka.extern.Manifest |
- Source:
Returns:
- Type
- Array.<shaka.extern.Stream>
(export, static) support() → {boolean}
Gets whether offline storage is supported. Returns true if offline storage
is supported for clear content. Support for offline storage of encrypted
content will not be determined until storage is attempted.
- Source:
Returns:
- Type
- boolean
(static) validatePeriod_(period)
Go over a period and issue warnings for any suspicious properties.
Parameters:
Name | Type | Description |
---|---|---|
period |
shaka.extern.Period |
- Source:
(private, static) verifyConfig_(confignon-null)
Make sure that the given configuration object follows the correct structure
expected by |configure|. This function should be removed in v2.6 when
backward-compatibility is no longer needed.
Parameters:
Name | Type | Description |
---|---|---|
config |
Object | The config fields that the app wants to update. This object will be change by this function. |
- Source:
(private) checkDestroyed_()
Throws an error if the object is destroyed.
- Source:
(export) configure(confignon-null)
Sets configuration values for Storage. This is associated with
Player.configure and will change the player instance given at
initialization.
Parameters:
Name | Type | Description |
---|---|---|
config |
Object | This should follow the form of shaka.extern.PlayerConfiguration, but you may omit any field you do not wish to change. |
- Source:
(private) createOfflineManifest_(downloadernon-null, storage, drmEnginenon-null, manifest, originalManifestUri, metadatanon-null) → {shaka.extern.ManifestDB}
Creates an offline 'manifest' for the real manifest. This does not store the
segments yet, only adds them to the download manager through createPeriod_.
Parameters:
Name | Type | Description |
---|---|---|
downloader |
shaka.offline.DownloadManager | |
storage |
shaka.extern.StorageCell | |
drmEngine |
shaka.media.DrmEngine | |
manifest |
shaka.extern.Manifest | |
originalManifestUri |
string | |
metadata |
Object |
- Source:
Returns:
(private) createPeriod_(downloadernon-null, storage, estimator, drmEnginenon-null, manifest, period) → {shaka.extern.PeriodDB}
Converts a manifest Period to a database Period. This will use the current
configuration to get the tracks to use, then it will search each segment
index and add all the segments to the download manager through createStream_.
Parameters:
Name | Type | Description |
---|---|---|
downloader |
shaka.offline.DownloadManager | |
storage |
shaka.extern.StorageCell | |
estimator |
shaka.offline.StreamBandwidthEstimator | |
drmEngine |
shaka.media.DrmEngine | |
manifest |
shaka.extern.Manifest | |
period |
shaka.extern.Period |
- Source:
Returns:
(private) createRequest_(segment) → {shaka.extern.Request}
Parameters:
Name | Type | Description |
---|---|---|
segment |
shaka.media.SegmentReference | shaka.media.InitSegmentReference |
- Source:
Returns:
- Type
- shaka.extern.Request
(private) createSegmentIndex_(manifest) → (non-null) {Promise}
Calls createSegmentIndex for all streams in the manifest.
Parameters:
Name | Type | Description |
---|---|---|
manifest |
shaka.extern.Manifest |
- Source:
Returns:
- Type
- Promise
(private) createStream_(downloadernon-null, storage, estimator, manifest, period, stream) → {shaka.extern.StreamDB}
Converts a manifest stream to a database stream. This will search the
segment index and add all the segments to the download manager.
Parameters:
Name | Type | Description |
---|---|---|
downloader |
shaka.offline.DownloadManager | |
storage |
shaka.extern.StorageCell | |
estimator |
shaka.offline.StreamBandwidthEstimator | |
manifest |
shaka.extern.Manifest | |
period |
shaka.extern.Period | |
stream |
shaka.extern.Stream |
- Source:
Returns:
(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
(private) downloadManifest_(storage, drmEnginenon-null, manifest, uri, metadatanon-null) → (non-null) {Promise.<shaka.extern.ManifestDB>}
Create a download manager and download the manifest.
Parameters:
Name | Type | Description |
---|---|---|
storage |
shaka.extern.StorageCell | |
drmEngine |
shaka.media.DrmEngine | |
manifest |
shaka.extern.Manifest | |
uri |
string | |
metadata |
Object |
- Source:
Returns:
- Type
- Promise.<shaka.extern.ManifestDB>
(export) getNetworkingEngine() → {shaka.net.NetworkingEngine}
Return the networking engine that storage is using. If storage was
initialized with a player instance, then the networking engine returned
will be the same as |player.getNetworkingEngine()|.
The returned value will only be null if |destroy| was called before
|getNetworkingEngine|.
- Source:
Returns:
(private) getParser_(assetUri, mimeTypenullable) → (non-null) {Promise.<shaka.extern.ManifestParser>}
Get a parser for the asset located at |assetUri|.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
assetUri |
string | ||
mimeType |
string |
<nullable> |
When not null, the mimeType will be used to find the best manifest parser for the given asset. |
- Source:
Returns:
- Type
- Promise.<shaka.extern.ManifestParser>
(export) list() → (non-null) {Promise.<!Array.<shaka.extern.StoredContent>>}
Lists all the stored content available.
- Source:
Returns:
A Promise to an
array of structures representing all stored content. The "offlineUri"
member of the structure is the URI that should be given to Player.load()
to play this piece of content offline. The "appMetadata" member is the
appMetadata argument you passed to store().
- Type
- Promise.<!Array.<shaka.extern.StoredContent>>
(private) list_() → (non-null) {Promise.<!Array.<shaka.extern.StoredContent>>}
See |shaka.offline.Storage.list| for details.
- Source:
Returns:
- Type
- Promise.<!Array.<shaka.extern.StoredContent>>
loadInternal(manifestUri, onError, getParser) → (non-null) {Promise.<{manifest: shaka.extern.Manifest, drmEngine: !shaka.media.DrmEngine}>}
Loads the given manifest, parses it, and constructs the DrmEngine. This
stops the manifest parser. This may be replaced by tests.
Parameters:
Name | Type | Description |
---|---|---|
manifestUri |
string | |
onError |
function(*) | |
getParser |
function(): !Promise.<shaka.extern.ManifestParser> |
- Source:
Returns:
- Type
- Promise.<{manifest: shaka.extern.Manifest, drmEngine: !shaka.media.DrmEngine}>
(export) remove(contentUri) → (non-null) {Promise}
Removes the given stored content.
Parameters:
Name | Type | Description |
---|---|---|
contentUri |
string |
- Source:
Returns:
- Type
- Promise
(private) remove_(contentUri) → (non-null) {Promise}
See |shaka.offline.Storage.remove| for details.
Parameters:
Name | Type | Description |
---|---|---|
contentUri |
string |
- Source:
Returns:
- Type
- Promise
(private) removeFromDRM_(urinon-null, manifestDB) → (non-null) {Promise}
Parameters:
Name | Type | Description |
---|---|---|
uri |
shaka.offline.OfflineUri | |
manifestDB |
shaka.extern.ManifestDB |
- Source:
Returns:
- Type
- Promise
(private) removeFromStorage_(storage, urinon-null, manifest) → (non-null) {Promise}
Parameters:
Name | Type | Description |
---|---|---|
storage |
shaka.extern.StorageCell | |
uri |
shaka.offline.OfflineUri | |
manifest |
shaka.extern.ManifestDB |
- Source:
Returns:
- Type
- Promise
(private) requireSupport_()
Used by functions that need storage support to ensure that the current
platform has storage support before continuing. This should only be
needed to be used at the start of public methods.
- Source:
(private) startOperation_(actionnon-null) → (non-null) {Promise.<T>}
Perform an action. Track the action's progress so that when we destroy
we will wait until all the actions have completed before allowing destroy
to resolve.
Parameters:
Name | Type | Description |
---|---|---|
action |
Promise.<T> |
- Source:
Returns:
- Type
- Promise.<T>
(export) store(uri, appMetadataopt, non-null, mimeType) → (non-null) {Promise.<shaka.extern.StoredContent>}
Stores the given manifest. If the content is encrypted, and encrypted
content cannot be stored on this platform, the Promise will be rejected with
error code 6001, REQUESTED_KEY_SYSTEM_CONFIG_UNAVAILABLE.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
uri |
string | The URI of the manifest to store. | |
appMetadata |
Object |
<optional> |
An arbitrary object from the application that will be stored along-side the offline content. Use this for any application-specific metadata you need associated with the stored content. For details on the data types that can be stored here, please refer to https://bit.ly/StructClone |
mimeType |
string | shaka.extern.ManifestParser.Factory | The mime type for the content |manifestUri| points to or a manifest parser factory to override auto-detection or use an unregistered parser. Passing a manifest parser factory is deprecated and will be removed. |
- Source:
Returns:
A Promise to a structure
representing what was stored. The "offlineUri" member is the URI that
should be given to Player.load() to play this piece of content offline.
The "appMetadata" member is the appMetadata argument you passed to store().
- Type
- Promise.<shaka.extern.StoredContent>
(private) store_(uri, appMetadatanon-null, getParser) → (non-null) {Promise.<shaka.extern.StoredContent>}
See |shaka.offline.Storage.store| for details.
Parameters:
Name | Type | Description |
---|---|---|
uri |
string | |
appMetadata |
Object | |
getParser |
function(): !Promise.<shaka.extern.ManifestParser> |
- Source:
Returns:
- Type
- Promise.<shaka.extern.StoredContent>