discardPolicy
Whether this AdItem is discarded or kept for a later opportunity once an attempt to play it ended, for any AdItemAttemptOutcome.
Default value is AdItemDiscardPolicy.DiscardAfterAttempt.
Pause ads
The discard policy is the default decision, which AdvertisingConfig.shouldDiscardAdItem receives as AdItemDiscardContext.discardPolicyDecision and can override. A kept pause ad stays eligible for later pauses.
Linear ad breaks
Supported for AdItems with AdSourceType.Bitmovin or AdSourceType.Progressive, including the ad breaks of a VMAP. AdvertisingConfig.shouldDiscardAdItem is not invoked for them, so the discard policy alone decides.
A kept ad break is tried again once playback is seeked or time-shifted to a position at or before it. This includes ad breaks that were played or failed, and ad breaks that were seeked over and not returned by AdvertisingConfig.shouldPlaySeekedOverAdItems. Each time a kept ad break is tried again, its ad tag is requested again and all tracking beacons and ad events are sent again. For a VMAP, the discard policy applies to each of its ad breaks, and the VMAP is resolved into ad breaks only once. An ad break whose VAST is embedded in the VMAP is not requested again. For HLS interstitials, it is derived from their CUE attribute: AdItemDiscardPolicy.DiscardAfterAttempt if it contains ONCE, otherwise AdItemDiscardPolicy.KeepAfterAttempt.
Limitations
Only supported for linear ad breaks with AdSourceType.Bitmovin or AdSourceType.Progressive.
A linear ad break is still discarded if AdvertisingConfig.shouldLoadAdItem returns
falsefor it, if it fails to load before playback reaches its position, or if it is discarded while casting with com.bitmovin.player.api.TweaksConfig.discardAdsWhileCasting enabled.
Example Usage
To keep a pause ad eligible for every later pause, instead of discarding it once it was presented:
AdItem(arrayOf(adSource), position = "pause", discardPolicy = AdItemDiscardPolicy.KeepAfterAttempt)To keep every ad break of a VMAP, so that it is played again when seeking back before it:
AdItem(arrayOf(AdSource(AdSourceType.Bitmovin, vmapUrl)), discardPolicy = AdItemDiscardPolicy.KeepAfterAttempt)