NSURL *playUrl=[NSURL URLWithString:url];
AVURLAsset *asset=[AVURLAsset assetWithURL:playUrl];
[asset loadValuesAsynchronouslyForKeys:[NSArray arrayWithObject:@"tracks"]
completionHandler:^{
AVKeyValueStatus status=[asset statusOfValueForKey:@"tracks" error:nil];
NSLog(@"status==%d",status);
if (status==AVKeyValueStatusLoaded) {
[[NSNotificationCenter defaultCenter]removeObserver:self
name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(stopPlay)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
items=[AVPlayerItem playerItemWithAsset:asset];
if (_player) {
RELEASE_SAFELY(_player);
}
_player=[[AVPlayer alloc]initWithPlayerItem:items];
[_playerView setPlayer:_player];
[_player play];
以上方法无法处理由于网络原因造成的中断,卡顿现象。求解决方案。
http://stackoverflow.com/questions/6880817/ios-avplayer-trigger-streaming-is-out-of-buffer