kat-debug #2
@ -114,7 +114,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
@objc var onVideoProgress: RCTDirectEventBlock?
|
||||
@objc var onVideoBandwidthUpdate: RCTDirectEventBlock?
|
||||
@objc var onVideoSeek: RCTDirectEventBlock?
|
||||
@objc var onVideoSeekComplete: RCTDirectEventBlock?
|
||||
@objc var onVideoSeekComplete: RCTDirectEventBlock? {
|
||||
didSet {
|
||||
print("onVideoSeekComplete set: \(onVideoSeekComplete != nil)")
|
||||
}
|
||||
}
|
||||
@objc var onVideoEnd: RCTDirectEventBlock?
|
||||
@objc var onTimedMetadata: RCTDirectEventBlock?
|
||||
@objc var onVideoAudioBecomingNoisy: RCTDirectEventBlock?
|
||||
@ -762,6 +766,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
_paused = paused
|
||||
}
|
||||
|
||||
|
||||
@objc
|
||||
func setSeek(_ time: NSNumber, _ tolerance: NSNumber) {
|
||||
let item: AVPlayerItem? = _player?.currentItem
|
||||
@ -770,30 +775,45 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
_pendingSeekTime = time.floatValue
|
||||
return
|
||||
}
|
||||
let wasPaused = _paused
|
||||
|
||||
let wasPaused = _paused
|
||||
let seekTime = CMTimeMakeWithSeconds(Float64(time.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
|
||||
guard let self = self, finished else { return }
|
||||
let currentTimeBeforeSeek = CMTimeGetSeconds(item.currentTime())
|
||||
print("Before seek - Current time: \(currentTimeBeforeSeek), Seeking to: \(time)")
|
||||
|
||||
// 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()
|
||||
if !wasPaused {
|
||||
self.setPaused(false)
|
||||
}
|
||||
|
||||
let currentTime = NSNumber(value: Float(CMTimeGetSeconds(item.currentTime())))
|
||||
self.onVideoSeek?(["currentTime": currentTime,
|
||||
"seekTime": time,
|
||||
"target": self.reactTag])
|
||||
let currentTimeAfterSeek = CMTimeGetSeconds(item.currentTime())
|
||||
|
||||
self.onVideoSeekComplete?(["currentTime": currentTime,
|
||||
let newCurrentTime = NSNumber(value: Float(currentTimeAfterSeek))
|
||||
self.onVideoSeekComplete?(["currentTime": newCurrentTime,
|
||||
"seekTime": time,
|
||||
"target": self.reactTag])
|
||||
}
|
||||
|
||||
_pendingSeek = false
|
||||
player.seek(to: seekTime, toleranceBefore: toleranceTime, toleranceAfter: toleranceTime, completionHandler: seekCompletionHandler)
|
||||
}
|
||||
|
||||
@objc
|
||||
|
Loading…
Reference in New Issue
Block a user