API Reference
This article acts a reference to the API configuration options AdPlayer.Pro supports.
Supported Methods
Method | Usage | Description |
pauseAd() |
AdPlayerPro.pauseAd() |
The video player calls pauseAd() to prompt the ad unit to pause ad display.
The ad unit responds by suspending any audio, animation or video and then sending the AdPaused event. |
resumeAd() |
AdPlayerPro.resumeAd() |
Following a call to pauseAd(), the video player calls resumeAd() to continue ad playback.
The ad unit responds by resuming playback and sending the AdPlaying event to confirm. |
stopAd() |
AdPlayerPro.stopAd() |
The video player calls stopAd() when it will no longer display the ad or needs to cancel the ad unit.
The ad unit responds by closing the ad, cleaning up its resources and then sending the AdStopped event. |
skipAd() |
AdPlayerPro.skipAd() |
Configures skip controls that the video player may implement.
The video player calls skipAd() when a user activates a skip control implemented by the video player. When called, the ad unit responds by closing the ad, cleaning up its resources and sending the AdSkipped event. |
setAdVolume(value) |
AdPlayerPro.setAdVolume(value) |
Configures the volume option.
Supported values: from 0 to 1 Example: 1 = 100% Volume, 0.5 = 50% Volume. |
getAdVolume() |
AdPlayerPro.getAdVolume() |
Returns details regarding the current ad playback volume. |
resizeAd(int width, int height) |
AdPlayerPro.resizeAd(int width, int height) |
Provides an option to get player resized |
getAdWidth() |
AdPlayerPro.getAdWidth() |
Returns the Width value of the currently playing ad (player). |
getAdHeight() |
AdPlayerPro.getAdHeight() |
Returns the Height value of the currently playing ad (player). |
getAdRemainingTime() |
AdPlayerPro.getAdRemainingTime() |
The video player may use the adRemainingTime property to update player UI during ad playback, such as displaying a playback counter or other ad duration indicator.
The adRemainingTime property is provided in seconds and is relative to the total duration value, provided in the adDuration property. |
getAdDuration() |
AdPlayerPro.getAdDuration() |
Returns the total ad duration in seconds. |
getAdSkippableState() |
AdPlayerPro().getAdSkippableState() |
The video player calls getAdSkippableState() to сheck the current ad unit [skippability] status, i.e. whether it’s possible to skip the ad, or not.
When called, the ad unit responds by returning the “true” or “false” value, depending on whether the AdSkippableStateChange event has been sent or not, accordingly. |
remove() |
AdPlayerPro.remove() |
When called, removes the player instance. |
Supported Events
Event | Usage | Description |
AdLoaded |
AdPlayerPro.on('AdLoaded', function(){}); |
As soon as ad is ready for display, the ad dispatches the AdLoaded event. |
AdStarted |
AdPlayerPro.on('AdStarted', function(){}); |
The AdStarted event is sent by the ad unit to notify the video player that the ad is displaying. |
AdVideoStart |
AdPlayerPro.on('AdVideoStart', function(){}); |
These five events are sent by the ad unit to notify the video player of the ad unit’s video progress and are used in VAST under the same event names. |
AdVideoFirstQuartile |
AdPlayerPro.on('AdVideoFirstQuartile', function(){}); |
|
AdVideoMidpoint |
AdPlayerPro.on('AdVideoMidpoint', function(){}); |
|
AdVideoThirdQuartile |
AdPlayerPro.on('AdVideoThirdQuartile', function(){}); |
|
AdVideoComplete |
AdPlayerPro.on('AdVideoComplete', function(){}); |
|
AdStopped |
AdPlayerPro.on('AdStopped', function(){}); |
The AdStopped event is sent by the ad unit to notify the video player that the ad has stopped displaying and all ad resources have been cleaned up.
This event is only for responding the stopAd() method call made by the video player. |
AdSkipped |
AdPlayerPro.on('AdSkipped', function(){}); |
The AdSkipped event is sent by the ad unit to notify the video player that the ad has been skipped, stopped displaying and all ad resources have been cleaned up. |
AdPaused |
AdPlayerPro.on('AdPaused', function(){}); |
The AdPaused event is sent in response to the pauseAd() method call to confirm that the ad is either paused or stopped.
Sending AdPaused indicates that the ad has stopped all audio and any animation in progress. |
AdPlaying |
AdPlayerPro.on('AdPlaying', function(){}); |
The AdPaused and AdPlaying events are sent in response to the pauseAd() and resumeAd() method calls to confirm that the ad has either paused or is playing.
Sending AdPlaying indicates that the ad unit has resumed playback from the point at which it was paused. |
AdError |
AdPlayerPro.on('AdError', function(message, error){}); |
The AdError event is sent when the ad unit has experienced a fatal error.
Before the ad unit sends AdError it must clean up all resources and cancel any pending ad playback. |
AdVolumeChange |
AdPlayerPro.on('AdVolumeChange', function(){}); |
AdVolumeChange event is dispatched to notify the video player of the change. |
AdSkippableStateChange |
AdPlayerPro.on('AdSkippableStateChange', function(){}); |
The AdSkippableStateChange event is sent at the point when the ad unit becomes skippable, i.e. when it becomes possible to skip the ad. |
AdClickThru |
AdPlayerPro.on('AdClickThru', function(){}); |
The AdClickThru event is sent when an ad click-through, i.e. a click on the ad, occurs. |
AdUserClose |
AdPlayerPro.on('AdUserClose', function(){}); |
The AdUserClose event is sent when a user’s click on the “Close” button on the ad occurs. |
Code Examples
Example 1:
Describing all logic (methods, events processing – just in a row):
<div id="divAdPlayerPro"></div> <script src="https://static.adplayer.pro/player/AdPlayerPro.js"></script> <script>(function () { AdPlayerPro("divAdPlayerPro").setup({ "placementId": "E4PwNl4FEpNx", "muted": true, "autoStart": true, "width": "640", "height": "360", "type": "inPage", "advertising": { "tag": [ { "url": "https://static.adplayer.pro/vast/demo.xml", } ] } }).on('AdStarted', function() {alert('started')}) })(); </script>
Example 2:
<div id="divAdPlayerPro"></div> <script src="https://static.adplayer.pro/player/AdPlayerPro.js"></script> <script>(function () { var adPlayerPro = AdPlayerPro("divAdPlayerPro").setup({ "placementId": "E4PwNl4FEpNx", "muted": true, "autoStart": true, "width": "640", "height": "360", "type": "inPage", "advertising": { "tag": [ { "url": "https://static.adplayer.pro/vast/demo.xml", } ] } }); //describing the logic adPlayerPro.on('AdStarted', function(){alert('ad has been started...')}); adPlayerPro.on('AdVideoMidpoint', function(){adPlayerPro.pauseAd()}); //etc })(); </script>