Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: AVPlayer video preloading

I am using AVPlayer to play videos. The lenght of them is short, 2-5 second. They are played in a random order. The problem is, when changing video, and a new video starts to play, the device lags for a very short time, but i wan't the change to be fluid. Is there a way to preload videos with AVPlayer?

like image 797
McDermott Avatar asked Dec 02 '11 09:12

McDermott


1 Answers

Try using AVQueuePlayer. I am assuming that what you described as a lag, in fact is the pre buffering delay. This should be minimized or actually entirely be gotten rid of when using AVQueuePlayer as that baby will buffer the next AVPlayerItem while playing the current one.

From the AVFoundation documentation:

On iOS 4.1 and later, you can use an AVQueuePlayer object to play a number of items in sequence (AVQueuePlayer is a subclass of AVPlayer).

Also see Mihai's answer on Pre-buffering-for-avqueueplayer.

like image 174
Till Avatar answered Oct 30 '22 13:10

Till