Constructor
new Storage(player)
This manages persistent offline data including storage, listing, and deleting
stored manifests. Playback of offline manifests are done using Player
using the special URI (e.g. 'offline:12').
Parameters:
Name | Type | Description |
---|---|---|
player |
shaka.Player | The player instance to pull configuration data from. |
- Implements:
- Source:
Members
-
(private, nullable) config_ :shakaExtern.OfflineConfiguration
-
Type:
- Source:
-
(private) dbEngine_ :shaka.offline.DBEngine
-
Type:
- Source:
-
(private) downloadManager_ :shaka.offline.DownloadManager
-
Type:
- Source:
-
(private) drmEngine_ :shaka.media.DrmEngine
-
Type:
- Source:
-
(private) duration_ :number
-
Type:
- number
- Source:
-
(private) firstPeriodTracks_ :Array.<shakaExtern.Track>
-
Type:
- Array.<shakaExtern.Track>
- Source:
-
(private, non-null) inProgressSegmentIds_ :Array.<number>
-
The IDs of the segments that have been stored for an in-progress store(). This is used to cleanup in destroy().
Type:
- Array.<number>
- Source:
-
(private, nullable) manifest_ :shakaExtern.Manifest
-
Type:
- Source:
-
(private) manifestId_ :number
-
Type:
- number
- Source:
-
(private) player_ :shaka.Player
-
Type:
- Source:
-
(private) storeInProgress_ :boolean
-
Type:
- boolean
- Source:
Methods
-
(static) support() → {boolean}
-
Gets whether offline storage is supported.
- Source:
Returns:
- Type
- boolean
-
(private) checkDestroyed_()
-
Throws an error if the object is destroyed.
- Source:
-
(private) cleanup_() → (non-null) {Promise}
-
Cleans up the current store and destroys any objects. This object is still usable after this.
- Source:
Returns:
- Type
- Promise
-
configure(config)
-
Sets configuration values for Storage. This is not associated with Player.configure and will not change Player.
Parameters:
Name Type Description config
shakaExtern.OfflineConfiguration - Source:
-
(private) createOfflineManifest_(originalManifestUri, appMetadatanon-null) → {shakaExtern.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 originalManifestUri
string appMetadata
Object - Source:
Returns:
-
(private) createPeriod_(period) → {shakaExtern.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 period
shakaExtern.Period - Source:
Returns:
- Type
- shakaExtern.PeriodDB
-
(private) createSegmentIndex_(manifest) → (non-null) {Promise}
-
Calls createSegmentIndex for all streams in the manifest.
Parameters:
Name Type Description manifest
shakaExtern.Manifest - Source:
Returns:
- Type
- Promise
-
(private) createStream_(period, streamSet, stream) → {shakaExtern.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 period
shakaExtern.Period streamSet
shakaExtern.StreamSet stream
shakaExtern.Stream - Source:
Returns:
- Type
- shakaExtern.StreamDB
-
(private) defaultConfig_() → {shakaExtern.OfflineConfiguration}
-
- Source:
Returns:
-
(private) defaultTrackSelect_(tracksnon-null) → (non-null) {Array.<shakaExtern.Track>}
-
The default track selection function.
Parameters:
Name Type Description tracks
Array.<shakaExtern.Track> - Source:
Returns:
- Type
- Array.<shakaExtern.Track>
-
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
-
(private) filterPeriod_(period)
-
Parameters:
Name Type Description period
shakaExtern.Period - Source:
-
(private) initIfNeeded_() → (non-null) {Promise}
-
Initializes the DBEngine if it is not already.
- Source:
Returns:
- Type
- Promise
-
list() → (non-null) {Promise.<!Array.<shakaExtern.StoredContent>>}
-
Lists all the stored content available.
- Source:
Returns:
- Type
- Promise.<!Array.<shakaExtern.StoredContent>>
-
loadInternal(manifestUri, onError, opt_manifestParserFactoryopt, non-null) → (non-null) {Promise.<{manifest: shakaExtern.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 Attributes Description manifestUri
string onError
function(*) opt_manifestParserFactory
shakaExtern.ManifestParser.Factory <optional>
- Source:
Returns:
- Type
- Promise.<{manifest: shakaExtern.Manifest, drmEngine: !shaka.media.DrmEngine}>
-
remove(content) → (non-null) {Promise}
-
Removes the given stored content.
Parameters:
Name Type Description content
shakaExtern.StoredContent - Source:
Returns:
- Type
- Promise
-
setDbEngine(enginenon-null)
-
Sets the DBEngine instance to use. This is used for testing.
Parameters:
Name Type Description engine
shaka.offline.DBEngine - Source:
-
store(manifestUri, appMetadatanon-null, opt_manifestParserFactoryopt, non-null) → (non-null) {Promise.<shakaExtern.StoredContent>}
-
Stores the given manifest.
Parameters:
Name Type Attributes Description manifestUri
string appMetadata
Object opt_manifestParserFactory
shakaExtern.ManifestParser.Factory <optional>
- Source:
Returns:
- Type
- Promise.<shakaExtern.StoredContent>