This guide is intended for users who want manual control over ad break playback timing. In a default implementation, the SDK automatically plays mid-rolls at their scheduled time. Some developers may want to prevent the SDK from playing these ad breaks automatically. By implementing manual ad break playback, the SDK fires an AD_BREAK_READY
event when a mid-roll has been loaded, and wait on you to start the break's playback.
Prerequisites
- iOS application with the IMA SDK implemented.
Helpful primers
If you still need to implement the IMA SDK in your app, check out our Get Started guide.
Configuring Manual Ad Break Playback
Configuring manual ad break playback takes three steps:- Tell the SDK you want to control ad break playback.
- Listen for the AD_BREAK_READY event.
- Tell the SDK to play ads when you're ready.
- (void)setUpAdsLoader { ... IMASettings settings = [[IMASettings alloc] init]; // Tell the SDK that you want to control ad break playback. settings.autoPlayAdBreaks = NO; self.adsLoader = [[IMAAdsLoader alloc] initWithSettings:settings]; ... } - (void)adsManager:(IMAAdsManager *)adsManager didReceiveAdEvent:(IMAAdEvent *)event { ... switch (event.type) { // Listen for the AD_BREAK_READY event case kIMAAdEvent_AD_BREAK_READY: // Tell the SDK to play ads when you're ready. To skip this ad break, // simply return from this handler without calling [adsManager start]. [adsManager start]; break; ... } }
FAQ
- Is this required for an IMA SDK implementation?
- Absolutely not! This is only offered for publishers who do not want the IMA SDK to automatically play mid-roll ads when they are scheduled by your ad rules or VMAP response.