Class: shaka.media.TextStream

Constructor

new TextStream(parentnon-null, videonon-null)

Creates a TextStream, which presents subtitles via an HTMLVideoElement's built-in subtitles support.
Parameters:
Name Type Description
parent shaka.util.FakeEventTarget The parent for event bubbling.
video HTMLVideoElement The video element.
Implements:
Extends:
Source:
Fires:

Members

(private) enabled_ :boolean

Type:
  • boolean
Source:

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

Type:
Inherited From:
Source:

(protected) parent :shaka.util.FakeEventTarget

Type:
Inherited From:
Source:

(private) segmentIndex_ :shaka.media.SegmentIndex

Type:
Source:

(private, non-null) startedPromise_ :shaka.util.PublicPromise

Type:
Source:

(private) streamInfo_ :shaka.media.StreamInfo

Type:
Source:

(private) track_ :HTMLTrackElement

Type:
  • HTMLTrackElement
Source:

(private, non-null) video_ :HTMLVideoElement

Type:
  • HTMLVideoElement
Source:

Methods

(private, static) createAdaptationEvent_(streamInfonon-null) → (non-null) {Event}

Creates an event object for an AdaptationEvent using the given StreamInfo.
Parameters:
Name Type Description
streamInfo shaka.media.StreamInfo
Source:
Returns:
Type
Event

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:

configure(confignon-null)

Configures the Stream options. Options are set via key-value pairs.
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.
Implements:
Source:

destroy()

Destroys the Stream.
Implements:
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

getEnabled() → {boolean}

Implements:
Source:
Returns:
True if the stream is enabled; otherwise, return false.
Type
boolean

getSegmentIndex() → {shaka.media.SegmentIndex}

Gets the SegmentIndex of the StreamInfo that corresponds to the stream that is currently being processed or presented. Note that this SegmentIndex may be different than the SegmentIndex of the last StreamInfo that was passed to switch() (see shaka.media.IStream#switch).
Implements:
Source:
Returns:
Type
shaka.media.SegmentIndex

getStreamInfo() → {shaka.media.StreamInfo}

Gets the StreamInfo that corresponds to the stream that is currently being processed or presented. Note that this StreamInfo may be different than the last StreamInfo that was passed to switch() (see shaka.media.IStream#switch).
Implements:
Source:
Returns:
Type
shaka.media.StreamInfo

hasEnded() → {boolean}

Always returns true since text streams are not segmented.
Implements:
Source:
Returns:
True if the stream has ended; otherwise, return false.
Type
boolean

isBuffered(time) → {boolean}

Returns true since text streams don't need to buffer.
Parameters:
Name Type Description
time number The time in seconds to check.
Implements:
Source:
Returns:
Type
boolean

(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:

resync()

Does nothing since text streams do not require manual resynchronization.
Implements:
Source:

setEnabled(enabled)

Enables or disables stream presentation or does nothing if the Stream cannot disable stream presentation.
Parameters:
Name Type Description
enabled boolean
Implements:
Source:

started(proceednon-null) → (non-null) {Promise.<number>}

Returns a Promise that the Stream will resolve after it has begun presenting its first text stream. The Stream will never reject the returned Promise.
Parameters:
Name Type Description
proceed Promise A Promise that the caller must resolve after startup completes to signal the Stream that it can proceed. The Stream will idle while in the 'waiting' state. Callers must never reject |proceed|.
Implements:
Source:
Returns:
A promise to a timestamp correction, which is the number of seconds that the media timeline (the sequence of timestamps in the stream's media segments) is offset from the Stream's initial StreamInfo's SegmentIndex (which is an approximation of the stream's media timeline). For example, if the timestamp correction is 5 then a SegmentReference that has a start time of 10 would correspond to a segment that actually starts at 15. For well formed content, the absolute value of the timestamp correction should be small, specifically, less than the duration of any one segment in the stream.
Type
Promise.<number>

switch(streamInfonon-null, clearBuffer, opt_clearBufferOffsetopt)

Starts presenting the specified stream asynchronously. Note: |clearBuffer| and |opt_clearBufferOffset| are ignored.
Parameters:
Name Type Attributes Description
streamInfo shaka.media.StreamInfo
clearBuffer boolean If true, removes the previous stream's content before switching to the new stream.
opt_clearBufferOffset number <optional>
if |clearBuffer| and |opt_clearBufferOffset| are truthy, clear the stream buffer from the given offset (relative to the Stream's current position) to the end of the stream.
Implements:
Source: