Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
player.addPeriodicTimeObserver(forInterval: CMTime(seconds: 1, preferredTimescale: 2), queue: DispatchQueue.main) {[weak self] (progressTime) in
if let duration = player.currentItem?.duration {
let durationSeconds = CMTimeGetSeconds(duration)
let seconds = CMTimeGetSeconds(progressTime)
let progress = Float(seconds/durationSeconds)
DispatchQueue.main.async {
self?.progressBar.progress = progress
if progress >= 1.0 {
self?.progressBar.progress = 0.0
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.