在MPMoviePlayerController启动之前预先滚动视频广告

时间:2015-06-09 07:49:30

标签: ios swift mpmovieplayercontroller iad

我正在尝试将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}}。任何帮助将不胜感激。

0 个答案:

没有答案