This works: I have an AVPlayer
which plays a video right after it was loaded. And this works fine.
This doesn\'t:
Couple of things which may help you:
When checking if the player is ready to play, I check both the player itself and also the player's current item.
if(self.player.status == AVPlayerStatusReadyToPlay &&
self.player.currentItem.status == AVPlayerItemStatusReadyToPlay) {
[self.player play];
}
It's possible that if you seek to e.g. 15 seconds, it may start from the beginning of the video instead if that is the location of the nearest keyframe. To force the player to seek to the exact location (note: this will take several seconds to do), do this:
Float64 seconds = 500.0f;
CMTime targetTime = CMTimeMakeWithSeconds(seconds, NSEC_PER_SEC);
[self.player seekToTime:targetTime
toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];
Or you can seek to the keyframe explicitly before/after the specified point by specifying one of the arguments as infinity:
[self.player seekToTime:targetTime
toleranceBefore:kCMTimePositiveInfinity toleranceAfter:kCMTimeZero];