Skip to content

Commit

Permalink
fix(ios): ensure we don't disable tracks when not necessary (causes b…
Browse files Browse the repository at this point in the history
…lack screen) (#4130)
  • Loading branch information
freeboub committed Sep 2, 2024
1 parent fbe570d commit 89df9d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ios/Video/Features/RCTPlayerOperations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ enum RCTPlayerOperations {
let trackCount: Int! = player?.currentItem?.tracks.count ?? 0

// 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 {
firstTextIndex = i
break
}
if firstTextIndex == -1 {
// no sideLoaded text track available (can happen with invalid vtt url)
return
}

var selectedTrackIndex: Int = RCTVideoUnset

Expand Down
4 changes: 4 additions & 0 deletions ios/Video/RCTVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,10 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
textTracks: self._textTracks
)

if validTextTracks.isEmpty {
DebugLog("Strange state, not valid textTrack")
}

if validTextTracks.count != self._textTracks.count {
self.setTextTracks(validTextTracks)
}
Expand Down

0 comments on commit 89df9d6

Please sign in to comment.