The following events are available in the API:

player.ready

Fires when the Player is ready to play video.

Event data properties:

  • rootDiv - (HTMLDivElement), player container
  • playerId
  • subId

Sample usage:

// player.ready usage -
       apiInterface.on('player.ready', function(eventObject) {
         var playerDiv = eventObject.data.rootDiv;

         // player will play only if user put mouse on it
         playerDiv.addEventListener("mouseover", function() {
           eventObject.player.play();
         });
         playerDiv.addEventListener("mouseout", function() {
           eventObject.player.pause();
         });
       });

player.started

Fires whenever the Player starts playing a video (this can be either a content item or an advertisement).

Event data properties:

  • playerId
  • subId

player.finished

Fires when the player has completed playing all ads and content video (won’t play the content in loop).

Event data properties:

  • playerId
  • subId

player.paused

Fires when a playing video, either an ad or content video is paused.

Event data properties:

  • playerId
  • subId

player.resumed

Fires when a paused video, either an ad or a content video is resumed.

Event data properties:

  • playerId
  • subId

player.adspaused

Fires when pauseAds method is called, and the player stopped both playing a current ad and sending requests for ads. (A content Video can still be playing.)

Event data properties:

  • playerId
  • subId

player.durationChange

Fires when the duration of a currently playing ad was changed. (This is mainly imprtant if the client is using its own control bar; if the VPAID updated the duration, the control bar will be updated accordingly).

Event data properties:

  • playerId
  • subId

closed

Fires after the Player close method is called.

Event data properties:

  • playerId
  • subId

click

Fires when the user clicks on an advertisement or a content video.

Event data properties:

  • url - string, the link for which the user is redirecting
  • playerId
  • subId

Sample usage:

apiInterface.on(‘click, function(eventObject){

      alert(“user clicked following url:” + eventObject.url);    

});

aderror

Fires when an ad error has occurred.

Event data properties:

  • playerId
  • subId
  • vatId

adstartreq

Fires when startAd is called. (Start Request id is done by Cedato’s servers, however this doesn’t necessarily mean the ad will play.)

Event data properties:

  • playerId
  • subId
  • vatId

adstart

Fires when a new ad starts playing (equal to ad impression).

Event data properties:

  • playerId
  • subId
  • vatId

Sample usage:

apiInterface.on(‘adstart’, function(eventObject){

alert(“ad started with vastId:” + eventObject.vastId);

});

adcomplete

Fires when the ad finishes playing. (Also valid if the user clicked Skip)

Event-specific data properties:

  • listCompleted - boolean.Will be true in case the Rotation is limited and last ad in the rotation is presented. (In-content unit is using this)
  • playerId
  • subId
  • vatId

Sample usage:

// adcomplete usage - player will get closed once there are no ads left to play
     apiInterface.on('adcomplete', function(eventObject) {
       if (eventObject.data.listCompleted) {
         eventObject.player.close();
       }
     });

adpause

Fires when a playing ad is paused.

Event data properties:

  • playerId
  • subId
  • vatId

adplay

Fires either when a new ad starts playing or when an ad is resumed after being paused.

Event data properties:

  • playerId
  • subId
  • vatId

content.started

Fires when a content video starts playing.

Event data properties:

  • playerId
  • subId

content.paused

Fires when a content video is paused either because the Player was paused or an ad started playing.

Event data properties:

  • playerId
  • subId

content.resumed

Fires when a content video is resumed, either because the Player was resumed or due to an ad that was playing and completed.

Event data properties:

  • playerId
  • subId

content.completed

Fires when a content video finishes playing.

Event data properties:

  • playerId
  • subId
  • src - string, url of the completed content video.
  • withErrors - boolean, true if the content stopped playing due to an error.
  • errorMsg - string, text of error if content was completed with error.
  • listCompleted - boolean, last video in content playlist.
  • loopCompleted - boolean, last video in content playlist and will not play in the loop (in case no loop, or number of loops is limited)

Sample usage:

// content.completed usage - new alert will be thrown if content was completed with error
     var listCompletedCount = 0;

     apiInterface.on('content.completed', function(eventObject) {
       if (eventObject.data.withErrors) {
         alert("there was an error during content video playing: " + eventObject.data.errorMsg);
       }

       if (eventObject.data.listCompleted) {
         listCompletedCount++;
         alert("all content videos were played " + listCompletedCount + " time" + (listCompletedCount > 1 ? "s" : ""));
       }

       // player will close once content has finished playing
       if (eventObject.data.loopCompleted) {
         eventObject.player.close();
       }
     });