1

我想展示一个AVPlayerViewController带有前贴片广告的广告。这是我到目前为止所拥有的:

在顶部:

let preRollAdPlayer = AVPlayerViewController()
let url = NSURL(fileURLWithPath: "https://www.youtube.com/watch?v=cIG1MsR7zWs")

在我的 didMoveToView 中:

let player = AVPlayer(URL: url)
preRollAdPlayer.showsPlaybackControls = true
preRollAdPlayer.player = player
if #available(iOS 9.0, *) {
    preRollAdPlayer.delegate = self
}

当触摸 SKSpriteNode 时:

self.view?.window?.rootViewController?.presentViewController(preRollAdPlayer, animated: true, completion: {

    self.preRollAdPlayer.playPrerollAdWithCompletionHandler({ (error) -> Void in

        if (error != nil) {
            NSLog("Error Message: %@", error)
        }
    })
    print("preRoll loaded")    
})

但是当我展示这个 AVPlayerViewController 时,它看起来像这样:

来自 iPhone 的截图

我在这里做错了什么?

4

0 回答 0