AVPlayerItemStatus在AV Player iOS中开始播放内容后未调用就绪状态

时间:2018-07-19 06:10:15

标签: ios avplayer avplayerviewcontroller

在我的应用程序中,我正在使用AvplayerController播放实时内容,并且正在观察状态为空或准备使用观察者进行播放。

 if (object == self->livePlayer.currentItem && [keyPath isEqualToString:@"playbackBufferEmpty"])
    {        


        dispatch_async(dispatch_get_main_queue(), ^{

            NSLog(@"Playback buffer is Empty");

            [self->livePlayer.contentOverlayView bringSubviewToFront:self->playerActivityIndicator];
            [self->playerActivityIndicator startAnimating];

        });
        }


    if (object == self->livePlayer.currentItem && [keyPath isEqualToString:@"status"])
    {
        if (self->livePlayer.currentItem.status == AVPlayerItemStatusReadyToPlay)
        {

                dispatch_async(dispatch_get_main_queue(), ^{

                    NSLog(@"Ready to play in live TV");

                    [self->livePlayer.contentOverlayView sendSubviewToBack:self->playerActivityIndicator];
                    [self->playerActivityIndicator stopAnimating];
                });

        }
        else if (self->livePlayer.currentItem.status == AVPlayerItemStatusFailed)
        {
            NSLog(@"fail to play");

  }

每当我开始播放缓冲区为空并且准备好执行播放条件时,但是在任何时候播放缓冲区为空时,视频就会冻结,并且一旦缓冲区已满并自动开始播放,但由于此原因活动指示器一直保持,因此readytoplay条件不会触发在播放视频时显示。我可以知道这种现象的原因以及我们如何解决此问题。

0 个答案:

没有答案