feat(overlay): add optional subtitle selection modal

- Add primary and secondary mpv track selection from the overlay
- Support configurable sequence shortcuts with conflict detection and hot reload
- Document settings, shortcuts, and generated config defaults
This commit is contained in:
2026-09-21 21:32:41 -07:00
parent 1508863dbb
commit ca673735ba
54 changed files with 1397 additions and 52 deletions
+33
View File
@@ -0,0 +1,33 @@
export interface SubtitleSelectionState {
mediaPath: string;
tracks: { id: number; label: string }[];
primary: number | null;
secondary: number | null;
}
export type SubtitleSelectionRequest = Pick<
SubtitleSelectionState,
'mediaPath' | 'primary' | 'secondary'
>;
export function parseSubtitleSelectionRequest(value: unknown): SubtitleSelectionRequest {
if (
typeof value !== 'object' ||
value === null ||
!('mediaPath' in value) ||
typeof value.mediaPath !== 'string' ||
!value.mediaPath ||
!('primary' in value) ||
!isTrackSelection(value.primary) ||
!('secondary' in value) ||
!isTrackSelection(value.secondary)
)
throw new Error('Invalid subtitle selection.');
if (value.primary !== null && value.primary === value.secondary)
throw new Error('Choose different primary and secondary tracks.');
return { mediaPath: value.mediaPath, primary: value.primary, secondary: value.secondary };
}
function isTrackSelection(value: unknown): value is number | null {
return value === null || (typeof value === 'number' && Number.isSafeInteger(value) && value > 0);
}