> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kontext.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Your player

> Give the SDK your content player: built-in support for some players, and VideoAdsPlayer for any other.

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](https://docs.kontext.so/video/sdk/swift/avplayer.md)):

```swift theme={null}
ads.track(player)
```

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](https://docs.kontext.so/video/sdk/swift/ttsdk.md).

With any other player, conform it to `VideoAdsPlayer`: its position in seconds, and whether it plays. Buffering and seeking count as playing.

```swift theme={null}
extension MyPlayer: VideoAdsPlayer {
    var currentTime: TimeInterval { position }
    var isPlaying: Bool { state == .playing || state == .buffering }
}

ads.track(myPlayer)
```

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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.