Implement ios onSeekComplete
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
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
This commit is contained in:
parent
d69729dc04
commit
f3deabd75e
@ -762,6 +762,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
_paused = paused
|
_paused = paused
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
func setSeek(_ time: NSNumber, _ tolerance: NSNumber) {
|
func setSeek(_ time: NSNumber, _ tolerance: NSNumber) {
|
||||||
let item: AVPlayerItem? = _player?.currentItem
|
let item: AVPlayerItem? = _player?.currentItem
|
||||||
@ -770,30 +771,44 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
_pendingSeekTime = time.floatValue
|
_pendingSeekTime = time.floatValue
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let wasPaused = _paused
|
|
||||||
|
|
||||||
|
let wasPaused = _paused
|
||||||
let seekTime = CMTimeMakeWithSeconds(Float64(time.floatValue), preferredTimescale: Int32(NSEC_PER_SEC))
|
let seekTime = CMTimeMakeWithSeconds(Float64(time.floatValue), preferredTimescale: Int32(NSEC_PER_SEC))
|
||||||
let toleranceTime = CMTimeMakeWithSeconds(Float64(tolerance.floatValue), preferredTimescale: Int32(NSEC_PER_SEC))
|
let toleranceTime = CMTimeMakeWithSeconds(Float64(tolerance.floatValue), preferredTimescale: Int32(NSEC_PER_SEC))
|
||||||
|
|
||||||
player.seek(to: seekTime, toleranceBefore: toleranceTime, toleranceAfter: toleranceTime) { [weak self] (finished) in
|
let currentTimeBeforeSeek = CMTimeGetSeconds(item.currentTime())
|
||||||
guard let self = self, finished else { return }
|
|
||||||
|
// Call onVideoSeek before starting the seek operation
|
||||||
|
let currentTime = NSNumber(value: Float(currentTimeBeforeSeek))
|
||||||
|
self.onVideoSeek?(["currentTime": currentTime,
|
||||||
|
"seekTime": time,
|
||||||
|
"target": self.reactTag])
|
||||||
|
|
||||||
|
_pendingSeek = true
|
||||||
|
|
||||||
|
let seekCompletionHandler: (Bool) -> Void = { [weak self] finished in
|
||||||
|
guard let self = self else { return }
|
||||||
|
|
||||||
|
self._pendingSeek = false
|
||||||
|
|
||||||
|
guard finished else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
self._playerObserver.addTimeObserverIfNotSet()
|
self._playerObserver.addTimeObserverIfNotSet()
|
||||||
if !wasPaused {
|
if !wasPaused {
|
||||||
self.setPaused(false)
|
self.setPaused(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
let currentTime = NSNumber(value: Float(CMTimeGetSeconds(item.currentTime())))
|
let currentTimeAfterSeek = CMTimeGetSeconds(item.currentTime())
|
||||||
self.onVideoSeek?(["currentTime": currentTime,
|
|
||||||
"seekTime": time,
|
|
||||||
"target": self.reactTag])
|
|
||||||
|
|
||||||
self.onVideoSeekComplete?(["currentTime": currentTime,
|
let newCurrentTime = NSNumber(value: Float(currentTimeAfterSeek))
|
||||||
|
self.onVideoSeekComplete?(["currentTime": newCurrentTime,
|
||||||
"seekTime": time,
|
"seekTime": time,
|
||||||
"target": self.reactTag])
|
"target": self.reactTag])
|
||||||
}
|
}
|
||||||
|
|
||||||
_pendingSeek = false
|
player.seek(to: seekTime, toleranceBefore: toleranceTime, toleranceAfter: toleranceTime, completionHandler: seekCompletionHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
@ -1661,3 +1676,4 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
@objc
|
@objc
|
||||||
func setOnClick(_: Any) {}
|
func setOnClick(_: Any) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user