PRODUCT
Follow

Methods

setPrimaryVideo(primaryVideoProperties)

Description

Sets the video to be the primary video.

Example

adkit.onReady(function(){ // Primary video represented by ordinal number      // Primary video will not play automatically adkit.vpaid.setPrimaryVideo({ sources: [1], autoPlay: false }); // Primary video represented by full url // primary video will play automatically after 2 seconds adkit.vpaid.setPrimaryVideo({ sources: ["http://mysite/video1.mp4"], autoPlayDelay: 2000 }); // Primary video represented by dynamic video service or streaming service // primary video will play automatically after 4 seconds adkit.vpaid.setPrimaryVideo({ sources: [{ src: "http://mysite/videoservice", type: "video/mp4"}], autoPlayDelay: 4000 }); });

Parameters

Name

Mandatory/Optional

Type

Description

primaryVideoIProperties

Mandatory

Object

Contains the primary video properties.

PrimaryVideoProperties Object

Name

Mandatory/Optional

Type

Description

sources

Mandatory

Array

An array of primary video sources.

Note

Currently only a single video source is supported.

The source can be one of the following:

  • A complete URL or an ordinal number of an additional asset.

  • Represented by a string or by an object.

    For example: {src: "http://mysite/myvideoservice", type: "video/mp4"}

autoPlay

Optional

Boolean

Determines whether to play the primary video automatically without a user interaction. The default value is true.

autoPlayDelay

Optional

Integer

The autoplay delay is set in milliseconds. The default value is 0.

The property is ignored if the autoPlay property is set to false.

pause()

Description

Pauses the primary video playback.

Example

              adkit.onReady(function(){
     adkit.vpaid.pause();
});          

play()

Description

Starts playing the primary video.

Example

              adkit.onReady(function(){
     adkit.vpaid.play();
});         

getVideoCurrentTime()

Description

Gets the current playing position of the primary video in seconds.

Return

Type: Number

Description: Playback position in seconds.

Example

              adkit.onReady(function(){
     var currentTime = adkit.vpaid.getVideoCurrentTime();
});
            

closeAd()

Closes the ad request.

Example

              adkit.onReady(function(){
    adkit.vpaid.closeAd();
});
          

skipAd()

Skips the ad request.

Example

              adkit.onReady(function(){
    adkit.vpaid.skipAd();
});
          

disableAutoClose()

Disables closing the ad automatically by the VPAID module.

Example

              adkit.onReady(function(){
    adkit.vpaid.disableAutoClose();
});



            

Video Event Registration Methods

Note

To view the full list of events, see AdKit: Event Registration Methods.

onVideoEvents(callback)

Registers to all primary video events.

onVideoEvents(event, callback)

Registers to a single primary video event.

onVideoEvents(eventList, callback)

Registers to the specified primary video events.

Example

              adkit.onReady(function(){
     // Register for single video event
     adkit.vpaid.onVideoEvents(adkit.vpaid.VIDEO_EVENTS.PLAY, function(event){
           // Do somethink
    });
    // Register for multiple video events
    var videoEvents = [adkit.vpaid.VIDEO_EVENTS.PLAY, adkit.vpaid.VIDEO_EVENTS.PAUSE];
    adkit.vpaid.onVideoEvents(videoEvents ,function(event){
                 switch(event.type) {
                    case adkit.vpaid.VIDEO_EVENTS.PLAY: 
                            // Handle play event
                            break;
                    case adkit.vpaid.VIDEO_EVENTS.PAUSE:
                            // Handle pause event

               } 
       });
       // Register for all video events
       adkit.vpaid.onVideoEvents(function(){
               switch(event.type) { 
                      // Handle events 
               }
          });
});

            

Parameters

Name

Mandatory/Optional

Type

Description

event

Optional

String

Primary video event.

eventlist

Optional

Array

Array of primary video events.

callback

Mandatory

Function

This function runs when a primary event that you have registered is fired.

Video Events

The following video events are the standard HTML video events.

Name

Description

ABORT

Fires when the loading of the primary video is aborted.

CAN_PLAY

Fires when the browser can start playing the primary video.

CAN_PLAY_THROUGH

Fires when the browser can play through the primary video without stopping for buffering.

DURATION_CHANGE

Fires when the duration of the primary video changes.

EMPTIED

Fires when the current playlist is empty.

ENDED

Fires when the current playlist ends.

ERROR

Fires when an error occurs during the loading of the primary video.

LOADED_DATA

Fires when the browser loads the current frame of the primary video.

LOADED_METADATA

Fires when the browser loads metadata for the primary video.

LOAD_START

Fires when the browser starts looking for the primary video.

PAUSE

Fires when the primary video pauses.

PLAY

Fires when the primary video starts or is no longer paused.

PLAYING

Fires when the primary video plays after being paused or stopped for buffering.

PROGRESS

Fires when the browser downloads the primary video.

RATE_CHANGE

Fires when the playing speed of the primary video changes.

SEEKED

Fires when the user finishes moving/skipping to a new position in the primary video.

STALLED

Fires when the browser tries to get media data, but data is not available.

SUSPEND

Fires when the browser is intentionally not getting media data.

TIME_UPDATE

Fires when the current playback position changes.

VOLUME_CHANGE

Fires when the volume changes.

WAITING

Fires when the primary video stops because it needs to buffer the next frame.

onCloseEnabled(closeEnabledCB)

Description

Registers to be notified when a close ad button can be enabled.

Example

              adkit.onReady(function(){
    adkit.vpaid.onCloseEnabled(function(){
        // Enable/Show close button
    });
});
            

Parameters

Name

Mandatory/Optional

Type

Description

closeEnabledCB

Mandatory

Function

This function runs when the event is fired.

onSkipEnabled(skipEnabledCB)

Description

Registers to be notified when a skip ad button can be enabled.

Example

              adkit.onReady(function(){
     adkit.vpaid.onSkipEnabled(function(){
          // Enable/Show skip button
     });
});
         

Parameters

Name

Mandatory/Optional

Type

Description

skipEnabledCB

Mandatory

Function

This function runs when the event is fired.

onAdEnd(adEndCB)

Description

Registered to be notified when the ad is about to close.

Example

              adkit.onReady(function(){
    adkit.vpaid.onAdEnd(function(){
         // Do something
    });
});

            

Parameters

Name

Mandatory/Optional

Type

Description

adEndCB

Mandatory

Function

This function runs when the event is fired.

onAdStart(adStartCB)

Description

Registers to be notified when the ad can start its logic.

Example

              adkit.onReady(function(){
     adkit.vpaid.onAdStart(function(){
          // For example: Start Animation
     });
});
          

Parameters

Name

Mandatory/Optional

Type

Description

adStartCB

Mandatory

Function

This function runs when the event is fired.

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

Comments