Video Ads | Android

Similar to Interstitial Ads, Video Ads are shown in fullscreen mode and can be placed before, in-between, or after the app content. The Video Ad will be loaded in the background and will be waiting for a signal to show up.

First, the Video Player requires activity declaration in your AndroidManifest.xml:

<activity android:name="com.smaato.soma.video.VASTAdActivity" android:configChanges="keyboardHidden|orientation|screenSize" />

Second, you need to instantiate a Video Object in the activity where you want to show video ads and to implement the VASTAdListener interface to have more control over the Video Ads. Your IDE will ask you to implement the following method:

import com.smaato.soma.video.VASTAdListener;
public class MyActivity implements VASTAdListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.myLayout);
        Video videoAd = new Video(this);
    }
    // Called when the video has been loaded.
    public void onReadyToShow() {
        // Call this when you want to show the video ad.
        videoAd.show();
    }

    public void onWillShow() {
        // Called when the ad will show.
    }

    public void onWillOpenLandingPage() {
        // Called when the banner has been clicked.
    }

    public void onWillClose() {
        // Called when Interstitial ad will be closed.
    }

    public void onFailedToLoadAd() {
        // called when video failed to load.
    }
}

Third, you will need to provide the SDK with your Smaato Publisher ID and the AdSpace IDs. Please use the following lines:

videoAd.getAdSettings().setPublisherId(REPLACE_WITH_YOUR_PUBLISHER_ID);
videoAd.getAdSettings().setAdspaceId(REPLACE_WITH_YOUR_ADSPACE_ID);

Last, you need to load a new Video Ad using the following method:

videoAd.asyncLoadNewBanner();

Auto-Close Feature

With the current Android SDK you can configure an auto-close duration in seconds as well as an auto-close after a given number of seconds upon Interstitial Video Ad completion.

By default, auto-close is enabled meaning after the video completion, the ad will automatically close after the default of 3 seconds.

videoAd.setAutoCloseDuration(5);   // default value is 3 seconds

You can also completely disable the auto-close feature on VAST Ad completion.

videoAd.disableAutoClose(true);   // default value is false.

Configurable Skip button

From Android SDK version 5.1 and on, you can also configure a skip button appearance after a duration in seconds. By default, videos are skippable after 15 seconds.

videoAd.setVideoSkipInterval(5);   // default value is 5 seconds

Modified: July 26, 2019 at 4:19 pm