From 8f1bdb7c36cb3b42925312b9a9952432f4735ba5 Mon Sep 17 00:00:00 2001 From: Bryan <65200903+brycnguyen@users.noreply.github.com> Date: Sun, 14 Jan 2024 22:31:22 -0800 Subject: [PATCH] Externally loaded text tracks not loading properly (#3461) * fix text tracks * keep map * use where * update change log * fix build error --- CHANGELOG.md | 1 + ios/Video/Features/RCTPlayerOperations.swift | 2 +- ios/Video/RCTVideo.swift | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a532c3b..d5027c63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,7 @@ ## Next - Android, iOS: add onVolumeChange event #3322 +- iOS: Externally loaded text tracks not loading properly [#3461](https://github.com/react-native-video/react-native-video/pull/3461) ### Version 6.0.0-alpha.9 - All: add built-in typescript support [#3266](https://github.com/react-native-video/react-native-video/pull/3266) diff --git a/ios/Video/Features/RCTPlayerOperations.swift b/ios/Video/Features/RCTPlayerOperations.swift index 9f7b66a5..809ea4ee 100644 --- a/ios/Video/Features/RCTPlayerOperations.swift +++ b/ios/Video/Features/RCTPlayerOperations.swift @@ -18,7 +18,7 @@ enum RCTPlayerOperations { // The first few tracks will be audio & video track var firstTextIndex = 0 - for i in 0 ..< trackCount where (player?.currentItem?.tracks[i].assetTrack?.hasMediaCharacteristic(.legible)) != nil { + for i in 0 ..< trackCount where player?.currentItem?.tracks[i].assetTrack?.hasMediaCharacteristic(.legible) ?? false { firstTextIndex = i break } diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 57f0f96f..c16dcfcd 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -1206,7 +1206,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH "orientation": orientation, ], "audioTracks": audioTracks, - "textTracks": textTracks.map(\.json), + "textTracks": self._textTracks?.compactMap { $0.json } ?? textTracks.map(\.json), "target": self.reactTag as Any]) } }