fix(ios): ensure we don't disable tracks when not necessary (causes black screen) (#4130)

This commit is contained in:
Olivier Bouillet 2024-09-02 19:08:27 +02:00 committed by GitHub
parent fbe570d62f
commit 89df9d69ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -15,11 +15,15 @@ enum RCTPlayerOperations {
let trackCount: Int! = player?.currentItem?.tracks.count ?? 0 let trackCount: Int! = player?.currentItem?.tracks.count ?? 0
// The first few tracks will be audio & video track // The first few tracks will be audio & video track
var firstTextIndex = 0 var firstTextIndex = -1
for i in 0 ..< trackCount where player?.currentItem?.tracks[i].assetTrack?.hasMediaCharacteristic(.legible) ?? false { for i in 0 ..< trackCount where player?.currentItem?.tracks[i].assetTrack?.hasMediaCharacteristic(.legible) ?? false {
firstTextIndex = i firstTextIndex = i
break break
} }
if firstTextIndex == -1 {
// no sideLoaded text track available (can happen with invalid vtt url)
return
}
var selectedTrackIndex: Int = RCTVideoUnset var selectedTrackIndex: Int = RCTVideoUnset

View File

@ -613,6 +613,10 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
textTracks: self._textTracks textTracks: self._textTracks
) )
if validTextTracks.isEmpty {
DebugLog("Strange state, not valid textTrack")
}
if validTextTracks.count != self._textTracks.count { if validTextTracks.count != self._textTracks.count {
self.setTextTracks(validTextTracks) self.setTextTracks(validTextTracks)
} }