- Version
- 1.1.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<*, {ele: HTMLElement, renderer: Object, line: (number|undefined), isVertical: (boolean|undefined), startTime: (number|undefined)}>
A map containing all currently active subtitle cues.
- Type
- Map<*, {ele: HTMLElement, renderer: Object, line: (number|undefined), isVertical: (boolean|undefined), startTime: (number|undefined)}>
- 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
update(activeCues)
Handles cue changes from the parent subtitles component. Adds new cues and removes cues that are no longer active.
| Name | Type | Description |
|---|---|---|
activeCues |
Array<VTTCue> |
List of currently active cues. |
- Source
- SubtitleRendererVTT.js, line 120
render(cue)
Renders a subtitle cue on the screen, positioning it based on various options.
| Name | Type | Description |
|---|---|---|
cue |
Object |
The subtitle cue to render. |
- Source
- SubtitleRendererVTT.js, line 140
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 298
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 322
private #removeCue(cue, infoopt)
Removes a cue from the DOM and internal state.
| Name | Type | Attributes | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
cue |
VTTCue |
Cue to remove. |
||||||||||
info |
Object | optional |
Stored cue info.
|
- Source
- SubtitleRendererVTT.js, line 356
clear()
Clears the rendered subtitles and resets the line maps.
- Source
- SubtitleRendererVTT.js, line 376
remove(params)
Removes a subtitle line from the grid.
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
The parameters for removing a line.
|
- Source
- SubtitleRendererVTT.js, line 404
destroy()
This method removes all events, subscriptions and DOM nodes created by this component.
- Source
- SubtitleRendererVTT.js, line 416