I am developing an application for playing video using HTTP Live Streaming technology.
For this I use AVPlayer which init as follows:
[[AVPlayer alloc] initWithURL:[NSURL URLWithString:VIDEO_URL]];
Then I check the state of the buffer using self.player.currentItem.loadedTimeRanges
and display this range on my custom view.
The problem is that when rewinding in an area that is loaded by [self.player seekToTime:timeToSeek
toleranceBefore:kCMTimeZero
toleranceAfter:kCMTimeZero];
, loads the video starts just as if it was not in the buffer.
First of all, my answer assumes that you are using HTTP Live Streaming for a static m3u8 list, otherwise seeking within the video will not make much sense.
HTTP Live Streaming uses an m3u style playlist which embeds sub playlists. Each sub-playlist shows different video quality and the AVPlayer chooses which one to use according to the network speed.
But, according to Apple's documentation, when the player initially starts playing it first chooses the first sub-playlist and only after a couple of ts files were played it chooses the appropriate sub-playlist as described above.
So it could be that when you seek to a certain time, the player first tries to play the first sub-list which is not cached.
Try the following:
CMTimeMake(30, 60)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With