Reputation: 719
I'm trying to incorporate MobileVLCKit
into my app but the default time observer isn't precise enough for me and makes the progress bar jump between times. Is there a way to get more precise time updates (for example, every 1/60th second)?
Here's my current code:
let player = VLCMediaPlayer()
func mediaPlayerTimeChanged(_ aNotification: Notification) {
print(player.time)
}
/// 0.0
/// 0.0
/// 0.0
/// 0.1
/// 0.1
/// 0.1
/// 0.2
Thanks in advance!
Upvotes: 1
Views: 901
Reputation: 1895
you can use this solution:
func setUpTimer() {
Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in
self.progressAnimation()
}
}
func progressAnimation() {
UIView.animate(withDuration: 0.003, delay: 0.0, options: [.beginFromCurrentState],
animations: { [weak self] in
self?.progressView.progress = player.position
self?.layoutIfNeeded()
}, completion: nil)
}
call the setUpTimer() funtion on whatever you want fire
Upvotes: 0
Reputation: 2267
Unable to find documentation for the option, I happened upon the following when browsing manually, which appears to be the solution to ensure not only that mediaPlayerTimeChanged
updates more frequently, but the correct updated time of the playing media is accurate.
mediaPlayer.timeChangeUpdateInterval = 0.05
Upvotes: 0
Reputation: 897
try: player.position
e.g:
let player = VLCMediaPlayer()
func mediaPlayerTimeChanged(_ aNotification: Notification) {
print(player.position)
}
You need to get the content length too to convert it into a human readable time e.g: let content_length = player.media.length
Upvotes: -1