Instance Property
shouldPlayAdItem
Callback that will be called once for every AdItem before it plays or is presented. If true is returned, the ad item can play or be presented. If false is returned, the ad item will be discarded and removed from the schedule.
var shouldPlayAdItem: (AdItem) -> Bool
Discussion
The callback is called once the ad item has loaded. To discard an ad item without loading it, use shouldLoadAdItem.
A VMAP of the Bitmovin Advertising Module, or an IMA VMAP with bitmovinAdTagLoading enabled, is replaced by one AdItem per ad break, so the callback is called for each of its ad breaks and never for the VMAP itself. Each of these ad items references the VMAP’s AdItem as parent.
Default Behavior
All ad items are allowed to play or be presented by default.
Relation to other Ad-Filtering callbacks
Together these three callbacks define the ad-filtering pipeline:
Load-time (shouldLoadAdItem)
Seek-time (shouldPlaySeekedOverAdItems)
Play- or presentation-time (shouldPlayAdItem)
Limitations
A VMAP loaded by the Google IMA SDK stays a single AdItem. The callback is called once, before its first ad break plays, and the result applies to all of its ad breaks. Set bitmovinAdTagLoading to decide about each ad break separately.
When seeking over multiple ad breaks in such a VMAP, the Google IMA SDK determines which ad breaks to play. Typically, only the last ad break fires the AD_BREAK_READY event, and the player cannot intercept or override this IMA SDK behavior. The same behavior occurs if a start offset is configured that skips ad breaks scheduled before the specified start time.
Usage Example
To skip pre-rolls, including the pre-roll of a VMAP, while keeping mid-rolls and post-rolls:
advertisingConfig.shouldPlayAdItem = { adItem in adItem.trigger != .pre }
For an IMA VMAP, this requires bitmovinAdTagLoading (see Limitations).