如何隐藏AVPlayerViewController控件栏?

时间:2015-11-20 14:18:22

标签: ios iad avplayerviewcontroller

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

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

2 个答案:

答案 0 :(得分:1)

您可以使用此代码执行相同操作。出示控制器时需要调用play。

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

答案 1 :(得分:0)

简单代码

// create an AVPlayer
AVPlayer *player = [AVPlayer playerWithURL:videoURL];

// create a player view controller
AVPlayerViewController *controller = [[AVPlayerViewController alloc]init];
controller.player = player;
controller.showsPlaybackControls = FALSE;