Keep startSeek function signature consistent
Some checks failed
Build iOS / Build iOS Example App (pull_request) Has been cancelled
Build iOS / Build iOS Example App With Ads (pull_request) Has been cancelled
Build iOS / Build iOS Example App With Caching (pull_request) Has been cancelled
Check CLang / CLang-Format (pull_request) Has been cancelled
Check iOS / Swift-Lint (pull_request) Has been cancelled
Check iOS / Swift-Format (pull_request) Has been cancelled
Check JS / Check TS (tsc) (pull_request) Has been cancelled
Check JS / Lint JS (eslint, prettier) (pull_request) Has been cancelled

This commit is contained in:
Kat Huang 2024-08-05 16:08:07 -06:00
parent 338148a95c
commit 7d975dfd13

View File

@ -761,39 +761,41 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
_paused = paused _paused = paused
} }

@objc
func setSeek(_ time: NSNumber, _ tolerance: NSNumber) {
let item: AVPlayerItem? = _player?.currentItem
guard item != nil, let player = _player, let item, item.status == AVPlayerItem.Status.readyToPlay else {
_pendingSeek = true
_pendingSeekTime = time.floatValue
return
}
let wasPaused = _paused
@objc let seekTime = CMTimeMakeWithSeconds(Float64(time.floatValue), preferredTimescale: Int32(NSEC_PER_SEC))
func setSeek(_ info: NSDictionary!) { let toleranceTime = CMTimeMakeWithSeconds(Float64(tolerance.floatValue), preferredTimescale: Int32(NSEC_PER_SEC))
let seekTime: NSNumber! = info["time"] as! NSNumber
let seekTolerance: NSNumber! = info["tolerance"] as! NSNumber
let item: AVPlayerItem? = _player?.currentItem
guard let player = _player, let item = item, item.status == AVPlayerItem.Status.readyToPlay else {
_pendingSeek = true
_pendingSeekTime = seekTime.floatValue
return
}
let wasPaused = _paused
let cmSeekTime = CMTimeMakeWithSeconds(Float64(seekTime.floatValue), preferredTimescale: Int32(NSEC_PER_SEC)) player.seek(to: seekTime, toleranceBefore: toleranceTime, toleranceAfter: toleranceTime) { [weak self] (finished) in
let tolerance = CMTimeMakeWithSeconds(Float64(seekTolerance.floatValue), preferredTimescale: Int32(NSEC_PER_SEC)) guard let self = self, finished else { return }
player.seek(to: cmSeekTime, toleranceBefore: tolerance, toleranceAfter: tolerance) { [weak self] (finished) in self._playerObserver.addTimeObserverIfNotSet()
guard let self = self, finished else { return } if !wasPaused {
self.setPaused(false)
}
self._playerObserver.addTimeObserverIfNotSet() let currentTime = NSNumber(value: Float(CMTimeGetSeconds(item.currentTime())))
if !wasPaused { self.onVideoSeek?(["currentTime": currentTime,
self.setPaused(false) "seekTime": time,
"target": self.reactTag])
self.onVideoSeekComplete?(["currentTime": currentTime,
"seekTime": time,
"target": self.reactTag])
} }
let currentTime = NSNumber(value: Float(CMTimeGetSeconds(item.currentTime()))) _pendingSeek = false
self.onVideoSeekComplete?(["currentTime": currentTime,
"seekTime": seekTime,
"target": self.reactTag])
} }
_pendingSeek = false
}
@objc @objc
func setRate(_ rate: Float) { func setRate(_ rate: Float) {
if _rate != 1 { if _rate != 1 {