fix(ios): handle async player access in text track selection (#4293)

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

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

This reverts commit 447c83423cdd77b0cfa9cc171b231327a2cf1586.

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

* fix: linter

* fix: linter formatting

* fix: revert typo
This commit is contained in:
Tarık 2024-11-22 14:19:09 +01:00 committed by GitHub
parent d934f214f5
commit daaac9740a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -967,10 +967,16 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
guard let source = _source else { return } guard let source = _source else { return }
if !source.textTracks.isEmpty { // sideloaded text tracks if !source.textTracks.isEmpty { // sideloaded text tracks
RCTPlayerOperations.setSideloadedText(player: _player, textTracks: source.textTracks, criteria: _selectedTextTrackCriteria) RCTPlayerOperations.setSideloadedText(player: _player, textTracks: source.textTracks, criteria: _selectedTextTrackCriteria)
} else { // text tracks included in the HLS playlist§ } else { // text tracks included in the HLS playlist
Task { Task { [weak self] in
await RCTPlayerOperations.setMediaSelectionTrackForCharacteristic(player: _player, characteristic: AVMediaCharacteristic.legible, guard let self,
criteria: _selectedTextTrackCriteria) let player = self._player else { return }
await RCTPlayerOperations.setMediaSelectionTrackForCharacteristic(
player: player,
characteristic: .legible,
criteria: self._selectedTextTrackCriteria
)
} }
} }
} }