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];