Constructor
new VttTextParser()
Constructs a VTT parser.
- Implements:
- Source:
Members
MPEG_TIMESCALE_ :number
Type:
- Source:
REGEX_ALIGN_ :RegExp
@const
Type:
- Source:
REGEX_LINE_NUM_ :RegExp
@const
Type:
- Source:
REGEX_LINE_PCT_ :RegExp
@const
Type:
- Source:
REGEX_NOTE_ :RegExp
@const
Type:
- Source:
REGEX_POSITION_ :RegExp
@const
Type:
- Source:
REGEX_REGION_ :RegExp
@const
Type:
- Source:
REGEX_SIZE_ :RegExp
@const
Type:
- Source:
REGEX_VERTICAL_ :RegExp
@const
Type:
- Source:
TS_ROLLOVER_ :number
At this value, timestamps roll over in TS content.
Type:
- Source:
manifestType_ :string
Type:
- Source:
Methods
firstCueStartTime_(cueBlocksnon-null) → {number}
Parameters:
| Name |
Type |
Description |
cueBlocks |
Array<string>
|
|
- Source:
Returns:
The start time of the first cue, in cue time.
-
Type
-
number
isRegionBlock_(linesnon-null) → {boolean}
Parameters:
| Name |
Type |
Description |
lines |
Array<string>
|
|
- Source:
Returns:
True if the block is a REGION definition block.
-
Type
-
boolean
parseCue_(textnon-null, timeOffset, regionsnon-null, stylesnon-null) → {shaka.text.Cue}
Parses a text block into a Cue object.
Parameters:
- Source:
Returns:
-
Type
-
shaka.text.Cue
parseCueSetting(cuenon-null, word, regionsnon-null) → {boolean}
Parses a WebVTT setting from the given word.
Parameters:
- Source:
Returns:
True on success.
-
Type
-
boolean
parseCueSettings(cuenon-null, parsernon-null, regionsnon-null)
Parses all the WebVTT settings of a cue.
Parameters:
- Source:
parsedLineValueAndInterpretation_(cuenon-null, word) → {boolean}
Parameters:
- Source:
Returns:
-
Type
-
boolean
parseLegacyRegions_(headerBlock) → {Array<!shaka.text.CueRegion>}
Parses the regions defined with the syntax of early WebVTT drafts, as
header lines like:
Region: id=fred width=50% lines=3 regionanchor=0%,100%
viewportanchor=10%,90% scroll=up
Parameters:
| Name |
Type |
Description |
headerBlock |
string
|
|
- Source:
Returns:
-
Type
-
Array<!shaka.text.CueRegion>
parsePercentage_(value) → {number}
Parses a WebVTT percentage, such as "12.5%".
See https://www.w3.org/TR/webvtt1/#parse-a-percentage-string
Parameters:
| Name |
Type |
Description |
value |
string
|
|
- Source:
Returns:
A number between 0 and 100, or null if invalid.
-
Type
-
number
parsePercentagePair_(value) → {Array<number>}
Parses two comma separated WebVTT percentages, such as "10%,90%".
Parameters:
| Name |
Type |
Description |
value |
string
|
|
- Source:
Returns:
-
Type
-
Array<number>
Parses a REGION definition block:
REGION
id:fred
width:40%
lines:3
regionanchor:0%,100%
viewportanchor:10%,90%
scroll:up
Parameters:
| Name |
Type |
Description |
lines |
Array<string>
|
|
- Source:
Returns:
-
Type
-
shaka.text.CueRegion
Parses the region definitions of a WebVTT header: everything before the
first cue, such as the contents of the WebVTTConfigurationBox of WebVTT in
MP4.
Parameters:
| Name |
Type |
Description |
header |
string
|
|
- Source:
Returns:
-
Type
-
Array<!shaka.text.CueRegion>
parseRegionSetting_(regionnon-null, word, separator) → {boolean}
Parses a WebVTTRegion setting from the given word.
Parameters:
| Name |
Type |
Description |
region |
shaka.text.CueRegion
|
|
word |
string
|
|
separator |
string
|
The separator between the name and the value. |
- Source:
Returns:
True on success.
-
Type
-
boolean
parseRegionSettings_(settings, separator) → {shaka.text.CueRegion}
Parses a list of region settings into a Region object.
See https://www.w3.org/TR/webvtt1/#collect-webvtt-region-settings
Parameters:
| Name |
Type |
Description |
settings |
string
|
|
separator |
string
|
The separator between the name and the value of
each setting. |
- Source:
Returns:
-
Type
-
shaka.text.CueRegion
parseStyle_(textnon-null, stylesnon-null)
Parses a style block into a Cue object.
Parameters:
| Name |
Type |
Description |
text |
Array<string>
|
|
styles |
Map<string, !shaka.text.Cue>
|
|
- Source:
setPositionAlign_(cuenon-null, align)
Parameters:
- Source:
setTextAlign_(cuenon-null, align)
Parameters:
- Source:
setVerticalWritingMode_(cuenon-null, value)
Parameters:
- Source:
computeHlsOffset_(headerBlock, time, cueBlocksnon-null) → {number}
Parameters:
- Source:
Returns:
-
Type
-
number
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:
Parse a media segment and return the cues that make up the segment.
Parameters:
| Name |
Type |
Attributes |
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. |
uri |
string
|
undefined
|
<nullable>
|
The media uri. |
images |
Array<string>
|
|
|
- Implements:
- Source:
Returns:
-
Type
-
Array<!shaka.text.Cue>
setManifestType(manifestType)
Notifies the manifest type.
Parameters:
| Name |
Type |
Description |
manifestType |
string
|
|
- Implements:
- Source: