Solution found.
When a new AVPlayerItem added to the AVQueuePlayer player will wait synchronously until the source part of the player element is buffered.
So, in this case, the player element must be buffered asynchronously, after which it can be added to the queue.
This can be done using [AVURLAsset loadValuesAsynchronouslyForKeys: completionHandler:]
For instance:
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:url options:nil]; NSArray *keys = [NSArray arrayWithObject:@"playable"]; [asset loadValuesAsynchronouslyForKeys:keys completionHandler:^() { dispatch_async(dispatch_get_main_queue(), ^ { AVPlayerItem *playerItem = [[[AVPlayerItem alloc] initWithAsset:asset] autorelease]; [player insertItem:playerItem afterItem:nil]; }); }];
Using this queue of solutions, AVQueuePlayer can be populated with elements without any spaces or hangs.
source share