I am using MPMoviePlayerController
to play audio and I want to show the buffered data on slider like this ...
According the documentation of MPMoviePlayerController
(available here) you can use the playableDuration
property to retrieve the duration that has been loaded by the player.
You would then have to subclass UISlider
to draw the red part of your control in the drawRect:
method.
As for AVPlayer
you would call loadedTimeRanges
(documentation here) on the AVPlayerItem
representing your content. That would give you an array of (as of iOS 8) a single CMTimeRange
representing the part of your media that has been buffered. I would advise using [NSArray firstObject]
when retrieving the time range to protect your code against a possibly empty array.