Created
May 3, 2021 18:59
-
-
Save mhijack/ea627088340491b9b11c65413a984563 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public private(set) var isSeekInProgress = false /// Used to notify whether to update playback progress bar | |
func manualSeekToProgress(progress: Float) { | |
self.isSeekInProgress = true /// Mark | |
let seekTime = PlayerPlaybackTimeFormatter.getConvertedCMTimeByProgress(player: player, progress: progress) | |
player.seek(to: seekTime, toleranceBefore: .zero, toleranceAfter: .zero) { [weak self] _ in | |
guard let `self` = self else { return } | |
print("Player time after seeking: \(CMTimeGetSeconds(self.player.currentTime()))") | |
self.isSeekInProgress = false /// Unmark | |
self.playbackStatus = PlayerPlaybackStatus(rawValue: self.player.timeControlStatus.rawValue) ?? .waitingToPlayAtSpecifiedRate | |
} | |
} | |
/// To update UI: | |
if !self.playbackManager.isScrubbingInProgress && !self.playbackManager.isSeekInProgress { | |
/// Do not let scrubbing interfere with periodic observer | |
self.controlsView.setProgress(progress: Float(self.playbackManager.currentPlaybackProgress)) | |
self.controlsView.updateCurrentTime(label: PlayerPlaybackTimeFormatter.getCurrentTimeFormatted(player: self.playbackManager.player)) /// update current time with playback current time | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment