Typically for a web application to play content with the Server-Side Ad Insertion (SSAI) service provided by IMA DAI, first it creates an instance of StreamManager – to request and manage the video stream with server-side ads inserted, as shown in the following example:
If the stream request is successful, through the listener to the IMA DAI
LOADED stream event the URL for playing video (with server-side ads inserted) is received and loaded into the player for content/ads presentation.
To an uninformed player or player data collector, the server-side inserted ads are indistinguishable from real contents under the same video stream. For a Datazoom collector to identify these ads and report ad data points accordingly, it must be given access to the StreamManager instance in order to derive the extra information needed for handling SSAI ads. This is discussed in the next section.
Attach the StreamManager
As in most Datazoom collector integrations, as soon as a player instance is created, a Datazoom collector context is created in order to collect data for this specific player. Now, we must perform one additional context method call to give the Datazoom collector context the access to the StreamManager.
The context method is named
attachImaDaiStreamManager() and it should be called as soon as the StreamManager is created, as demonstrated in the following example:
That’s it. The Datazoom collector is now provided with the required access to gather SSAI ad related information.
Normally the IMA DAI SDK relies on the application to forward timed metadata from the player to the IMA DAI SDK. However, if the Datazoom collector is given access to the StreamManager as demonstrated above, we will function as a bridge between the player and IMA DAI SDK to meet these integration requirements, so the application can be spared from the extra effort.
Register SDK Event Callbacks to Update UI for SSAI Ads
The application may register callback functions to be invoked by Datazoom collector SDK when the current playhead enters or leaves the time span of a SSAI ad, as demonstrated below:
In the sample code above, the Datazoom collector context corresponding to the player is passed as the
context argument. Besides, the native ad object (as defined by IMA here) is passed as the
ad argument – it contains useful information such as the ad’s skip offset value.