Class: shaka.text.TtmlTextParser

Constructor

new TtmlTextParser()

Implements:
Source:

Classes

RateInfo_

Members

(private, static, constant, non-null) percentValues_ :RegExp

Type:
  • RegExp
Source:
Example
50% 10%

(private, static, constant, non-null) pixelValues_ :RegExp

Type:
  • RegExp
Source:
Example
100px

(private, static, constant, non-null) textAlignToLineAlign_ :Object.<string, shaka.text.Cue.lineAlign>

Type:
Source:

(private, static, constant, non-null) textAlignToPositionAlign_ :Object.<string, shaka.text.Cue.positionAlign>

Type:
Source:

(private, static, constant, non-null) timeColonFormat_ :RegExp

Type:
  • RegExp
Source:
Example
00:00:40 or 00:40

(private, static, constant, non-null) timeColonFormatFrames_ :RegExp

Type:
  • RegExp
Source:
Example
00:00:40:07 (7 frames) or 00:00:40:07.1 (7 frames, 1 subframe)

(private, static, constant, non-null) timeColonFormatMilliseconds_ :RegExp

Type:
  • RegExp
Source:
Example
01:02:43.0345555 or 02:43.03

(private, static, constant, non-null) timeFramesFormat_ :RegExp

Type:
  • RegExp
Source:
Example
75f or 75.5f

(private, static, constant, non-null) timeHMSFormat_ :RegExp

Type:
  • RegExp
Source:
Example
3.45h, 3m or 4.20s

(private, static, constant, non-null) timeTickFormat_ :RegExp

Type:
  • RegExp
Source:
Example
50t or 50.5t

(private, static, constant, non-null) unitValues_ :RegExp

Type:
  • RegExp
Source:
Example
100px

Methods

(private, static) addNewLines_(elementnon-null, whitespaceTrim)

Inserts \n where
tags are found.
Parameters:
Name Type Description
element Node
whitespaceTrim boolean
Source:

(private, static) addStyle_(cuenon-null, cueElementnon-null, region, stylesnon-null)

Adds applicable style properties to a cue.
Parameters:
Name Type Description
cue shaka.text.Cue
cueElement Element
region Element
styles Array.<!Element>
Source:

(private, static) addTextDecoration_(cuenon-null, decoration)

Parses text decoration values and adds/removes them to/from the cue.
Parameters:
Name Type Description
cue shaka.text.Cue
decoration string
Source:

(private, static) getElementFromCollection_(element, attributeName, collectionnon-null) → {Element}

Selects an item from |collection| whose id matches |attributeName| from |element|.
Parameters:
Name Type Description
element Element
attributeName string
collection Array.<Element>
Source:
Returns:
Type
Element

(private, static) getInheritedAttribute_(elementnon-null, attributeName) → (nullable) {string}

Traverses upwards from a given node until a given attribute is found.
Parameters:
Name Type Description
element Element
attributeName string
Source:
Returns:
Type
string

(private, static) getLeafNodes_(element) → (non-null) {Array.<!Element>}

Gets the leaf nodes of the xml node tree. Ignores the text, br elements and the spans positioned inside paragraphs
Parameters:
Name Type Description
element Element
Source:
Returns:
Type
Array.<!Element>

(private, static) getStyleAttribute_(cueElementnon-null, region, stylesnon-null, attribute) → (nullable) {string}

Finds a specified attribute on either the original cue element or its associated region and returns the value if the attribute was found.
Parameters:
Name Type Description
cueElement Element
region Element
styles Array.<!Element>
attribute string
Source:
Returns:
Type
string

(private, static) getStyleAttributeFromElement_(cueElementnon-null, stylesnon-null, attribute) → (nullable) {string}

Finds a specified attribute on the cue element and returns the value if the attribute was found.
Parameters:
Name Type Description
cueElement Element
styles Array.<!Element>
attribute string
Source:
Returns:
Type
string

(private, static) getStyleAttributeFromRegion_(region, stylesnon-null, attribute) → (nullable) {string}

Finds a specified attribute on the element's associated region and returns the value if the attribute was found.
Parameters:
Name Type Description
region Element
styles Array.<!Element>
attribute string
Source:
Returns:
Type
string

(private, static) parseColonTimeWithFrames_(rateInfonon-null, text) → (nullable) {number}

Parses a TTML colon formatted time containing frames.
Parameters:
Name Type Description
rateInfo shaka.text.TtmlTextParser.RateInfo_
text string
Source:
Returns:
Type
number

(private, static) parseCue_(cueElementnon-null, offset, rateInfonon-null, stylesnon-null, regionElementsnon-null, cueRegionsnon-null, whitespaceTrim) → {shaka.text.Cue}

Parses an Element into a TextTrackCue or VTTCue.
Parameters:
Name Type Description
cueElement Element
offset number
rateInfo shaka.text.TtmlTextParser.RateInfo_
styles Array.<!Element>
regionElements Array.<!Element>
cueRegions Array.<!shaka.text.CueRegion>
whitespaceTrim boolean
Source:
Returns:
Type
shaka.text.Cue

(private, static) parseCueRegion_(regionElementnon-null, stylesnon-null) → {shaka.text.CueRegion}

Parses an Element into a TextTrackCue or VTTCue.
Parameters:
Name Type Description
regionElement Element
styles Array.<!Element>
Source:
Returns:
Type
shaka.text.CueRegion

(private, static) parseFramesTime_(rateInfonon-null, text) → (nullable) {number}

Parses a TTML time in frame format.
Parameters:
Name Type Description
rateInfo shaka.text.TtmlTextParser.RateInfo_
text string
Source:
Returns:
Type
number

(private, static) parseTickTime_(rateInfonon-null, text) → (nullable) {number}

Parses a TTML time in tick format.
Parameters:
Name Type Description
rateInfo shaka.text.TtmlTextParser.RateInfo_
text string
Source:
Returns:
Type
number

(private, static) parseTime_(text, rateInfonon-null) → (nullable) {number}

Parses a TTML time from the given word.
Parameters:
Name Type Description
text string
rateInfo shaka.text.TtmlTextParser.RateInfo_
Source:
Returns:
Type
number

(private, static) parseTimeFromRegex_(regexnon-null, text) → (nullable) {number}

Parses a TTML time with a given regex. Expects regex to be some sort of a time-matcher to match hours, minutes, seconds and milliseconds
Parameters:
Name Type Description
regex RegExp
text string
Source:
Returns:
Type
number

(export) parseInit(datanon-null)

Parse an initialization segment. Some formats do not have init segments so this won't always be called.
Parameters:
Name Type Description
data Uint8Array The data that makes up the init segment.
Implements:
Source:

(export) parseMedia(datanon-null, timeContext) → (non-null) {Array.<!shaka.extern.Cue>}

Parse a media segment and return the cues that make up the segment.
Parameters:
Name Type Description
data Uint8Array The next section of buffer.
timeContext shaka.extern.TextParser.TimeContext The time information that should be used to adjust the times values for each cue.
Implements:
Source:
Returns:
Type
Array.<!shaka.extern.Cue>