AVPlayerViewController not loading remote URL

£可爱£侵袭症+ 提交于 2020-01-16 05:18:08

问题


I'm trying to play a remote MP4 video in an AVPlayerViewController:

self.vcVideo = [[AVPlayerViewController alloc] init];
self.vcVideo.player = [AVPlayer playerWithURL:[NSURL URLWithString:videoURL]];

[self presentViewController:self.vcVideo animated:YES completion:^{
    [self.vcVideo.player play];
}];

The view controller is presented but the play button is disabled:

This is on iOS 9.


回答1:


In iOS9 security policy is changed. In your log you should see something about the security. I believe that your remote video url is http not https. You should add these lines to your plist file.

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>


来源:https://stackoverflow.com/questions/36044314/avplayerviewcontroller-not-loading-remote-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!