- Version
- 1.0.0
- License
- MIT
- Requires
- DomSmith
- sanitize
- Source
- SubtitleRendererVTT.js, line 15
Constructor
new SubtitleRendererVTT(player, parent)
Members
private #config :SubtitleRendererVTT~SubtitleRendererVTTConfig
Configuration options for the SubtitleRendererVTT component.
- Type
- SubtitleRendererVTT~SubtitleRendererVTTConfig
- Source
- SubtitleRendererVTT.js, line 21
private #player :Object
The player instance that this renderer belongs to.
- Type
- Object
- Source
- SubtitleRendererVTT.js, line 29
private #linesHorMax :number
Maximum number of horizontal subtitle lines.
- Type
- number
- Source
- SubtitleRendererVTT.js, line 35
private #linesHorMap :Array<{isActive: boolean}>
Map of active horizontal lines. Tracks which lines are in use.
- Type
- Array<{isActive: boolean}>
- Source
- SubtitleRendererVTT.js, line 41
private #linesVertMax :number
Maximum number of vertical subtitle lines.
- Type
- number
- Source
- SubtitleRendererVTT.js, line 47
private #linesVertMap :Array<{isActive: boolean}>
Map of active vertical lines. Tracks which lines are in use.
- Type
- Array<{isActive: boolean}>
- Source
- SubtitleRendererVTT.js, line 53
private #dom :DomSmith
DomSmith instance to manage the structure of the subtitle elements.
- Type
- DomSmith
- Source
- SubtitleRendererVTT.js, line 59
private #currentCues :Map
A map containing all currently active subtitle cues.
- Type
- Map
- Source
- SubtitleRendererVTT.js, line 65
Methods
canRender(cue) → boolean
Checks if the subtitle cue has text to be rendered.
| Name | Type | Description |
|---|---|---|
cue |
Object |
The subtitle cue object. |
- Returns
-
True if the cue contains text, false otherwise.
- Type boolean
- Source
- SubtitleRendererVTT.js, line 109
render(cue, currentCues)
Renders a subtitle cue on the screen, positioning it based on various options.
| Name | Type | Description |
|---|---|---|
cue |
Object |
The subtitle cue to render. |
currentCues |
Map |
A map containing all currently active subtitle cues. |
- Source
- SubtitleRendererVTT.js, line 120
private #replaceOldestLine(cue, ele, isVertical)
Replaces the oldest subtitle line with a new one.
| Name | Type | Description |
|---|---|---|
cue |
Object |
The subtitle cue to replace. |
ele |
HTMLElement |
Element representing the subtitle. |
isVertical |
boolean |
Whether the subtitle is displayed vertically. |
- Source
- SubtitleRendererVTT.js, line 281
private #addLine(cue, index, ele, isVertical)
Adds a subtitle line to the grid.
| Name | Type | Description |
|---|---|---|
cue |
Object |
The subtitle cue object. |
index |
number |
The index of the current line. |
ele |
HTMLElement |
Element representing the subtitle. |
isVertical |
boolean |
Whether the subtitle is displayed vertically. |
- Source
- SubtitleRendererVTT.js, line 304
clear()
Clears the rendered subtitles and resets the line maps.
- Source
- SubtitleRendererVTT.js, line 334
remove(params)
Removes a subtitle line from the grid.
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
The parameters for removing a line.
|
- Source
- SubtitleRendererVTT.js, line 357
destroy()
This method removes all events, subscriptions and DOM nodes created by this component.
- Source
- SubtitleRendererVTT.js, line 369