Skip to content

WebView: shared flow

On Android, Android TV, and iOS, the app opens the SDK page in a WebView. The flow is the same on all three platforms; only the way you receive events and your player code differ. Platform-specific details are on the Android, Android TV, and iOS pages.

Page address

https://cdn.adsdk.ru/android/v3/?url=https%3A%2F%2Fads.example.com%2Fvast.xml&lang=ru&controls=%5B%22ad-skip-btn%22%5D

The platform and the version are part of the path; playback settings are parameters. The same files are also served at https://adsdk.ru/sdk/… — for example https://adsdk.ru/sdk/android/v3/.

Platform

PathPlatform
/android/Android phones and tablets
/androidtv/Android TV
/ios/iPhone, iPad
/web/The browser package, see Browser

Version

ChannelExampleWhat you getUse it for
Majorv3Every 3.x fix and feature, never a breaking changeRecommended for production
Exact versionv3.0.0This build exactly; it never changesFull control over updates
latestlatestThe newest release, majors includedDebugging only: the next major release breaks your integration

Moving to the next major version (v4) is a deliberate upgrade: read “Before you upgrade” in the releases first. The SDK always reports its exact version to the ad server through , even when a channel is loaded.

Parameters

ParameterRequiredDescription
urlVAST tag, encoded with encodeURIComponent.
lang, controls, autoplay, …See Parameters.
Anything elseAppended to the VAST URL unchanged — a way to pass macros to the ad server.

Who plays the video

The main mode is the app player. The ad runs through the same player as your content: with hardware decoding, the same quality, and no re-buffering inside the WebView.

Playback flow

What the app does

WhenWhat to call
AdLoaded arrivesLoad the video file address into your player.
The player starts playingplayAd()
Every player position update (~4 times a second)timeupdateAd(position, duration) in seconds
The user paused / resumedpauseAd() / playAd()
The ad endedtimeupdateAd(duration, duration)
AdSkipped or AdError arrivesStop the player.
AdClick arrivesOpen url in the browser.
AdDestroyed arrives with ad_is_last = trueClose the WebView, return to the content.

App and SDK connection

  • Methods are called by executing JavaScript in the WebView: window.myAdController.<method>(...). See the list under Methods.
  • Events on Android arrive as calls to methods of the Android JavaScript interface; on iOS, as messages to the AdEventsHandler handler. See the list and formats under Events.

Transparent WebView

The SDK page is transparent. Make the WebView itself transparent too, or the ad won't be visible: Android — setBackgroundColor(Color.TRANSPARENT), iOS — isOpaque = false and backgroundColor = .clear.

Page opened inside a frame

window.myAdController is created in the window of the SDK page. If the WebView loads it inside an iframe, access the controller through window.top.myAdController.