2 qyqy555555 qyqy555555 于 2014.04.01 14:26 提问

avplayer在播放视频时,如何检测网速不好时的卡顿状态?
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];

以上方法无法处理由于网络原因造成的中断,卡顿现象。求解决方案。

1个回答

woaiios
woaiios   2016.01.13 11:35
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!