@mailonline/video-ad-sdk

Video ad SDK to load and play HTML5 video ads.

Source:

Methods

(static) getDetails(vastChain) → {VastChainDetails}

Returns a summary of the passed VastChain.

Parameters:
Name Type Description
vastChain VastChain

the VastChain from which we want the details.

Source:

(async, static) requestAd(adTag, options, vastChainopt) → {Promise.<VastChain>}

Request the ad using the passed ad tag and returns an array with the VAST responses needed to get an inline ad.

Parameters:
Name Type Attributes Description
adTag string

The VAST ad tag request url.

options Object

Options Map. The allowed properties are:

Properties
Name Type Attributes Description
wrapperLimit number <optional>

Sets the maximum number of wrappers allowed in the VastChain. Defaults to 5.

AllowMultipleAds boolean <optional>

Boolean to indicate whether adPods are allowed or not. Defaults to true.

timeout number <optional>

timeout number in milliseconds. If set, the request will timeout if it is not fulfilled before the specified time.

vastChain VastChain <optional>

Optional vastChain with the previous VAST responses.

Source:

(async, static) requestNextAd(VastChain, options) → {Promise.<VastChain>}

Requests the next ad in the VAST Chain.

Parameters:
Name Type Description
VastChain VastChain

Array of VastResponse.

options Object

Options Map. The allowed properties are:

Properties
Name Type Attributes Description
wrapperLimit number <optional>

Sets the maximum number of wrappers allowed in the vastChain. Defaults to 5.

AllowMultipleAds boolean <optional>

Boolean to indicate whether adPods are allowed or not. Defaults to true.

track tracker <optional>

optional function to track whatever errors occur during the loading. Defaults to @mailonline/video-ad-tracker track method.

useAdBuffet boolean <optional>

Specifies whether to use buffet ads from an ad pod if possible. If no buffet ad is available it will return the next ad in ad pod sequence. Set it to true if an ad from an adPod failed and you want to replace it with an ad from the ad buffet. Defaults to false.

fallbackOnNoAd boolean <optional>

tells the video player to select an ad from any stand-alone ads available. Note: if the VastChain contains an adPod this property will be ignored. Defaults to true.

timeout number <optional>

timeout number in milliseconds. If set, the request will timeout if it is not fulfilled before the specified time.

Source:

(async, static) run(vastChain, placeholder, optionsopt) → {Promise.<(VastAdUnit|VpaidAdUnit)>}

Will try to start video ad in the passed VastChain and return the started VideoAdUnit.

Parameters:
Name Type Attributes Description
vastChain VastChain

The VastChain with all the VastResponses.

placeholder HTMLElement

placeholder element that will contain the video ad.

options Object <optional>

Options Map. The allowed properties are:

Properties
Name Type Attributes Description
onAdReady runWaterfall~onAdReady

will be called once the ad is ready with the ad unit.

videoElement HTMLVideoElement <optional>

optional videoElement that will be used to play the ad.

logger Console <optional>

Optional logger instance. Must comply to the Console interface. Defaults to window.console

viewability boolean <optional>

if true it will pause the ad whenever is not visible for the viewer. Defaults to false

responsive boolean <optional>

if true it will resize the ad unit whenever the ad container changes sizes. Defaults to false

timeout number <optional>

timeout number in milliseconds. If set, the video ad will time out if it doesn't start within the specified time.

tracker TrackerFn <optional>

If provided it will be used to track the VAST events instead of the default pixelTracker.

hooks Object <optional>

Optional map with hooks to configure the behaviour of the ad.

Properties
Name Type Attributes Description
createSkipControl function <optional>

If provided it will be called to generate the skip control. Must return a clickable HTMLElement that is detached from the DOM.

Source:
Throws:

if there is an error starting the ad or it times out (by throw I mean that it will reject promise with the error).

(static) runWaterfall(adTag, placeholder, optionsopt) → {function}

Will try to start one of the ads returned by the adTag. It will keep trying until it times out or it runs out of ads.

Parameters:
Name Type Attributes Description
adTag string

The VAST ad tag request url.

placeholder HTMLElement

placeholder element that will contain the video ad.

options Object <optional>

Options Map. The allowed properties are:

Properties
Name Type Attributes Description
videoElement HTMLVideoElement <optional>

optional videoElement that will be used to play the ad.

logger Console <optional>

Optional logger instance. Must comply to the Console interface. Defaults to window.console

wrapperLimit number <optional>

Sets the maximum number of wrappers allowed in the VastChain. Defaults to 5.

onAdReady runWaterfall~onAdReady <optional>

will be called once the ad is ready with the ad unit.

onAdStart runWaterfall~onAdStart <optional>

will be called once the ad starts with the ad unit.

onError runWaterfall~onError <optional>

will be called if there is an error with the video ad with the error instance and an obj with the VastChain and the ad unit if it exists.

onRunFinish runWaterfall~onRunFinish <optional>

will be called whenever the ad run finishes.

viewability boolean <optional>

if true it will pause the ad whenever is not visible for the viewer. Defaults to false

responsive boolean <optional>

if true it will resize the ad unit whenever the ad container changes sizes. Defaults to false

timeout number <optional>

timeout number in milliseconds. If set, the video ad will time out if it doesn't start within the specified time.

tracker TrackerFn <optional>

If provided it will be used to track the VAST events instead of the default pixelTracker.

vpaidEnabled boolean <optional>

if false and it gets a VPAID ad, it will throw an error before starting the ad and continue down in the waterfall. Defaults to true.

hooks Object <optional>

Optional map with hooks to configure the behaviour of the ad.

Properties
Name Type Attributes Description
createSkipControl function <optional>

If provided it will be called to generate the skip control. Must return a clickable HTMLElement that is detached from the DOM.

validateVastResponse function <optional>

If provided it will be called passing the current VastChain for each valid vast response. Must throw if there is a problem with the vast response. If the Error instance has an code number then it will be tracked using the error macros in the Vast response. It will also call runWaterfall~onError with the thrown error.

transformVastResponse function <optional>

If provided it will be called with the current VastChain before building the adUnit allowing the modification of the vastResponse if needed.

Source: