我已经实施了iAd的Preroll视频广告,我想保证我的用户会观看整个广告。如何隐藏AVPlayerViewController
的控制栏,以便用户无法点击“完成”并在视频完成之前退出视频?
self.canDisplayBannerAds = YES;
[AVPlayerViewController preparePrerollAds];
player = [[AVPlayerViewController alloc] init];
player.showsPlaybackControls = NO;
player.delegate = self;
答案 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;