如何隐藏AVPlayerViewController控件栏? [英] How to hide AVPlayerViewController control bar?

查看:90
本文介绍了如何隐藏AVPlayerViewController控件栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实施了iAd的Preroll视频广告,并且我想保证我的用户可以观看整个广告.如何隐藏AVPlayerViewController的控制栏,使用户无法点击完成"并在完成之前退出视频?

I've implemented iAd's Preroll Video Ad and I want to guarantee that my user will watch the entire advertisement. How do I hide the AVPlayerViewController's control bar so the user can not tap "Done" and get out of the video before it finishes?

self.canDisplayBannerAds = YES;
[AVPlayerViewController preparePrerollAds];
player = [[AVPlayerViewController alloc] init];
player.showsPlaybackControls = NO;
player.delegate = self;

推荐答案

您可以使用此代码执行相同的操作.当您出现控制器时,您需要通话.

You can use this code to do the same. You need to call play when you present the controller.

playerItem = [[AVPlayerItem alloc] initWithURL:url];
if(playerItem) {
  player = [[AVPlayer alloc] initWithPlayerItem:playerItem];
  playerViewController = [[AVPlayerViewController alloc] init];
  playerViewController.player = _player;
  [playerViewController setShowsPlaybackControls:NO];
  [parentViewController presentViewController:playerViewController animated:YES completion:^{
  [playerViewController.player play];
}];

这篇关于如何隐藏AVPlayerViewController控件栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆