Skip to main content
Every request and event carries where the viewer is in the episode, and overlay and pause ads follow the playback: an overlay shows over playing content only and goes away when the viewer pauses; a pause ad goes away when the content plays again after a pause seen while the ad is on screen, however the viewer resumed it. Give the SDK your player once the episode starts playing. With an AVPlayer, hand it over; the SDK reads its time and watches its playback (see AVPlayer):
With a TTSDK player (TTVideoEngine), add the KontextVideoTTSDK product of the same package and hand over the engine, ads.track(ttVideoEngine: engine) { episode.id }; see TTSDK player. With any other player, conform it to VideoAdsPlayer: its position in seconds, and whether it plays. Buffering and seeking count as playing.
If your player already publishes its state, return it as isPlayingPublisher and an overlay ends the moment the viewer pauses; otherwise the SDK checks isPlaying four times a second while an overlay is on screen. The SDK keeps your VideoAdsPlayer until destroy() or the next track(_:), so a small wrapper needs no other reference; an AVPlayer is held weakly, as your app owns it. A wrapper that references the VideoAds (or the object owning it) keeps both alive until destroy(): call destroy() when the viewer leaves, or do not reference the ads from it. Call track(_:) when this episode starts playing, not when you create the VideoAds: until then the player’s time belongs to the previous episode. Before that the SDK sends 0, which is right for a prefetch.