我正在尝试将Pre-Roll Video Ads
实施为MPMoviePlayerController
。我想在主视频开始之前添加广告。所以这是我的代码:
override func viewDidLoad() {
super.viewDidLoad()
moviePlayer = MPMoviePlayerController()
moviePlayer.view.frame = CGRect(x: 0, y: self.view.frame.height/2 - self.view.frame.height/6, width: self.view.frame.width, height: self.view.frame.height/3)
self.view.addSubview(moviePlayer.view)
moviePlayer.fullscreen = true
moviePlayer.controlStyle = MPMovieControlStyle.Embedded
self.moviePlayer.playPrerollAdWithCompletionHandler { (var error: NSError!) -> Void in
self.moviePlayer.contentURL = NSURL(string: videoUrl)
self.moviePlayer.play()
}
}
此外,我已将MPMoviePlayerController.preparePrerollAds()
添加到AppDelegate。
但是,我无法在代码中添加引用Pre-Roll Video Ads
的{{1}}。任何帮助将不胜感激。