Skip to content

Commit efa1108

Browse files
committed
Add additional docs for offline storage
This adds additional text explaining how to use the Storage API. Change-Id: Icff55d6fe19e91f983ffb3e4a786f2beefe9ae8f
1 parent 66963dc commit efa1108

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

lib/offline/storage.js

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ goog.require('shaka.util.StreamUtils');
4040
* stored manifests. Playback of offline manifests are done using Player
4141
* using the special URI (e.g. 'offline:12').
4242
*
43+
* First, check support() to see if offline is supported by the platform.
44+
* Second, configure() the storage object with callbacks to your application.
45+
* Third, call store(), remove(), or list() as needed.
46+
* When done, call destroy().
47+
*
4348
* @param {shaka.Player} player
4449
* The player instance to pull configuration data from.
4550
*
@@ -94,7 +99,9 @@ shaka.offline.Storage = function(player) {
9499

95100

96101
/**
97-
* Gets whether offline storage is supported.
102+
* Gets whether offline storage is supported. Returns true if offline storage
103+
* is supported for clear content. Support for offline storage of encrypted
104+
* content will not be determined until storage is attempted.
98105
*
99106
* @return {boolean}
100107
* @export
@@ -148,6 +155,12 @@ shaka.offline.Storage.prototype.destroy = function() {
148155
* Sets configuration values for Storage. This is not associated with
149156
* Player.configure and will not change Player.
150157
*
158+
* There are two important callbacks configured here: one for download progress,
159+
* and one to decide which tracks to store.
160+
*
161+
* The default track selection callback will store the largest SD video track.
162+
* Provide your own callback to choose the tracks you want to store.
163+
*
151164
* @param {shakaExtern.OfflineConfiguration} config
152165
* @export
153166
*/
@@ -159,12 +172,21 @@ shaka.offline.Storage.prototype.configure = function(config) {
159172

160173

161174
/**
162-
* Stores the given manifest.
175+
* Stores the given manifest. If the content is encrypted, and encrypted
176+
* content cannot be stored on this platform, the Promise will be rejected with
177+
* error code 6001, REQUESTED_KEY_SYSTEM_CONFIG_UNAVAILABLE.
163178
*
164-
* @param {string} manifestUri
165-
* @param {!Object} appMetadata
179+
* @param {string} manifestUri The URI of the manifest to store.
180+
* @param {!Object} appMetadata An arbitrary object from the application that
181+
* will be stored along-side the offline content. Use this for any
182+
* application-specific metadata you need associated with the stored content.
183+
* For details on the data types that can be stored here, please refer to
184+
* https://goo.gl/h62coS
166185
* @param {!shakaExtern.ManifestParser.Factory=} opt_manifestParserFactory
167-
* @return {!Promise.<shakaExtern.StoredContent>}
186+
* @return {!Promise.<shakaExtern.StoredContent>} A Promise to a structure
187+
* representing what was stored. The "offlineUri" member is the URI that
188+
* should be given to Player.load() to play this piece of content offline.
189+
* The "appMetadata" member is the appMetadata argument you passed to store().
168190
* @export
169191
*/
170192
shaka.offline.Storage.prototype.store = function(
@@ -339,7 +361,11 @@ shaka.offline.Storage.prototype.remove = function(content) {
339361
/**
340362
* Lists all the stored content available.
341363
*
342-
* @return {!Promise.<!Array.<shakaExtern.StoredContent>>}
364+
* @return {!Promise.<!Array.<shakaExtern.StoredContent>>} A Promise to an
365+
* array of structures representing all stored content. The "offlineUri"
366+
* member of the structure is the URI that should be given to Player.load()
367+
* to play this piece of content offline. The "appMetadata" member is the
368+
* appMetadata argument you passed to store().
343369
* @export
344370
*/
345371
shaka.offline.Storage.prototype.list = function() {

0 commit comments

Comments
 (0)