- Version
- 1.0.0
- License
- MIT
- Requires
- Menu
- Source
- SubtitlesUi.js, line 12
Constructor
new SubtitlesUi(player, parent, optionsopt)
Creates an instance of the Subtitles UI component.
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
player |
Player |
Reference to the media player instance. |
|||||||||
parent |
Popup |
Reference to the parent instance (popup). |
|||||||||
options |
Object | optional |
Additional options.
|
Members
private #config :Object
UI-related configuration derived from the subtitles config.
- Type
- Object
- Source
- SubtitlesUi.js, line 18
private #player :Player
Reference to the main player instance.
- Type
- Player
- Source
- SubtitlesUi.js, line 29
private #parent :Object
Reference to the parent popup/controller.
- Type
- Object
- Source
- SubtitlesUi.js, line 35
private #apiKey :symbol
Secret key only known to the player instance and initialized components.
- Type
- symbol
- Source
- SubtitlesUi.js, line 41
private #menu :Menu
private #fontMenu :Menu
Reference to the font size menu (optional).
- Type
- Menu
- Source
- SubtitlesUi.js, line 53
private #tracks :Array
Available subtitle tracks (without the "off" entry).
- Type
- Array
- Source
- SubtitlesUi.js, line 59
private #currentIndex :number
Currently active subtitle index (-1 for off).
- Type
- number
- Source
- SubtitlesUi.js, line 65
private #fontSizes :Array<string>
Allowed font sizes.
- Type
- Array<string>
- Source
- SubtitlesUi.js, line 71
private #currentFontSize :string
Current font size.
- Type
- string
- Source
- SubtitlesUi.js, line 77
private #subscriptions :Array<number>
Holds tokens of subscriptions to player events, for later unsubscribe.
- Type
- Array<number>
- Source
- SubtitlesUi.js, line 83
Methods
private #onDataReady(data, topic)
Resets UI state and builds menu when new media data arrives.
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
data |
Object |
Event data.
|
||||||
topic |
string |
Event topic. |
- Listens
- data/ready
- data/update
- Source
- SubtitlesUi.js, line 154
private #onNoMedia()
Resets UI state when no media is available.
- Listens
- data/nomedia
- Source
- SubtitlesUi.js, line 179
private #onActive(data)
Handles active track notifications from the engine.
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
data |
Object |
Active payload.
|
- Listens
- subtitles/active
- Source
- SubtitlesUi.js, line 191
private #onMenuSelected(sel)
Handles subtitle menu selections.
| Name | Type | Description |
|---|---|---|
sel |
number |
Selected menu index (includes "off" at position 0). |
- Fires
- subtitles/selected
- Source
- SubtitlesUi.js, line 203
private #onFontSelected(index, item)
Handles font size menu selections.
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
index |
number |
Selected index. |
||||||
item |
Object |
Selected menu item.
|
- Fires
- subtitles/fontsize
- Source
- SubtitlesUi.js, line 223
private #createMenu()
Builds the menu entries based on current tracks.
- Source
- SubtitlesUi.js, line 233
private #setFontMenu(fontSize)
Syncs font menu UI selection.
| Name | Type | Description |
|---|---|---|
fontSize |
string |
The font size to select. |
- Source
- SubtitlesUi.js, line 252
private #resetMenus()
Resets menus to an empty state and restores font selection.
- Source
- SubtitlesUi.js, line 263
destroy()
Cleans up menus and subscriptions.
- Source
- SubtitlesUi.js, line 278