SDK operation modes
Depending on the ad response that the SDK receives from the ad server, it can operate in one or more modes.
- Single ad
- An ad that can will played at any time when the "start"
message is sent to the
IMAAdsManager. No special initialization is necessary to play a single ad.
- Ad pod
- Several ads that will play back to back when "start" message is sent to
IMAAdsManager. No special initialization is necessary to play a single ad pod.
- Ad rules
- A playlist of ad breaks scheduled at certain times against particular
startmessage is ignored in ad rules mode. There can be several ad breaks scheduled within a single playlist (e.g., pre-roll, mid-roll, post-roll). For further implementation details, see the Ad Rules section below.
IMA iOS SDK v3 supports fully automated ad playlists. This feature will insert ad breaks into the content as specified in Doubleclick for Publishers when trafficking your ads. It also greatly simplifies the video player code necessary to support ad breaks, including pre-rolls, mid-rolls and post-rolls.
- When trafficking the ads in DFP, it is possible to specify various ad rules like "always play ad break at the beginning of the content" or "play a one minute ad break every 30 minutes of content".
- When ads are requested, the ad server can return an ad playlist. The SDK processes the playlist and automatically schedules the ad breaks that have been specified.
- When initializing the
IMAContentPlayheadobject is passed in via the
initializeWithContentPlayhead:adsRenderingSettings:call. If you are using an AVPlayer to display your content, you can pass an instance of
IMAAVPlayerContentPlayheadto the SDK. This object is used to track the progress of the content playback so ad breaks are automatically inserted at the times specified in DFP.
IMAContentPlayhead *contentPlayhead = [[IMAAVPlayerContentPlayhead alloc] initWithAVPlayer:self.contentAVPlayer]; [self.adsManager initializeWithContentPlayhead:contentPlayhead adsRenderingSettings:nil];
- Implement the
currentTimeto return the current time of your video player.
- Change your initialization call to the
- Implement the
- The IMAAdsManagerDelegate is used to pause and resume the content as ad breaks are played.
Note: When the content has finished playing or
the user has stopped playback, be sure to call to call
IMAAdsLoader in order to signal to the SDK that the content
is done. The SDK will then play the post-roll ad break, if one has been scheduled.
ALL_ADS_COMPLETED event will be raised when ALL ad breaks have
been played. In addition, note that content tracking begins when
method is called and you should always call
before playing content.