fix: video not loading when external subtitles are malformed (#4822)

This commit is contained in:
Kamil Moskała
2026-01-21 23:37:51 +01:00
committed by GitHub
parent 28e295a6ee
commit 86133e38cd
@@ -67,11 +67,18 @@ enum ExternalSubtitlesUtils {
withMediaType: .text, withMediaType: .text,
preferredTrackID: kCMPersistentTrackID_Invalid preferredTrackID: kCMPersistentTrackID_Invalid
) { ) {
try compositionTextTrack.insertTimeRange( do {
CMTimeRange(start: .zero, duration: textTrack.timeRange.duration), try compositionTextTrack.insertTimeRange(
of: textTrack, CMTimeRange(start: .zero, duration: textTrack.timeRange.duration),
at: .zero of: textTrack,
) at: .zero
)
} catch {
print(
"[ReactNativeVideo] Failed to insert text track into composition: \(error.localizedDescription). Language: \(textTrack.languageCode ?? "unknown"). Continuing without this subtitle track."
)
continue
}
compositionTextTrack.languageCode = textTrack.languageCode compositionTextTrack.languageCode = textTrack.languageCode
compositionTextTrack.isEnabled = true compositionTextTrack.isEnabled = true