Skip to content

Commit

Permalink
fix(ios): handle async player access in text track selection (#4293)
Browse files Browse the repository at this point in the history
* fix(ios): add null check to setSelectedTextTrack for player instance

* Revert "fix(ios): add null check to setSelectedTextTrack for player instance"

This reverts commit 447c834.

* fix(ios): ensure strong reference to player during async operation

* fix: linter

* fix: linter formatting

* fix: revert typo
  • Loading branch information
tarikfp authored Nov 22, 2024
1 parent d934f21 commit daaac97
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ios/Video/RCTVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -967,10 +967,16 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
guard let source = _source else { return }
if !source.textTracks.isEmpty { // sideloaded text tracks
RCTPlayerOperations.setSideloadedText(player: _player, textTracks: source.textTracks, criteria: _selectedTextTrackCriteria)
} else { // text tracks included in the HLS playlist§
Task {
await RCTPlayerOperations.setMediaSelectionTrackForCharacteristic(player: _player, characteristic: AVMediaCharacteristic.legible,
criteria: _selectedTextTrackCriteria)
} else { // text tracks included in the HLS playlist
Task { [weak self] in
guard let self,
let player = self._player else { return }

await RCTPlayerOperations.setMediaSelectionTrackForCharacteristic(
player: player,
characteristic: .legible,
criteria: self._selectedTextTrackCriteria
)
}
}
}
Expand Down

0 comments on commit daaac97

Please sign in to comment.