Class: shaka.player.OfflineVideoSource

Constructor

new OfflineVideoSource(groupIdnullable, estimator, abrManager)

Creates an OfflineVideoSource.
Parameters:
Name Type Attributes Description
groupId number <nullable>
The unique ID of the group of streams in this source.
estimator shaka.util.IBandwidthEstimator
abrManager shaka.media.IAbrManager
Extends:
Source:

Members

(private, non-null) config_ :Object.<string, *>

Type:
  • Object.<string, *>
Source:

(private, nullable) groupId_ :number

Type:
  • number
Source:

(private, non-null) listeners_ :shaka.util.MultiMap.<shaka.util.FakeEventTarget.ListenerType>

Type:
Inherited From:
Source:

(private) networkCallback_ :shaka.util.FailoverUri.NetworkCallback

Type:
Source:

(private) overrideConfig_ :shaka.player.DrmInfo.Config

Type:
Source:

(protected) parent :shaka.util.FakeEventTarget

Type:
Inherited From:
Source:

(private, non-null) sessionIds_ :Array.<string>

Type:
  • Array.<string>
Source:

(private, non-null) streamConfig_ :Object.<string, *>

Type:
  • Object.<string, *>
Inherited From:
Source:

timeoutMs :number

The timeout, in milliseconds, for downloading and storing offline licenses for encrypted content.
Type:
  • number
Source:

Methods

(static) retrieveGroupIds() → (non-null) {Promise.<!Array.<number>>}

Retrieves an array of all stored group IDs.
Source:
Returns:
The unique IDs of all of the stored groups.
Type
Promise.<!Array.<number>>

addEventListener(type, listener, opt_capturingopt)

Add an event listener to this object.
Parameters:
Name Type Attributes Description
type string The event type to listen for.
listener shaka.util.FakeEventTarget.ListenerType The callback or listener object to invoke.
opt_capturing boolean <optional>
True to listen during the capturing phase, false to listen during the bubbling phase. Note that FakeEventTarget does not support the capturing phase from the standard event model.
Inherited From:
Source:

(private) applyRestrictions_()

Applies the video track restrictions, if any.
Inherited From:
Source:

attach()

Inherited From:
Source:

(private) beginPlayback_(segmentIndexesnon-null, timestampCorrection)

Corrects the MediaSource's duration and append windows, moves the playhead to the start of the first buffered range, and then starts playback by signalling each Stream to proceed.
Parameters:
Name Type Description
segmentIndexes Array.<!shaka.media.SegmentIndex> The initial set of SegmentIndexes.
timestampCorrection number The global timestamp correction.
Inherited From:
Source:

(private) cancelSeekRangeTimer_()

Cancels the seek range timer, if any.
Inherited From:
Source:

(private) cancelUpdateTimer_()

Cancels the update timer, if any.
Inherited From:
Source:

(private) clampPlayheadToLeft_(currentTime, end) → {boolean}

Clamps the video's current time to the left of the given end time (inclusive).
Parameters:
Name Type Description
currentTime number The video's current time.
end number The end time in seconds.
Inherited From:
Source:
Returns:
True if the video's current was clamped, in which case a 'seeking' event will be fired by the video.
Type
boolean

(private) clampPlayheadToRight_(currentTime, start, end) → {boolean}

Clamps the video's current time to the right of the given start time (inclusive).
Parameters:
Name Type Description
currentTime number The video's current time.
start number The start time in seconds.
end number The end time in seconds, which must be provided to ensure that the playhead is not adjusted too far right.
Inherited From:
Source:
Returns:
True if the video's current was clamped, in which case a 'seeking' event will be fired by the video.
Type
boolean

(private) computeStreamLimits_(segmentIndexesnon-null) → (nullable) {?{start: number, end: number, last: number}}

Computes the stream limits, i.e., a stream start time and stream end time, of the given SegmentIndexes. The stream limits define the video's seekable range, so the video's current time should always be within the stream limits. The stream limits are a subset of each individual SegmentIndex's seek range; however, the converse is not true.
Parameters:
Name Type Description
segmentIndexes Array.<!shaka.media.SegmentIndex>
Inherited From:
Source:
Returns:
The stream limits on success; otherwise, return null if a stream end time could not be computed or the streams' media timelines do not intersect.
Type
?{start: number, end: number, last: number}

configure(confignon-null)

Configures the OfflineVideoSource options. Options are set via key-value pairs. The following configuration options are supported: licenseRequestTimeout: number Sets the license request timeout in seconds. mpdRequestTimeout: number Sets the MPD request timeout in seconds. segmentRequestTimeout: number Sets the segment request timeout in seconds.
Parameters:
Name Type Description
config Object.<string, *> A configuration object, which contains the configuration options as key-value pairs. All fields should have already been validated.
Overrides:
Source:
Example
offlineVideoSouce.configure({'licenseRequestTimeout': 20});

(private) configureStreams_()

Configures each Stream with |streamConfig_|
Inherited From:
Source:

(private) createAndStartStreams_() → (non-null) {Promise}

Instantiates the Streams and begins stream startup. Stream startup consists of starting a Stream for each available content type, waiting for each of these Streams to complete their initialization sequence (see shaka.media.IStream), applying the global timestamp correction, and then beginning playback. This function resolves the returned Promise when it instantiates and starts the initial set of Streams; at this time, each Stream (i.e., each Stream in this.streamsByType_) will be in the 'startup' state; however, actual playback will not have begun, and the video's playback rate should be zero. When each Stream completes startup we call shaka.player.StreamVideoSource#onAllStreamsStarted_; at this time, each Stream will be in the 'waiting' state.
Inherited From:
Source:
Returns:
A Promise that resolves when this function creates the initial set of Streams and begins stream startup. If the manifest specifies live content then this function will always resolve the returned Promise; otherwise, this function may reject the returned Promise.
Type
Promise

(private) createStream_(streamInfonon-null) → (non-null) {shaka.media.Stream}

Creates a Stream object.
Parameters:
Name Type Description
streamInfo shaka.media.StreamInfo
Inherited From:
Source:
Returns:
Type
shaka.media.Stream

(private) createStreams_(streamInfosByTypenon-null) → {boolean}

Creates the initial set of Stream objects. Populates |streamsByType_| on success.
Parameters:
Name Type Description
streamInfosByType Object.<string, !shaka.media.StreamInfo>
Inherited From:
Source:
Returns:
True on success; otherwise, return false.
Type
boolean

(private) createTextStream_() → (non-null) {shaka.media.TextStream}

Creates a TextStream object.
Inherited From:
Source:
Returns:
Type
shaka.media.TextStream

deleteGroup(opt_configopt, opt_forceDeleteopt) → (non-null) {Promise.<Error>}

Deletes a group of streams from storage. This destroys the VideoSource.
Parameters:
Name Type Attributes Description
opt_config shaka.player.DrmInfo.Config <optional>
Optional config to override the values stored. Can only change |licenseServerUrl|, |withCredentials|, |serverCertificate|, |licensePreProcessor|, and |licensePostProcessor|.
opt_forceDelete boolean <optional>
True to delete the content even if there is an error when deleting the persistent session. The error is returned.
Source:
Returns:
Type
Promise.<Error>

(private) deleteGroupContent_() → (non-null) {Promise}

Deletes the offline content from the database for the given |group|.
Source:
Returns:
Type
Promise

(private) deletePersistentSessions_() → (non-null) {Promise}

Deletes any persistent sessions associated with the |groupId_|.
Source:
Returns:
Type
Promise

destroy()

Inherited From:
Source:

dispatchEvent(eventnon-null) → {boolean}

Dispatch an event from this object.
Parameters:
Name Type Description
event Event The event to be dispatched from this object.
Inherited From:
Source:
Returns:
True if the default action was prevented.
Type
boolean

enableTextTrack()

Inherited From:
Source:

(private) endOfStream_()

Signals the end of the video.
Inherited From:
Source:

(private) fireSeekRangeChangedEvent_(start, end)

Fires a 'seekrangechanged' event.
Parameters:
Name Type Description
start number
end number
Inherited From:
Source:

(private) fireTracksChangedEvent_()

Fires a 'trackschanged' event.
Inherited From:
Source:

getAudioTracks()

Inherited From:
Source:

getBufferingGoal()

Inherited From:
Source:

getConfigurations()

Inherited From:
Source:

(private) getSegmentIndexes_() → (non-null) {Array.<!shaka.media.SegmentIndex>}

Gets the active Streams' SegmentIndexes.
Inherited From:
Source:
Returns:
Type
Array.<!shaka.media.SegmentIndex>

getSessionIds()

Overrides:
Source:

getTextTracks()

Inherited From:
Source:

getVideoTracks()

Inherited From:
Source:

(private) initializeStreams_(streamInfosnon-null, initDatasnon-null) → (non-null) {Promise}

Creates sourceBuffers and appends init data for each of the given streams. This should trigger encrypted events for any encrypted streams.
Parameters:
Name Type Description
streamInfos Array.<!shaka.media.StreamInfo> The streams to initialize.
initDatas Array.<ArrayBuffer> |streamInfos| corresponding initialization data.
Source:
Returns:
Type
Promise

(private) insertGroup_(selectedStreamsnon-null, drmInfo, durationnullable) → (non-null) {Promise.<number>}

Inserts a group of streams into the database.
Parameters:
Name Type Attributes Description
selectedStreams Array.<!shaka.media.StreamInfo> The streams to insert.
drmInfo shaka.player.DrmInfo
duration number <nullable>
The duration of the entire stream.
Source:
Returns:
The unique id assigned to the group.
Type
Promise.<number>

isLive()

Inherited From:
Source:

isOffline()

Overrides:
Source:

load()

Overrides:
Source:

(private) onAllStreamsStarted_(timestampCorrectionsnon-null)

Called when each Stream has completed startup. Computes a global timestamp correction and immediately applies it to the initial set of SegmentIndexes and then begins playback. In parallel, creates/fetches all SegmentIndexes and fetches all initialization segments.
Parameters:
Name Type Description
timestampCorrections Array.<number> The initial set of streams' timestamp corrections.
Inherited From:
Source:

(private) onBandwidth_(eventnon-null)

Bandwidth statistics update callback.
Parameters:
Name Type Description
event Event
Inherited From:
Source:

(private) onBufferingEnd_(eventnon-null)

The buffering end event callback.
Parameters:
Name Type Description
event Event
Inherited From:
Source:

(private) onBufferingStart_(eventnon-null)

The buffering start event callback.
Parameters:
Name Type Description
event Event
Inherited From:
Source:

onKeyStatusesChange()

Inherited From:
Source:

(private) onMediaSourceOpen_(eventnon-null)

Called when the MediaSource transitions into the 'open' state. Only called after load() has been called.
Parameters:
Name Type Description
event Event
Inherited From:
Source:

(private) onSeeking_(eventnon-null)

Video seeking callback.
Parameters:
Name Type Description
event Event
Inherited From:
Source:

(private) onSessionReady_(event)

Event handler for sessionReady events.
Parameters:
Name Type Description
event Event A sessionReady event.
Source:

(private) onStreamEnded_(eventnon-null)

Stream ended callback.
Parameters:
Name Type Description
event Event
Inherited From:
Source:

(protected) onUpdateLocalManifest() → (non-null) {Promise.<!shaka.media.ManifestInfo>}

Update local manifest hook. The caller takes ownership of the returned manifest. This CANNOT return this.manifestInfo.
Inherited From:
Source:
Returns:
Type
Promise.<!shaka.media.ManifestInfo>

(protected) onUpdateManifest(urlnon-null) → (non-null) {Promise.<!shaka.media.ManifestInfo>}

Update manifest hook. The caller takes ownership of the returned manifest.
Parameters:
Name Type Description
url shaka.util.FailoverUri
Inherited From:
Source:
Returns:
Type
Promise.<!shaka.media.ManifestInfo>

(private) onUpdateManifest_(useLocal)

Updates the manifest.
Parameters:
Name Type Description
useLocal boolean Whether to update using the local manifest.
Inherited From:
Source:

(private) onUpdateSeekRange_()

Computes a new seek range and fires a 'seekrangechanged' event. Also clamps the playhead to the seek start time during playback.
Inherited From:
Source:

(private) processDeferredSwitches_()

Processes all deferred switches.
Inherited From:
Source:

(private) reconstructManifestInfo_(indexesnon-null, duration, config) → (non-null) {shaka.media.ManifestInfo}

Reconstructs a ManifestInfo object with data from storage.
Parameters:
Name Type Description
indexes Array.<shaka.util.ContentDatabase.StreamIndex> The indexes of the streams in this manifest.
duration number The max stream's entire duration in the group.
config shaka.player.DrmInfo.Config The config info loaded from storage.
Source:
Returns:
Type
shaka.media.ManifestInfo

(private) recursiveDispatch_(eventnon-null) → {boolean}

Dispatches an event recursively without changing its original target.
Parameters:
Name Type Description
event Event
Inherited From:
Source:
Returns:
True if the default action was prevented.
Type
boolean

removeEventListener(type, listener, opt_capturingopt)

Remove an event listener from this object.
Parameters:
Name Type Attributes Description
type string The event type for which you wish to remove a listener.
listener shaka.util.FakeEventTarget.ListenerType The callback or listener object to remove.
opt_capturing boolean <optional>
True to remove a listener for the capturing phase, false to remove a listener for the bubbling phase. Note that FakeEventTarget does not support the capturing phase from the standard event model.
Inherited From:
Source:

(private) removeStream_(streamInfonon-null)

Removes the given StreamInfo. Handles removing an active stream.
Parameters:
Name Type Description
streamInfo shaka.media.StreamInfo
Inherited From:
Source:

selectAudioTrack()

Inherited From:
Source:

selectConfigurations()

Inherited From:
Source:

(private) selectStreamInfos_(streamSetInfosnon-null) → (non-null) {Object.<string, !shaka.media.StreamInfo>}

Selects the initial StreamInfos from the given StreamSetsInfos.
Parameters:
Name Type Description
streamSetInfos Array.<!shaka.media.StreamSetInfo>
Inherited From:
Source:
Returns:
Type
Object.<string, !shaka.media.StreamInfo>

selectTextTrack()

Inherited From:
Source:

(private) selectTrack_(type, id, clearBuffer, opt_clearBufferOffsetopt) → {boolean}

Select a track by ID.
Parameters:
Name Type Attributes Description
type string The type of track to change, such as 'video', 'audio', or 'text'.
id number The |uniqueId| field of the desired StreamInfo.
clearBuffer boolean
opt_clearBufferOffset number <optional>
if |clearBuffer| and |opt_clearBufferOffset| are truthy, clear the stream buffer from the offset (in front of video currentTime) to the end of the stream.
Inherited From:
Source:
Returns:
True on success.
Type
boolean

selectVideoTrack()

Inherited From:
Source:

setNetworkCallback(callbacknon-null)

Sets the callback used to intercept the URL in network requests.
Parameters:
Name Type Description
callback shaka.util.FailoverUri.NetworkCallback
Source:

setPlaybackStartTime()

Inherited From:
Source:

(private) setSeekRangeTimer_()

Sets the seek range timer.
Inherited From:
Source:

(private) setUpdateLocalManifest_()

Sets the update timer to updated the manifest using the local copy.
Inherited From:
Source:

(private) setUpdateTimer_(offset)

Sets the update timer. Does nothing if the manifest does not specify an update period.
Parameters:
Name Type Description
offset number An offset, in seconds, to apply to the manifest's update period.
Inherited From:
Source:

(private) setUpMediaSource_(streamLimits)

Sets the MediaSource's duration and the SourceBuffers' append windows. Before calling this function, the MediaSource must be in the 'open' state. This function may be called any number of times.
Parameters:
Name Type Description
streamLimits {start: number, end: number, last: number} The current stream limits.
Inherited From:
Source:

(private) sortByLanguage_(streamSetsnon-null)

Move the best language match to the front of the array.
Parameters:
Name Type Description
streamSets Array.<!shaka.media.StreamSetInfo>
Inherited From:
Source:

(private) startStreams_(streamInfosByTypenon-null, streamLimits)

Starts each Stream.
Parameters:
Name Type Description
streamInfosByType Object.<string, !shaka.media.StreamInfo>
streamLimits {start: number, end: number, last: number} The initial stream limits.
Inherited From:
Source:

store(mpdUrl, preferredLanguage, interpretContentProtectionnullable, chooseTracks) → (non-null) {Promise.<number>}

Stores the content described by the MPD for offline playback.
Parameters:
Name Type Attributes Description
mpdUrl string The MPD URL.
preferredLanguage string The user's preferred language tag.
interpretContentProtection shaka.player.DashVideoSource.ContentProtectionCallback <nullable>
A callback to interpret the ContentProtection elements in the MPD.
chooseTracks shaka.player.OfflineVideoSource.ChooseTracksCallback
Source:
Returns:
The group ID of the stored content.
Type
Promise.<number>

Type Definitions

ChooseTracksCallback

A callback to the application to choose the tracks which will be stored offline. Returns a Promise to an array of track IDs. This uses Promises so that the application can, if it chooses, display some dialog to the user to drive the choice of tracks.
Type:
  • function(): !Promise.<!Array.<number>>
Source: