Constructor
new TextEngine(displayer)
Manages text parsers and cues.
Parameters:
- Implements:
- Source:
Members
(private) appendWindowEnd_ :number
Type:
- Source:
(private) appendWindowStart_ :number
Type:
- Source:
(private, nullable) bufferEnd_ :number
Type:
- Source:
(private, nullable) bufferStart_ :number
Type:
- Source:
(private) closedCaptionsMap_ :Map.<string, Map.<string, Array.<Object>>>
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:
-
Map.<string, Map.<string, Array.<Object>>>
- Source:
(private) selectedClosedCaptionId_ :string
Type:
- Source:
(private) timestampOffset_ :number
Type:
- Source:
Methods
(static) isTypeSupported(mimeType) → {boolean}
Parameters:
Name |
Type |
Description |
mimeType |
string
|
|
- Source:
Returns:
-
Type
-
boolean
(export, static) registerParser(mimeType, pluginnon-null)
Parameters:
- 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
(export) appendCues(cuesnon-null)
Append cues to text displayer.
Parameters:
- 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() → (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
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:
(export) setDisplayer(displayer)
Parameters:
- Source:
(export) 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)
Store the closed captions in the text engine, and append the cues to
the text displayer.
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 |
- Source: