Video ads in WEB games

To implement video ads in your HTML game it must use our javascript SDK.

To display an ad to your player follow these two steps:

  1. Make sure that video ad is available for current user with SDK-method ui.prepareMidroll.
    • If method responded without an error ad is ready to be shown to a user. Only after this you can show user an invitation to view an ad in your UI.
    • If an error occurred when method was invoked then it is most likely that no ads are available to be shown to current user. Retry getting an ad after some time. UI invitation to view an ad should not be shown when there is no prepared video to play.
    • We highly recommend to renew prepared video ad every 5 or so minutes since a prepared video can be expired.
  2. If user agreed to view an ad to initiate this process you need to use SDK-method ui.showMidroll.
    • If video is indeed prepared, it will be shown to user. It will be shown on top of the game’s UI and game itself will be faded.
    • After video is viewed you’ll get response from API (callback).
    • It’s important to know that in case of user navigating to another browser window or closing browser an ad will be stopped from playing. It will only continue playing if browser window is opened and active.

Video ads in Mobile HTML games (Instant games)

To implement video ads in a mobile app you should use OKSDK.Ads methods in a following order:

Test application

If you want to check how video ads are working for both WEB and Instant applications you can use our test application:

To view an add do the following:

  • press a button “prepare midroll”;
  • press a button “show midroll”.


  • press a button “inject frame”;
  • press a button “prepare midroll”;
  • press a button “show”.


Ad is counted as viewed only if:

  • it was played for a at least 10 seconds;
  • a response “showMidroll$ok$complete” was returned after an ad was played.

If you have any questions about how to implement video ads in our game, how they work or how the statistics are counted you can sent an email with your question to