我正在展示一个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)
}
})
})
})