Skip to content

Methods

Methods are called on the ad controller:

  • in WebView — window.myAdController;
  • in the browser — controller.loader, where controller is what adSDK.init() returns.

Playback control

MethodDescription
loadAd(url, settings)Load an ad from a VAST link. In WebView, the SDK calls this itself when the page opens.
playAd()Start or resume playback.
pauseAd()Pause playback.
stopAd()End playback and release resources.
skipAd()Skip the ad. Call it after AdSkippableStateChanged with status: true.
clickAd()Follow the ad's click-through link, as if the user had clicked the creative.
errorAd()Abort playback with an error. The SDK sends VAST error 403 and fires AdError.
disableAd()Report that ads have been disabled. The SDK sends AdDisable.
setVolume(level)Set volume from 0 to 1.
setMuted(muted)Turn mute mode on (true) or off (false).
resizeAd(width, height, viewMode)Tell the player its new size. viewMode is 'fullscreen' or 'normal'. The SDK tracks window resizes on its own; call this method only when just the container's size changes.
timeupdateAd(time, duration)Report the app player's playback time to the SDK, in seconds. WebView only. Call it on every player time update, and timeupdateAd(duration, duration) when the ad ends. See Playback flow.
setFocusToPlayer()Move focus to the interactive creative. Needed on Android TV and in the browser for keyboard control.
destroy()Stop playback and unsubscribe all handlers.

Browser only:

MethodDescription
on(name, callback)Subscribe to an event. Returns { unsubscribe() }.
off(name, callback)Unsubscribe from an event.

Ad information

Values are available after the AdLoaded event. Fields coming from VAST extensions are null if the extension is absent.

Creative

MethodTypeDescription
getAdCreativeSrcURL()stringCreative URL.
getAdCreativeType()stringCreative type.
getAdCreativeBannerId()stringBanner ID.
getAdIsNoBanner()booleantrue if the response contains no ad.
getAdDuration()numberAd duration in milliseconds.
getAdDurationInSec()numberAd duration in seconds.
getAdCurrentTimeSec()numberCurrent playback position in seconds. When the app's player plays the video, the last value passed to timeupdateAd().
getAdClickThroughUrl()stringClick-through link to the advertiser's site.

Skipping

MethodTypeDescription
getAdSkippableState()booleanWhether the ad can be skipped right now.
getAdIsSkippable()booleanWhether the ad supports skipping.
getAdSkipTimeOffsetSec()numberSeconds from the start until the ad becomes skippable (from VAST skipoffset).
getAdSkipTime()number | nullSeconds until the ad can be skipped (skipTime extension).
getAdSkipTime2()number | nullSeconds until the ad can be closed (skipTime2 extension).

Ad pod

MethodTypeDescription
getAdIsPod()booleanThe ad is a pod of multiple ads.
getAdPodLength()numberNumber of ads in the pod.

Labeling and VAST extensions

MethodTypeDescription
getAdTune()object | nullLabeling data: show (1 / 0) — whether to show it, token — ERID, advertiserInfo — advertiser information.
getAdTitle()object | nullAd label: show (1 / 0), domain, socialAdvertising (1 / 0).
getAdTitleText()stringReady-made label text: "Ad", "Social ad", or the domain.
getAdLinkTxt()string | nullCall-to-action text for the click-through link.
getAdStartTime()number | nullSeconds from the start at which to show the linkTxt text.
getAdIsClickable()boolean | nullWhether the creative can be clicked.
getAdCloseAct()boolean | nullWhat to do after the click-through: true — close, false — pause.
getAdSkipAd()string | nullAd-skip tracking link.
getAdAddClick()string | nullLink opened on click-through to the advertiser's site.
getAdFiveSecondPoint()string | nullTracking link fired 5 seconds after the ad starts.
getAdExtensions()MapAll VAST extensions.