feat: multi-language subtitle support (SRT/VTT)

This commit is contained in:
Nice Try
2026-06-26 20:12:48 +00:00
parent 33e5e61b11
commit 7d0f976da0
6 changed files with 98 additions and 6 deletions
+28
View File
@@ -410,6 +410,18 @@ export function VideoPlayer({
}
}, [selectedSubtitle, subtitles])
const hasSubtitles = Boolean(subtitles && subtitles.length > 0)
const captionsEnabled = selectedSubtitle !== 'off'
const toggleCaptions = () => {
if (!hasSubtitles) return
if (captionsEnabled) {
setSelectedSubtitle('off')
return
}
const defaultIndex = subtitles?.findIndex(track => track.default) ?? -1
setSelectedSubtitle(defaultIndex >= 0 ? defaultIndex : 0)
}
return (
<div
className="video-player-container"
@@ -563,6 +575,22 @@ export function VideoPlayer({
/>
</div>
{hasSubtitles && (
<Button
variant="ghost"
size="icon"
className={cn(
'text-white hover:bg-white/20 font-bold text-xs',
captionsEnabled && 'bg-primary text-primary-foreground hover:bg-primary/90'
)}
onClick={toggleCaptions}
aria-label={captionsEnabled ? 'Turn captions off' : 'Turn captions on'}
title={captionsEnabled ? 'Captions on' : 'Captions off'}
>
CC
</Button>
)}
{/* Fullscreen - FIRST */}
<Button
variant="ghost"