AVPlayer needs no adapter: track(_:) takes it directly.
Track the player
- Any
AVPlayer, anAVQueuePlayerincluded, wherever it renders: anAVPlayerLayer, anAVPlayerViewController, a SwiftUIVideoPlayer. - Held weakly: the SDK never keeps your player alive. It lets go at
destroy()or the nexttrack(_:). - Call it when the 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.
One player across episodes
Most apps reuse one player and swap its item. Track it from each episode’sVideoAds once that episode’s item is in the player:
invalidated(.contentChanged) at show: the SDK took the previous item for this episode’s. Track again once the new item is in and they show.
What the SDK reads
The SDK observes the player, so an overlay ends the moment the viewer pauses, wherever the pause came from: your controls, the lock screen, Control Center, a headset, picture-in-picture.
In the background
iOS pauses anAVPlayer when the app goes to the background. An overlay on screen freezes instead of ending: it goes on if the content plays again within a second of the app’s return, and ends as .interrupted otherwise.
A looped episode
AnAVPlayerLooper plays copies of the item, so each loop is another item: an overlay or pause ad requested in one loop is refused in the next (invalidated(.contentChanged)). Request the next ad from didEnd, as always, and it belongs to the loop that plays.