swift - MPMoviePlayerController.preparePrerollAds() 准备就绪时的通知

标签 swift mpmovieplayercontroller iad

我已根据 this post 成功实现了前置视频广告.

本教程在模拟器中以 100% 的填充率工作,但现在我的应用已上线,但没有按计划进行。

是否可以收到预告片已准备就绪的通知?

我想做的是仅当广告准备好加载时才显示按钮。

这是我在这里的第一篇文章,希望我已经把我的问题说清楚了!

最佳答案

在您计划通过 yourMoviePlayer.playPrerollAdWithCompletionHandler 播放前插视频广告请求之前,无法检测它是否已成功填充。您可以在点击 UIButton 并请求另一个 Pre-Roll Video Ad 后检查是否收到错误不过我不建议这样做。 iAd 网络不喜欢您发送大量请求,并且可能会进一步降低成功填充前置视频广告的机会。由于用户位于不受支持的国家/地区,因此还存在从未收到前置视频广告的问题。由于所转换广告的不可靠性,基于广告展示限制功能并不是最佳方法。

    yourMoviePlayer.playPrerollAdWithCompletionHandler { (error) -> Void in
        if (error) != nil {
            NSLog("\(error)")
            // Request another ad
            MPMoviePlayerController.preparePrerollAds()
        }
        else {
            self.yourMoviePlayer.play()
            // Perform desired button action
        }
    }

关于swift - MPMoviePlayerController.preparePrerollAds() 准备就绪时的通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32539161/

相关文章:

ios7 - 使用 Sprite Kit 时如何启用 iAd?

ios - Swift - 使用 DispatchGroup() 从 Firebase Firestore 异步下载数据时出现问题

ios - UICollectionViewCells 中的 UITableviews

ios - 快速解析查询获取最后创建的对象

ios - Apple 如何计算 iAd 横幅的展示次数?

ios - 插页式广告坏了吗? iOS 8?

ios - 在 iOS 应用程序的整个 Web View 中保留登录凭据(快速)

ios - 如果背景音频处于事件状态,则MPMoviePlayerController卡住

ios - Objective-C MPMoviePlayerController iOS7 问题

iphone - 为什么 MPMovieLoadState 的状态为 5?