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,
preferredTrackID: kCMPersistentTrackID_Invalid
) {
try compositionTextTrack.insertTimeRange(
CMTimeRange(start: .zero, duration: textTrack.timeRange.duration),
of: textTrack,
at: .zero
)
do {
try compositionTextTrack.insertTimeRange(
CMTimeRange(start: .zero, duration: textTrack.timeRange.duration),
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.isEnabled = true