iOS AVPlayer在“播放"图标上显示带有交叉线的屏幕 [英] iOS AVPlayer showing screen with a cross line on Play icon

查看:135
本文介绍了iOS AVPlayer在“播放"图标上显示带有交叉线的屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Screen Shot of AVPlayer error

下面是代码段,url是视频url.该错误是随机发生的. 我无法找到问题所在.视频也存储在云中,而视频窃听者可以在AVPlayer上播放.以下代码中缺少任何内容.

Below is the code snippet, url is the the video url. This error occurs randomly. I'm unable to trace what is the issue. Also the video is stored in cloud and video buggers to play on the AVPlayer. Is anything missing in the below code.

+ (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];
      }];
}

推荐答案

检查以下2种情况.

1)检查网址是否正确.

1) Check whether the url is correct or not.

2)如果您的网络速度很慢,并且AVPlayer无法在其缓冲区中获取足够的数据,它将停止加载并显示您提到的UI(播放"按钮中的横线).因此,请尝试使用速度较快的网络. 如果这是问题所在,则可以使用播放停止通知重新启动播放器.

2) If your network is slow and AVPlayer is not getting adequate data into it's buffer,it stops loading and shows a UI like you mentioned (A cross bar in play button).So try using high sped network. If this is the issue,you can restart the player using the playback stall notification.

我遇到了第二期问题,我像这样解决了这个问题.

I had the 2nd issue and I fixed the same like this.

这篇关于iOS AVPlayer在“播放"图标上显示带有交叉线的屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆