Created
February 21, 2019 10:01
-
-
Save pgpt10/993398a3c70d219cde4c8e2288918eb8 to your computer and use it in GitHub Desktop.
This file contains 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
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