I’m working on an iOS application that feeds all videos submitted by a user pool, allowing users to view and view videos created by others. As you can imagine, I need to be able to support an arbitrary number of videos in the feed.
I am currently creating and saving an instance of AVPlayer for each video, for example:
NSString * urlString = @"aRemoteURL.mov";
NSURL * movURL = [NSURL URLWithString:urlString];
_videoPlayer = [[AVPlayer alloc]initWithURL:movURL];
[_videoPlayer.currentItem addObserver:self forKeyPath:@"playbackBufferEmpty" options:NSKeyValueObservingOptionNew context:nil];
[_videoPlayer.currentItem addObserver:self forKeyPath:@"playbackLikelyToKeepUp" options:NSKeyValueObservingOptionNew context:nil];
AVPlayerLayer * playerLayer = [AVPlayerLayer playerLayerWithPlayer:_videoPlayer];
playerLayer.frame = self.frame;
[self.layer addSublayer:playerLayer];
I call playon _videoPlayerwhen the user clicks on UIViewand everything works fine. That is, until enough videos are sent to the channel ...
18 , AVPlayer , _videoPlayer.currentItem.status AVPlayerItemStatusFailed Code=-11800 "The operation could not be completed". , 19- , , 18 .
, AVPlayer. AVPlayer, AVPlayer UIView, . AVPlayerItemStatusFailed, .
. - , AVPlayer, . !