Loading several ads at once
To have several formats ready at once, ask for them and load them concurrently. Each format is requested and rendered in parallel, and one format without an ad leaves the others untouched:Running your own auction
VideoAd carries the price before anything is rendered, so you can compare it with other networks and decide:
price.value is a CPM in price.currency. price.precision says whether it is a DSP’s clearing price (.exact) or a forecast for house demand (.estimated).
reject tells the server at once, and the server tells the advertiser its win produced no impression. Use .outbid when another network won on price, with the winning price and the network, so we can optimize our bids for your traffic; .notUsed (the default) for any other reason: the moment passed, the viewer left. Rejecting is optional; an ad you never use is settled when it expires or when you call destroy().
Handling no-fill
format(_:) throws VideoAdError.noFill(reason:) when the server has nothing for the format. It is not a failure and the SDK never retries by itself; ask again at a later moment.
Giving the SDK the playhead
Every request and event carries where the viewer is in the episode. Give the SDK your player once the episode starts playing, in one of two ways. With anAVPlayer, hand it over and the SDK reads its time whenever it needs it:
VideoAds: until then the player’s time belongs to the previous episode. Before that the SDK sends 0, which is right for a prefetch.
The next episode
Create the next episode’sVideoAds while the current one plays, prefetch its ads, and destroy the current one when the viewer leaves. Any number can be alive at once; the SDK keeps at most one ad on screen in the whole app.
trackPlayhead(of:) when the episode actually starts in the player, not at creation: before that the player’s time belongs to the previous episode.