I have a collection view with an AVPlayer
inside the cell and the AVPlayer
starts playing the AVPlayerItem
in a loop when
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
gets called. this works well but the problem is that after the AVPlayer
is playing the item a few times the video is no longer shown but i can hear its sound.
I also add an observer for the value @"playbackBufferFull"
for each item that is played like that:
[item addObserver:self forKeyPath:@"playbackBufferFull" options:NSKeyValueObservingOptionNew context:nil];
i noticed that when the video stops the observer method of the value @"playbackBufferFull"
gets called, first of all i would like to know what causes the buffer the get full, the second and most important is how can i resume the AVPlayer
when the video stops;
i tried calling [cell.videoPlayer play];
and to replace the item with a new one and it didnt work, the observer method:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context {
if ([object isKindOfClass:[AVPlayerItem class]] && [keyPath isEqualToString:@"playbackBufferFull"])
{
//this method is get called when the video stop showing but i can still hear it
//how can i resume the video?
}
}