我试图在视图控制器上使用视频,但没有全屏显示,只有足够的空间放在顶部的标签和底部的按钮,这可能吗?如果不是我怎么能这样,如果用户跳过视频或它完成它转到某个viewController?
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *videoURL = [[NSBundle mainBundle]URLForResource:@"TTPlaneHits" withExtension:@"mp4"];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player];
AVPlayer *player = [AVPlayer playerWithURL:videoURL];
playerLayer.frame = CGRectMake(0, 21, self.view.frame.size.width, self.view.frame.size.height - 45 - 21);
[self.view.layer addSublayer:playerLayer];
AVPlayerViewController *controller = [[AVPlayerViewController alloc]init];
controller.player = player;
[player play];
[self.view addSubview:controller.view];
controller.view.frame = self.view.frame;
Run Code Online (Sandbox Code Playgroud)