<!DOCTYPE html> <html lang="en"> <head> ... <script src="admanagement-sdk-3.4.0.min.js"></script> </head> ... <script> var properties = new YospaceAdManagement.SessionProperties(); properties.setUserAgent(navigator.userAgent); YospaceAdManagement.SessionLive.create( "https://csm-e-sdk-validation.bln1.yospace.com/csm/extlive/yospace02,hlssample42.m3u8?yo.br=true&yo.av=4", properties, function(event) { var yospace_session = event.getPayload(); if (yospace_session.getSessionResult() === YospaceAdManagement.SessionResult.INITIALISED) { my_player.load(yospace_session.getPlaybackUrl()); } else { console.error("failed to init Yospace session"); } } ); </script>
At the completion of this session initialization step, a Yospace session object was received and through its getPlaybackUrl()
the URL for playing video (with server-side ads inserted) can be 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 Yospace session object in order to derive the extra information needed for handling SSAI ads. This is discussed in the next section.
Attach Yospace Session Objects
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 Yospace session object.
The context method is named attachYospaceSession()
and it should be called as soon as the Yospace session object becomes available, as demonstrated in the following example:
my_player = createPlayer(); datazoom_context = datazoom.createContext(my_player); ... YospaceAdManagement.SessionLive.create( "https://csm-e-sdk-validation.bln1.yospace.com/csm/extlive/yospace02,hlssample42.m3u8?yo.br=true&yo.av=4", properties, function(event) { var yospace_session = event.getPayload(); if (yospace_session.getSessionResult() === YospaceAdManagement.SessionResult.INITIALISED) { datazoom_context.attachYospaceSession(yospace_session); my_player.load(yospace_session.getPlaybackUrl()); } else { console.error("failed to init Yospace session"); } } );
That’s it. The Datazoom collector is now provided with the required access to gather SSAI ad related information.
Normally the Yospace Ad Management SDK relies on the application to forward selected player events/data into the Yospace SDK, in order to gather playback status information or important timed metadata. However, if the Datazoom collector is given access to the Yospace session object as demonstrated above, we will function as a bridge between the player and Yospace 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:
datazoom.on(datazoom.sdkEvent.AD_START, function(context, ad) { // entering the time span of a SSAI ad -- switch player UI to // make it appropriate for ads, such as disabling trick play controls }); datazoom.on(datazoom.sdkEvent.AD_END, function(context) { // leaving the time span of a SSAI ad -- restore player UI back to normal });
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 Yospace here) is passed as the ad
argument – it contains useful information such as the ad’s skip offset value.
Comments
0 comments
Article is closed for comments.