I am using AVPlayer to view videos stored on Amazon's CloudFront -- Live HTTP protocol is used and the playlist and segments are stored on S3 and hosted using CloudFront.
After playing a few videos I start getting a status of AVPla开发者_运维问答yerItemStatusUnknown from the AVPlayer item
AVPlayer.currentItem.status == AVPlayerItemStatusUnknown
This status persists when a new video playlist is selected -- I've tried de-allocating the AVPlayer before setting a new playlist URL and still the AVPlayerItemStatusUnknown status remains until I terminate the application.
Two questions. Is anybody using Amazaon CloudFront to host video experiencing the same issue? Does anybody know a work around so i can recover the state of the AVPlayer to prevent the user from having to terminate the app to view any more videos?
Many Thanks,
//aaron
For streaming media this looks like a normal behavior to me. Do you add an observer for the 'status' property? You should start playback when status changes to AVPlayerItemStatusReadyToPlay.
[item addObserver:self forKeyPath:@"status" options:0 context:nil];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:@"status"]) {
AVPlayerItem *item = (AVPlayerItem *)object;
if (item.status == AVPlayerItemStatusReadyToPlay) {
//Ready
}
}
}
I found the problem. Short answer is it was an over retained AVPlayer, which by the way, was not noticed by the Instruments tool using the leaks template. Sorry for the false alarm.
//aaron
精彩评论