2015-09-25 78 views
0

我的代碼在ios8上工作正常,但它在ios 9上無法正常工作。它實際上不適用於其他視頻,對於照片庫中的視頻來說效果不錯。請幫忙!視頻在iOS 9.0.1中不起作用

這是一個視頻播放應用程序,主要代碼如下:

AVURLAsset *movieAsset = [[AVURLAsset alloc] initWithURL:wpTrack.url options:nil]; 
    AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:movieAsset]; 
    _audioPlayer = [AVPlayer playerWithPlayerItem:playerItem]; 
    AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:_audioPlayer]; 
    playerLayer.frame = _playerView.layer.bounds; 
    playerLayer.videoGravity = AVLayerVideoGravityResizeAspect; 


for (CALayer *layer in [_playerView.layer sublayers]) { 
    if ([layer isKindOfClass:[AVPlayerLayer class]]) { 
     [layer removeFromSuperlayer]; 
    } 
} 
[_playerView.layer addSublayer:playerLayer]; 
[_audioPlayer setAllowsExternalPlayback:YES]; 
[playerItem addObserver:self forKeyPath:@"status" options:0 context:nil]; 

回答

0

貌似iOS9增加了一些網絡安全檢查的東西,我添加了下面的代碼後進入Info.plist的固定的問題。

<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSAllowsArbitraryLoads</key> 
    <true/> 
</dict> 
相關問題