Skip to content

Commit

Permalink
fix: post seeking notification before initiating AVPlayer seek operat…
Browse files Browse the repository at this point in the history
…ion (#476)
  • Loading branch information
kononenkoAnton authored May 29, 2024
1 parent 1e5e184 commit 5212edd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Classes/Player/AVPlayerEngine/AVPlayerEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,17 @@ public class AVPlayerEngine: AVPlayer {
}
let newTime = self.rangeStart + CMTimeMakeWithSeconds(value, preferredTimescale: self.rangeStart.timescale)
PKLog.debug("set currentPosition: \(CMTimeGetSeconds(newTime))")

self.post(event: PlayerEvent.Seeking(targetSeekPosition: CMTimeGetSeconds(newTime)))
super.seek(to: newTime, toleranceBefore: CMTime.zero, toleranceAfter: CMTime.zero) { [weak self] (isSeeked: Bool) in
guard let self = self else { return }
if isSeeked {
self.post(event: PlayerEvent.Seeked())
PKLog.debug("seeked")
} else {
PKLog.error("seek faild")
PKLog.error("seek failed")
}
}
self.post(event: PlayerEvent.Seeking(targetSeekPosition: CMTimeGetSeconds(newTime)))
}
}

Expand Down

0 comments on commit 5212edd

Please sign in to comment.