视频无法在iOS 10中播放

时间:2016-11-30 07:56:11

标签: ios objective-c avplayerviewcontroller

在以下代码中:

// NSURL *videoURL1 = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.ebookfrenzy.com/ios_book/movie/movie.mov"]];
NSURL *videoURL2 = [NSURL URLWithString:[NSString stringWithFormat:@"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"]];



AVPlayer *playerV = [AVPlayer playerWithURL:videoURL];
AVPlayerViewController *playerViewController = [AVPlayerViewController new];
playerViewController.player = playerV;

[self presentViewController:playerViewController animated:YES completion:^{
    [playerV play];
}];

VideoURL1正在运行,但是videoURL2无效,屏幕如下:

click here for screenshot

我在info.plist中添加了键和值:

Click here for screenshot

1 个答案:

答案 0 :(得分:0)

第二个网址不工作的原因是您只将“http://www.ebookfrenzy.com”列入白名单,但不支持支持安全连接。您还应该将“clips.vorwaerts-gmbh.de”列入白名单“http://www.ebookfrenzy.com”列入白名单。如果您要动态访问来自多个站点的视频,这些视频不支持安全连接(https),那么您的plist中会显示以下行。

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

有关详细信息,请查看以下主题

How do I load an HTTP URL with App Transport Security enabled in iOS 9?