From daaac9740aed1858b7ababae0ec8b08274130a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tar=C4=B1k?= <61876765+tarikfp@users.noreply.github.com> Date: Fri, 22 Nov 2024 14:19:09 +0100 Subject: [PATCH] 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 --- ios/Video/RCTVideo.swift | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 0701067f..5b17b08b 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -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 + ) } } }