fix(ios): remove false calls at onPlaybackRateChange (#3306)

This commit is contained in:
Krzysztof Moch 2023-10-24 22:10:29 +02:00 committed by GitHub
parent 9373493d6a
commit 286418e4a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -94,7 +94,7 @@ class RCTPlayerObserver: NSObject {
return
}
_playerRateChangeObserver = player.observe(\.rate, changeHandler: _handlers.handlePlaybackRateChange)
_playerRateChangeObserver = player.observe(\.rate, options: [.old], changeHandler: _handlers.handlePlaybackRateChange)
_playerExternalPlaybackActiveObserver = player.observe(\.isExternalPlaybackActive, changeHandler: _handlers.handleExternalPlaybackActiveChange)
}

View File

@ -1221,6 +1221,10 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
func handlePlaybackRateChange(player: AVPlayer, change: NSKeyValueObservedChange<Float>) {
guard let _player = _player else { return }
if(player.rate == change.oldValue && change.oldValue != nil) {
return
}
onPlaybackRateChange?(["playbackRate": NSNumber(value: _player.rate),
"target": reactTag as Any])