0

我正在展示一个AVPlayerViewControllerAVPlayer在其中显示一个前贴片广告,但我想删除顶部和按钮栏,或者让用户ViewController在广告完成之前无法关闭:

来自 iPhone 的截图

我怎么做?

这是我的 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)
            }
        })
    })

})
4

1 回答 1

1

根据 Apple 的说法,您应该使用showsPlaybackControls属性:

一个布尔值,指示播放器视图控制器是否显示播放控件。

将其设置为假:

迅速:

yourAvPlayer.showsPlaybackControls = false

目标 C:

[yourAvPlayer setShowsPlaybackControls:FALSE];
于 2016-02-07T12:42:45.707 回答