Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
当前一集播放时创建下一集的 VideoAds,预取它的广告,观众离开时销毁当前的。
VideoAds
let next = VideoAds(content: nextEpisode) Task { nextLinear = try? await next.format(.linear); try? await nextLinear?.load() } // 观众继续看下一集时: ads.destroy() ads = next ads.track(player) // 播放器现在播放下一集
track(_:)
didEnd
destroy()
func episodeFinished() { do { guard let postRoll else { return nextEpisode() } try postRoll.show() // 此时调用 destroy() 会结束它 } catch { nextEpisode() // 没有展示 } } func videoAd(_ ad: VideoAd, didEnd reason: VideoAd.EndReason) { if ad === postRoll { nextEpisode() } } func nextEpisode() { ads.destroy() // 在片尾广告的 didEnd 之后,绝不在之前 ads = next ads.track(player) }