AVPlayerItemDidPlayToEndTimeNotification
に登録しようとしましたか?
、あなたのビデオを再生し、あなたの広告を提示する必要がある場合itemDidFinishPlaying:
メソッドを実装するときだけ
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(YourViewController.itemDidFinishPlaying(_:)), name: AVPlayerItemDidPlayToEndTimeNotification, object: nil)
を追加します。このようなもの:
func playVideo(){
player = AVPlayer(URL: NSURL(string: String(vid))!)
player?.play()
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(YourViewController.itemDidFinishPlaying(_:)), name: AVPlayerItemDidPlayToEndTimeNotification, object: nil)
}
func itemDidFinishPlaying(notification : NSNotification){
if(ALInterstitialAd.isReadyForDisplay()){
ALInterstitialAd.show()
}
NSNotificationCenter.defaultCenter().removeObserver(self, name: AVPlayerItemDidPlayToEndTimeNotification, object: nil)
}
「AVPlayer」の再生が完了すると、広告を表示します。http://stackoverflow.com/a/12605261/2108547 –