iOS AVPlayer在播放图标上显示交叉线的屏幕

Screen Shot of AVPlayer error

下面是代码片段,url是videourl。 这个错误随机发生。 我无法追查是什么问题。 video也存储在云端和video监听器上播放AVPlayer。 下面的代码中缺less任何东西。

 + (void)presentVideoForURL:(NSURL *)URL parentViewController:(UIViewController *)parentViewController { AVAudioSession *audioSession = [AVAudioSession sharedInstance]; NSError *setCategoryError; if (![audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError]) { Error(@"setCategoryError %@", setCategoryError.localizedDescription); } NSError *activationError; if (![audioSession setActive:YES error:&activationError]) { Error(@"activationError: %@", activationError.localizedDescription); } AVPlayer *player = [[AVPlayer alloc] initWithURL:URL]; AVPlayerViewController *playerController = [[AVPlayerViewController alloc] init]; playerController.player = player; [parentViewController presentViewController:playerController animated:YES completion:^{ [player play]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackDidFinish:) name:AVPlayerItemDidPlayToEndTimeNotification object:player.currentItem]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackDidFinish:) name:AVPlayerItemFailedToPlayToEndTimeNotification object:player.currentItem]; }]; } 

检查以下两种情况。

1)检查url是否正确。

2)如果你的networking比较慢,AVPlayer没有获得足够的数据进入它的缓冲区,它会停止加载,并显示一个像你提到的UI(播放button中的横条)。所以,尝试使用高速networking。 如果这是问题,您可以使用播放停止通知重新启动播放器。

我有第二个问题,我像这样固定相同。