任务已完成,但发生错误-代码:-999个带AV Player的iOS播放视频

时间:2018-06-19 13:38:49

标签: ios objective-c avkit

我想制作一个演示应用程序,仅用以下示例代码播放从网络加载的视频:

- (void)viewDidLoad {
    [super viewDidLoad];

    NSURL *url = [NSURL URLWithString:@"http://ftp.cp.108tian.com/video/unity_animation.mov"];
    AVPlayer *avp = [[AVPlayer alloc]initWithURL:url];

    AVPlayerViewController *avpc = [[AVPlayerViewController alloc]init];
    avpc.player = avp;

    [self presentViewController:avpc animated:YES completion:nil];

}

是的,我添加了AST以允许HTTP传输:

enter image description here

但是我仍然收到此错误:

enter image description here

发生了什么事?以及如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

Present除有效网址外,还应位于viewDidAppear / viewWillAppear

[self presentViewController:avpc animated:YES completion:nil];