From ac0a9c3e3a4fec474a963207a343765d1776406d Mon Sep 17 00:00:00 2001 From: Dibyendu Das Date: Fri, 7 Jun 2024 08:04:00 -0400 Subject: [PATCH] fix(ios): Implicit use of 'self' in closure - use 'self.' to make capture semantics explicit (#3764) (#3881) * Fix/ensure view drop stop playback startup (#3875) * fix: ensure player doesn't start when view is unmounted * Patch commit to fix the error: Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit --------- Co-authored-by: Olivier Bouillet <62574056+freeboub@users.noreply.github.com> --- ios/Video/NowPlayingInfoCenterManager.swift | 12 ++++++------ ios/Video/RCTVideo.swift | 4 ++-- ios/Video/RCTVideoManager.swift | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ios/Video/NowPlayingInfoCenterManager.swift b/ios/Video/NowPlayingInfoCenterManager.swift index 6c416c72..674c2491 100644 --- a/ios/Video/NowPlayingInfoCenterManager.swift +++ b/ios/Video/NowPlayingInfoCenterManager.swift @@ -150,7 +150,7 @@ class NowPlayingInfoCenterManager { guard let self, let player = self.currentPlayer else { return .commandFailed } - let newTime = player.currentTime() - CMTime(seconds: SEEK_INTERVAL_SECONDS, preferredTimescale: .max) + let newTime = player.currentTime() - CMTime(seconds: self.SEEK_INTERVAL_SECONDS, preferredTimescale: .max) player.seek(to: newTime) return .success } @@ -160,7 +160,7 @@ class NowPlayingInfoCenterManager { return .commandFailed } - let newTime = player.currentTime() + CMTime(seconds: SEEK_INTERVAL_SECONDS, preferredTimescale: .max) + let newTime = player.currentTime() + CMTime(seconds: self.SEEK_INTERVAL_SECONDS, preferredTimescale: .max) player.seek(to: newTime) return .success } @@ -266,15 +266,15 @@ class NowPlayingInfoCenterManager { // case where there is new player that is not paused // In this case event is triggered by non currentPlayer - if rate != 0 && currentPlayer != player { - setCurrentPlayer(player: player) + if rate != 0 && self.currentPlayer != player { + self.setCurrentPlayer(player: player) return } // case where currentPlayer was paused // In this case event is triggeret by currentPlayer - if rate == 0 && currentPlayer == player { - findNewCurrentPlayer() + if rate == 0 && self.currentPlayer == player { + self.findNewCurrentPlayer() } } } diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 724f33c4..e1a5d9f8 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -525,7 +525,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH guard let self else { throw NSError(domain: "", code: 0, userInfo: nil) } let playerItem = try await self.preparePlayerItem() - try await setupPlayer(playerItem: playerItem) + try await self.setupPlayer(playerItem: playerItem) } catch { DebugLog("An error occurred: \(error.localizedDescription)") @@ -763,7 +763,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH guard let self else { return } self._playerObserver.addTimeObserverIfNotSet() - self.setPaused(_paused) + self.setPaused(self._paused) self.onVideoSeek?(["currentTime": NSNumber(value: Float(CMTimeGetSeconds(item.currentTime()))), "seekTime": seekTime, "target": self.reactTag]) diff --git a/ios/Video/RCTVideoManager.swift b/ios/Video/RCTVideoManager.swift index b4e3144a..7f762fca 100644 --- a/ios/Video/RCTVideoManager.swift +++ b/ios/Video/RCTVideoManager.swift @@ -21,7 +21,7 @@ class RCTVideoManager: RCTViewManager { let view = self.bridge.uiManager.view(forReactTag: reactTag) guard let videoView = view as? RCTVideo else { - DebugLog("Invalid view returned from registry, expecting RCTVideo, got: \(String(describing: view))") + DebugLog("Invalid view returned from registry, expecting RCTVideo, got: \(String(describing: self.view))") callback(nil) return }