Fix SRT subtitle conversion and default selection

This commit is contained in:
Mert Uyanık
2025-10-29 14:22:08 +03:00
parent c5efcb95d5
commit a508919d20
2 changed files with 71 additions and 26 deletions
+22
View File
@@ -265,6 +265,28 @@ export const VideoElement: React.FC<VideoElementProps> = ({
}
}, [subtitles])
useEffect(() => {
const video = videoRef.current
if (!video) return
if (processedSubtitles.length === 0) return
if (settings.subtitle) return
const defaultSubtitle = processedSubtitles.find((subtitle) => subtitle.default)
if (!defaultSubtitle) return
const tracks = video.textTracks
if (!tracks || tracks.length === 0) return
for (let i = 0; i < tracks.length; i++) {
const track = tracks[i]
if (track.language === defaultSubtitle.lang) {
track.mode = 'showing'
setSubtitle(defaultSubtitle)
break
}
}
}, [processedSubtitles, settings.subtitle, setSubtitle, videoRef])
// Detect HLS source and load hls.js if needed
useEffect(() => {
const video = videoRef.current