我正在使用AVPlayerViewController
呈现AVPlayer
,并在其中显示前贴片广告,但我想删除顶部和按钮栏,或者让用户无法在广告完成之前解除ViewController
:
我该怎么做?
这是我的AVPlayerViewController实现的代码:
let preRollAdPlayer = AVPlayerViewController()
let player = AVPlayer()
preRollAdPlayer.player = player
if #available(iOS 9.0, *) {
preRollAdPlayer.delegate = self
}
preRollAdPlayer.showsPlaybackControls = false
self.view?.window?.rootViewController?.presentViewController(preRollAdPlayer, animated: true, completion: {
self.preRollAdPlayer.playPrerollAdWithCompletionHandler({ (error) -> Void in
if (error != nil) {
NSLog("Error Message: %@", error)
} else {
print("preRoll loaded")
}
self.preRollAdPlayer.dismissViewControllerAnimated(true, completion: {
if (error != nil) {
NSLog("Error Message: %@", error)
}
})
})
})
答案 0 :(得分:0)
根据Apple的说法,您应该使用showsPlaybackControls属性:
一个布尔值,指示播放器视图控制器是否显示播放控件。
将其设为false:
<强>夫特:强>
yourAvPlayer.showsPlaybackControls = false
目标C:
[yourAvPlayer setShowsPlaybackControls:FALSE];