What is a subtitle style store?
ISubtitleStyleStore is a contract for persisting and restoring the user’s subtitle style preferences across page reloads.
The player does not wire one in: player.subtitleStyle() keeps the style in memory and emits the subtitleStyle event, and persistence is left to the consumer.
StorageBackedSubtitleStyleStore is an exported reference implementation that uses the core’s IStorage adapter (so the storage backend is swappable); you call it from your own code.
ISubtitleStyleStore interface
import type { ISubtitleStyleStore } from '@nomercy-entertainment/nomercy-video-player';
| Method | Signature | Description |
|---|---|---|
load() | () => Promise<Partial<SubtitleStyle> | null> | Load the persisted style. Returns null when no preference has been saved |
save(style) | (style: SubtitleStyle) => Promise<void> | Persist the full merged style. Call this from your own subtitleStyle event listener |
clear() | () => Promise<void> | Clear persisted preferences (e.g. “reset to defaults”) |
How to wire it
The player never calls these methods for you, so wire the store yourself:
load(): call once afterready()and apply the result withplayer.subtitleStyle(style).save(style): call from asubtitleStyleevent listener so each change is persisted.clear(): call from a “Reset subtitle preferences” control in your settings screen.
SubtitleStyle
SubtitleStyle is defined in @nomercy-entertainment/nomercy-player-core and covers all user-facing subtitle appearance options:
| Field | Type | Description |
|---|---|---|
fontFamily | string | CSS font-family string |
fontSize | number | Scale percentage (100 = default size) |
textColor | string | CSS color string for subtitle text |
textOpacity | number | 0–100 opacity for text |
backgroundColor | string | CSS color string for text background |
backgroundOpacity | number | 0–100 opacity for text background |
edgeStyle | string | Text shadow style: 'none', 'dropShadow', 'raised', 'depressed', 'uniform', 'textShadow' |
areaColor | string | CSS color string for the subtitle area background |
windowOpacity | number | 0–100 opacity for the area background |
Reading and writing style
// Read current style
const style = player.subtitleStyle();
// Merge a partial update; emits the 'subtitleStyle' event
player.subtitleStyle({
fontSize: 120,
textColor: 'yellow',
});
The 'subtitleStyle' event fires after each update, carrying the new full style.
The SubtitleOverlayPlugin subscribes to this event to repaint active cue areas immediately.