A
A
Anton Ivanov2015-11-15 09:19:18
iOS
Anton Ivanov, 2015-11-15 09:19:18

How to make a progress bar indicating how much is already cached for the ios player?

Hello!
I'm writing my first app for iOS :) I'm
using AVPlayer and caching. How can I make a progress bar of the current position of the file being played while indicating how much has already been cached (in a darker color, for example). Naturally with the ability to drag and drop to play from another moment.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bananafish_911, 2015-11-16
@Bananafish_911

Or file KVO: watch AVPlayerItem.loadedTimeRanges, we need a null object in the array, we get the right time like this: CMTimeRangeGetEnd(range!.CMTimeRangeValue)
or pull such a function
func availableDuration() -> CMTime
{
let range = self.player?. currentItem?.loadedTimeRanges?.first as? NSValue
if (range != nil){
return CMTimeRangeGetEnd(range!.CMTimeRangeValue)
}
return kCMTimeZero
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question