Methods
Methods are called on the ad controller:
- in WebView —
window.myAdController; - in the browser —
controller.loader, wherecontrolleris whatadSDK.init()returns.
Playback control
| Method | Description |
|---|---|
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:
| Method | Description |
|---|---|
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
| Method | Type | Description |
|---|---|---|
getAdCreativeSrcURL() | string | Creative URL. |
getAdCreativeType() | string | Creative type. |
getAdCreativeBannerId() | string | Banner ID. |
getAdIsNoBanner() | boolean | true if the response contains no ad. |
getAdDuration() | number | Ad duration in milliseconds. |
getAdDurationInSec() | number | Ad duration in seconds. |
getAdCurrentTimeSec() | number | Current playback position in seconds. When the app's player plays the video, the last value passed to timeupdateAd(). |
getAdClickThroughUrl() | string | Click-through link to the advertiser's site. |
Skipping
| Method | Type | Description |
|---|---|---|
getAdSkippableState() | boolean | Whether the ad can be skipped right now. |
getAdIsSkippable() | boolean | Whether the ad supports skipping. |
getAdSkipTimeOffsetSec() | number | Seconds from the start until the ad becomes skippable (from VAST skipoffset). |
getAdSkipTime() | number | null | Seconds until the ad can be skipped (skipTime extension). |
getAdSkipTime2() | number | null | Seconds until the ad can be closed (skipTime2 extension). |
Ad pod
| Method | Type | Description |
|---|---|---|
getAdIsPod() | boolean | The ad is a pod of multiple ads. |
getAdPodLength() | number | Number of ads in the pod. |
Labeling and VAST extensions
| Method | Type | Description |
|---|---|---|
getAdTune() | object | null | Labeling data: show (1 / 0) — whether to show it, token — ERID, advertiserInfo — advertiser information. |
getAdTitle() | object | null | Ad label: show (1 / 0), domain, socialAdvertising (1 / 0). |
getAdTitleText() | string | Ready-made label text: "Ad", "Social ad", or the domain. |
getAdLinkTxt() | string | null | Call-to-action text for the click-through link. |
getAdStartTime() | number | null | Seconds from the start at which to show the linkTxt text. |
getAdIsClickable() | boolean | null | Whether the creative can be clicked. |
getAdCloseAct() | boolean | null | What to do after the click-through: true — close, false — pause. |
getAdSkipAd() | string | null | Ad-skip tracking link. |
getAdAddClick() | string | null | Link opened on click-through to the advertiser's site. |
getAdFiveSecondPoint() | string | null | Tracking link fired 5 seconds after the ad starts. |
getAdExtensions() | Map | All VAST extensions. |