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>
This commit is contained in:
Dibyendu Das 2024-06-07 08:04:00 -04:00 committed by GitHub
parent ff1e24aaad
commit ac0a9c3e3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 9 deletions

View File

@ -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()
}
}
}

View File

@ -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])

View File

@ -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
}