Class: shaka.text.TextEngine

Manages text parsers and cues.

Constructor

new TextEngine(displayer)

Manages text parsers and cues.

Parameters:
Name Type Description
displayer shaka.extern.TextDisplayer
Implements:
Source:

Members

parserMap_ :Object.<string, !shaka.extern.TextParserPlugin>

Type:
Source:

appendWindowEnd_ :number

Type:
  • number
Source:

appendWindowStart_ :number

Type:
  • number
Source:

bufferEnd_ :number

Type:
  • number
Source:

bufferStart_ :number

Type:
  • number
Source:

closedCaptionsMap_ :Map.<string, !Map.<string, !Array.<shaka.text.Cue>>>

The closed captions map stores the CEA closed captions by closed captions id and start and end time. It's used as the buffer of closed caption text streams, to show captions when we start displaying captions or switch caption tracks, we need to be able to get the cues for the other language and display them without re-fetching the video segments they were embedded in. Structure of closed caption map: closed caption id -> {start and end time -> cues}
Type:
Source:

segmentRelativeVttTiming_ :boolean

Type:
  • boolean
Source:

selectedClosedCaptionId_ :string

Type:
  • string
Source:

timestampOffset_ :number

Type:
  • number
Source:

Methods

isTypeSupported(mimeType) → {boolean}

Parameters:
Name Type Description
mimeType string
Source:
Returns:
Type
boolean

registerParser(mimeType, pluginnon-null)

Parameters:
Name Type Description
mimeType string
plugin shaka.extern.TextParserPlugin
Source:

unregisterParser(mimeType)

Parameters:
Name Type Description
mimeType string
Source:

appendBuffer(buffer, startTimenullable, endTimenullable, uriopt, nullable) → {Promise}

Parameters:
Name Type Attributes Description
buffer BufferSource
startTime number <nullable>
relative to the start of the presentation
endTime number <nullable>
relative to the start of the presentation
uri string <optional>
<nullable>
Source:
Returns:
Type
Promise

applyVideoTimestampOffsetRecursive_(cuenon-null, videoTimestampOffset)

Parameters:
Name Type Description
cue shaka.text.Cue the cue to apply the timestamp to recursively
videoTimestampOffset number the timestamp offset of the video
Source:

bufferedAheadOf(t) → {number}

Parameters:
Name Type Description
t number A timestamp
Source:
Returns:
Number of seconds ahead of 't' we have buffered
Type
number

bufferEnd() → {number}

Source:
Returns:
Time in seconds of the end of the buffered range, or null if nothing is buffered.
Type
number

bufferStart() → {number}

Source:
Returns:
Time in seconds of the beginning of the buffered range, or null if nothing is buffered.
Type
number

convertMuxjsCaptionsToShakaCaptions(closedCaptionsnon-null) → {Array.<!shaka.cea.ICaptionDecoder.ClosedCaption>}

Parameters:
Name Type Description
closedCaptions Array.<muxjs.mp4.ClosedCaption>
Source:
Returns:
Type
Array.<!shaka.cea.ICaptionDecoder.ClosedCaption>

destroy() → {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

getNumberOfClosedCaptionChannels() → {number}

Get the number of closed caption channels. This function is for TESTING ONLY. DO NOT USE in the library.
Source:
Returns:
Type
number

getNumberOfClosedCaptionsInChannel(channelId) → {number}

Get the number of closed caption cues for a given channel. If there is no channel for the given channel id, this will return 0. This function is for TESTING ONLY. DO NOT USE in the library.
Parameters:
Name Type Description
channelId string
Source:
Returns:
Type
number

initParser(mimeType, sequenceMode, segmentRelativeVttTiming)

Initialize the parser. This can be called multiple times, but must be called at least once before appendBuffer.
Parameters:
Name Type Description
mimeType string
sequenceMode boolean
segmentRelativeVttTiming boolean
Source:

isBuffered(t) → {boolean}

Parameters:
Name Type Description
t number A timestamp
Source:
Returns:
Type
boolean

remove(startTime, endTime) → {Promise}

Parameters:
Name Type Description
startTime number relative to the start of the presentation
endTime number relative to the start of the presentation
Source:
Returns:
Type
Promise

setAppendWindow(appendWindowStart, appendWindowEnd)

Parameters:
Name Type Description
appendWindowStart number
appendWindowEnd number
Source:

setDisplayer(displayernon-null)

Parameters:
Name Type Description
displayer shaka.extern.TextDisplayer
Source:

setSelectedClosedCaptionId(id, bufferEndTime)

Set the selected closed captions id. Append the cues stored in the closed captions map until buffer end time. This is to fill the gap between buffered and unbuffered captions, and to avoid duplicates that would be caused by any future video segments parsed for captions.
Parameters:
Name Type Description
id string
bufferEndTime number Load any stored cues up to this time.
Source:

setTimestampOffset(timestampOffset)

Parameters:
Name Type Description
timestampOffset number
Source:

storeAndAppendClosedCaptions(closedCaptionsnon-null, startTimenullable, endTimenullable, videoTimestampOffset)

Store the closed captions in the text engine, and append the cues to the text displayer. This is a side-channel used for embedded text only.
Parameters:
Name Type Attributes Description
closedCaptions Array.<!shaka.cea.ICaptionDecoder.ClosedCaption>
startTime number <nullable>
relative to the start of the presentation
endTime number <nullable>
relative to the start of the presentation
videoTimestampOffset number the timestamp offset of the video stream in which these captions were embedded
Source: