expose-on-seek-complete #1
@ -761,23 +761,21 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
|
|
||||||
_paused = paused
|
_paused = paused
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
func setSeek(_ info: NSDictionary!) {
|
func setSeek(_ time: NSNumber, _ tolerance: NSNumber) {
|
||||||
let seekTime: NSNumber! = info["time"] as! NSNumber
|
|
||||||
let seekTolerance: NSNumber! = info["tolerance"] as! NSNumber
|
|
||||||
let item: AVPlayerItem? = _player?.currentItem
|
let item: AVPlayerItem? = _player?.currentItem
|
||||||
guard let player = _player, let item = item, item.status == AVPlayerItem.Status.readyToPlay else {
|
guard item != nil, let player = _player, let item, item.status == AVPlayerItem.Status.readyToPlay else {
|
||||||
_pendingSeek = true
|
_pendingSeek = true
|
||||||
_pendingSeekTime = seekTime.floatValue
|
_pendingSeekTime = time.floatValue
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let wasPaused = _paused
|
let wasPaused = _paused
|
||||||
|
|
||||||
let cmSeekTime = CMTimeMakeWithSeconds(Float64(seekTime.floatValue), preferredTimescale: Int32(NSEC_PER_SEC))
|
let seekTime = CMTimeMakeWithSeconds(Float64(time.floatValue), preferredTimescale: Int32(NSEC_PER_SEC))
|
||||||
let tolerance = CMTimeMakeWithSeconds(Float64(seekTolerance.floatValue), preferredTimescale: Int32(NSEC_PER_SEC))
|
let toleranceTime = CMTimeMakeWithSeconds(Float64(tolerance.floatValue), preferredTimescale: Int32(NSEC_PER_SEC))
|
||||||
|
|
||||||
player.seek(to: cmSeekTime, toleranceBefore: tolerance, toleranceAfter: tolerance) { [weak self] (finished) in
|
player.seek(to: seekTime, toleranceBefore: toleranceTime, toleranceAfter: toleranceTime) { [weak self] (finished) in
|
||||||
guard let self = self, finished else { return }
|
guard let self = self, finished else { return }
|
||||||
|
|
||||||
self._playerObserver.addTimeObserverIfNotSet()
|
self._playerObserver.addTimeObserverIfNotSet()
|
||||||
@ -786,8 +784,12 @@ func setSeek(_ info: NSDictionary!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let currentTime = NSNumber(value: Float(CMTimeGetSeconds(item.currentTime())))
|
let currentTime = NSNumber(value: Float(CMTimeGetSeconds(item.currentTime())))
|
||||||
|
self.onVideoSeek?(["currentTime": currentTime,
|
||||||
|
"seekTime": time,
|
||||||
|
"target": self.reactTag])
|
||||||
|
|
||||||
self.onVideoSeekComplete?(["currentTime": currentTime,
|
self.onVideoSeekComplete?(["currentTime": currentTime,
|
||||||
"seekTime": seekTime,
|
"seekTime": time,
|
||||||
"target": self.reactTag])
|
"target": self.reactTag])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user