Fix SRT subtitle conversion and default selection
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user