代码之家  ›  专栏  ›  技术社区  ›  armnotstrong

任务已完成,但出现错误-代码:-999 ios正在使用avplayer播放视频

  •  0
  • armnotstrong  · 技术社区  · 8 年前

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

    - (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 回复  |  直到 8 年前
        1
  •  0
  •   Shehata Gamal    8 年前

    Present 应该在 viewDidAppear / viewWillAppear 除了有效的url

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