Compare commits
4 Commits
master
...
kat/temp-2
Author | SHA1 | Date | |
---|---|---|---|
6b15138ca7 | |||
6042eca33b | |||
1235efe975 | |||
4c9b82f6b2 |
@ -308,7 +308,7 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
private void handleSeekCompletion() {
|
private void handleSeekCompletion() {
|
||||||
if (player != null && player.getPlaybackState() == Player.STATE_READY && isSeekInProgress) {
|
if (player != null && player.getPlaybackState() == Player.STATE_READY && isSeekInProgress) {
|
||||||
Log.d("ReactExoplayerView", "handleSeekCompletion: currentPosition=" + player.getCurrentPosition());
|
Log.d("ReactExoplayerView", "handleSeekCompletion: currentPosition=" + player.getCurrentPosition());
|
||||||
eventEmitter.onVideoSeekComplete.invoke(player.getCurrentPosition());
|
eventEmitter.onSeekComplete.invoke(player.getCurrentPosition());
|
||||||
isSeeking = false;
|
isSeeking = false;
|
||||||
seekPosition = -1;
|
seekPosition = -1;
|
||||||
isSeekInProgress = false;
|
isSeekInProgress = false;
|
||||||
|
@ -762,7 +762,6 @@ 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
|
||||||
@ -771,44 +770,30 @@ 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))
|
||||||
|
|
||||||
let currentTimeBeforeSeek = CMTimeGetSeconds(item.currentTime())
|
player.seek(to: seekTime, toleranceBefore: toleranceTime, toleranceAfter: toleranceTime) { [weak self] (finished) in
|
||||||
|
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 currentTimeAfterSeek = CMTimeGetSeconds(item.currentTime())
|
let currentTime = NSNumber(value: Float(CMTimeGetSeconds(item.currentTime())))
|
||||||
|
self.onVideoSeek?(["currentTime": currentTime,
|
||||||
|
"seekTime": time,
|
||||||
|
"target": self.reactTag])
|
||||||
|
|
||||||
let newCurrentTime = NSNumber(value: Float(currentTimeAfterSeek))
|
self.onVideoSeekComplete?(["currentTime": currentTime,
|
||||||
self.onVideoSeekComplete?(["currentTime": newCurrentTime,
|
"seekTime": time,
|
||||||
"seekTime": time,
|
"target": self.reactTag])
|
||||||
"target": self.reactTag])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
player.seek(to: seekTime, toleranceBefore: toleranceTime, toleranceAfter: toleranceTime, completionHandler: seekCompletionHandler)
|
_pendingSeek = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
@ -1676,4 +1661,3 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
@objc
|
@objc
|
||||||
func setOnClick(_: Any) {}
|
func setOnClick(_: Any) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user