【问题标题】:Task finished with error - code: -999 ios playing video with avplayer任务完成但出现错误 - 代码:-999 ios 使用 avplayer 播放视频
【发布时间】:2018-06-19 13:38:48
【问题描述】:

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

- (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 传输:

但我仍然收到此错误:

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

【问题讨论】:

    标签: ios objective-c avkit


    【解决方案1】:

    Present 应该在viewDidAppear/viewWillAppear 中加上一个有效的 url

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

    【讨论】:

    • 在将代码移动到viewDidAppear 后仍然是相同的错误代码-999,我已经尝试了另一个online source 以确保视频文件正常
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-07
    • 2015-07-26
    • 1970-01-01
    • 2016-06-12
    • 1970-01-01
    • 2017-02-23
    • 1970-01-01
    相关资源
    最近更新 更多