我在这里看到了完全相同的问题,但没有得到答案,所以再次问同样的问题。 AVPlayer 不会在 iOS9 中播放来自 url 的视频 我尝试了各种方法来尝试播放视频,但不幸的是它们不适合我。这是代码:
AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init];
NSString *url = [[NSBundle mainBundle] pathForResource:@"Intro" ofType:@"mp4"];
_asset = [AVURLAsset assetWithURL: [NSURL URLWithString:url]];
_playerItem = [AVPlayerItem playerItemWithAsset: _asset];
_player = [[AVPlayer alloc] initWithPlayerItem: _playerItem];
[playerViewController.view setFrame:_videoView.frame];
playerViewController.showsPlaybackControls = YES;
[_videoView addSubview:playerViewController.view];
playerViewController.player = _player;
[_player play];
这是使用上述代码的当前外观的屏幕截图。我使用另一个 Apple 代码来检查视频,它运行良好,但 Apple 代码对我来说太过分了,因为它对于简单的事情来说太复杂了。这是:https ://developer.apple.com/library/prerelease/ios/samplecode/AVFoundationSimplePlayer-iOS/