Javascript API

Connatix Javascript API is an interface that allows clients to receive events on AdUnit loads. It also gives clients control over several behaviors in order to provide a much deeper and more native integration with their websites.

 

Initialization of the AdUnit

Compared to the regular integration with Connatix Javascript, an API type of integration returns an interface linked to the unit that is being initialized. The first part of the integration is the callback function, which is called when our unit is being initialized. The second part occurs after the unit is binded to the needed events, which will then be initialized by calling the init function.

 
e.g.

 <script type="text/javascript">
                       window["player_callback"] = function(unit){
                           unit.on('ready',function(){})
                           .on('videoPause', function(){})
                           .on('videoPlay', function(){})
                           .init();
                         };
                       (function (cnxwindow, cnxdocument ,container, token, callback) {
                            var s = cnxdocument.createElement('script');
                             s.async = 1;
                             s.src = 'https://cdn.connatix.com/min/connatix.renderer.infeed.min.js';
                             s.setAttribute('data-connatix-token',token);
                             s.setAttribute('ext-interface-callback',callback);
                             container.appendChild(s);
                       })(window, document ,[container],[provided_token],[callback_func]);
        </script>
 
 
Parameters
 
1. Container: DOM Element where the unit will be inserted. If the unit will be inserted in the <head> section, then it will automatically be inserted in the configured position from the Connatix Console
2. Token: AdUnit token provided by your account manager
3. Callback Function: the globally defined function that receives the interface object used to control the AdUnit
 
Functions
 
Name Arguments Returns Description
init - - Triggers the initialization of the AdUnit. If this method is not called in the callback function, nothing will happen
play (video) - - Plays the current content video
pause (video) - - Pauses the current content video
stop (video) - - Stops the current content video
getVolume (video) - float Returns the currently set volume of the player 0 -> 1
setVolume (video) float - Sets the current volume of the player with a value between 0 and 1
mute (video) - - Mutes the current content video
unmute (video) - - Unmutes the current content video
getCurrentTime (video) - float The current position of the player in seconds
getDuration (video) - float The total length of the content in seconds
isMuted (video) - bool Returns true if the player is currently muted
destroy - - Destroys the AdUnit by removing all players and the placement container

 

Events

Name Arguments Description Media Item Availability
no-fill - Triggered when the request couldn't be fulfilled Video
ready - Triggered when the AdUnit has been rendered and control is available Video, Stories, Highlights
videoPlay - Triggered when the content video has started playing Video
videoPause - Triggered when the content video paused Video
videoEnd - Triggered when the content video has ended. Depending on the configuration of the AdUnit, after this event another content video can start and will trigger the videoPlay event again  Video
adStart - Triggered when a Video Ad is displayed Video
readMore   Triggered once the Read More is clicked and returns the URL associated with the highlights item Highlights

 

 

 

 

 

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

  • Avatar
    Pragya

     I am trying to get alert when there will be no ad but not able to do so, Please help me how will I accomplish that. And what are the ways to get the alert on 'no-fill' event.

    Note-  'adEnd' event is missed in this documentation, Please add this.

    Edited by Pragya

Please sign in to leave a comment.