Class: shaka.text.TextEngine

Constructor

new TextEngine(displayer)

Manages text parsers and cues.
Parameters:
Name Type Description
displayer shaka.extern.TextDisplayer
Implements:
Source:

Members

(private, static, non-null) parserMap_ :Object.<string, !shaka.extern.TextParserPlugin>

Type:
Source:

(private) appendWindowEnd_ :number

Type:
  • number
Source:

(private) appendWindowStart_ :number

Type:
  • number
Source:

(private, nullable) bufferEnd_ :number

Type:
  • number
Source:

(private, nullable) bufferStart_ :number

Type:
  • number
Source:

(private, non-null) 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:

(private) selectedClosedCaptionId_ :string

Type:
  • string
Source:

(private) timestampOffset_ :number

Type:
  • number
Source:

Methods

(static) isTypeSupported(mimeType) → {boolean}

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

(export, static) registerParser(mimeType, pluginnon-null)

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

(export, static) unregisterParser(mimeType)

Parameters:
Name Type Description
mimeType string
Source:

appendBuffer(buffernon-null, startTimenullable, endTimenullable) → (non-null) {Promise}

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

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() → (nullable) {number}

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

bufferStart() → (nullable) {number}

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

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

getStartTime(buffernon-null) → {number}

Parse the start time from the text media segment, if possible.
Parameters:
Name Type Description
buffer ArrayBuffer
Source:
Throws:
on failure
Type
shaka.util.Error
Returns:
Type
number

initParser(mimeType)

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

isBuffered(t) → {boolean}

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

remove(startTime, endTime) → (non-null) {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.<muxjs.mp4.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: