I'd like to buffer a video using AVPlayer. I play one video and I'd like to not have delay when the second video starts. One idea is to use AVURLAsset with this code:
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:urlNext options:nil];
NSArray *keys = [NSArray arrayWithObject:@"playable"];
[asset loadValuesAsynchronouslyForKeys:keys completionHandler:^()
{
dispatch_async(dispatch_get_main_queue(), ^
{
AVPlayerItem *nextVideo = [[AVPlayerItem alloc] initWithAsset:asset];
});
}];
In this way the idea is to pre-load the next video and when the first video stops, play it. But still now this don't works and the next video don't appears. Do you know if my idea is correct and what is the error? Or do you have another idea to use AVPlayer and to have buffer? Thank you.