Banner Video (Beta)

xGrowth SDK also gives the option to load and show in-stream video ad inside a banner format/placement.

Create your AdRequestConfiguration as per the below format:

val configuration = AdRequestConfiguration.Companion.builder(context, "Your_placement_name");

Load and show Banner Video Ad

1

Create and load the Banner Video Ad

Call loadAd() with an ad loader configured with listeners.

Java
AdSterAdLoader.Companion.builder().withAdsListener(new MediationAdListener() {
    @Override
    public void onBannerVideoAdLoaded (@NonNull MediationBannerVideoAd ad){
        //Use the ad object provided here to display the ad
    }

    @Override
    public void onFailure (@NonNull AdError adError){ }
}).withAdsEventsListener(new AdEventsListener() {
    @Override
    public void onAdClicked() {
        //Handle ad click here
    }

    @Override
    public void onAdImpression() {
        //Handle ad impression here
    }

    @Override
    public void onAdRevenuePaid(double revenue, @NotNull String adUnitId,@NotNull String network) {
        // Callback which provides revenue and the network which provided it
    }
}).build().loadAd(configuration.build());
2

Handle lifecycle: pause, resume, destroy

Use the pause(), resume() and destroy() functions of the ad object provided in onBannerVideoAdLoaded(MediationBannerVideoAd ad) to pause, resume and destroy the video when the fragment or the activity is being paused, resumed and destroyed respectively.

Choose the Java or Kotlin example below.

Java
private MediationBannerVideoAd bannerVideoAd = null;

@Override
protected void onPause() {
    super.onPause();
    if (bannerVideoAd != null) {
        bannerVideoAd.pause();
    }
}

@Override
protected void onResume() {
    super.onResume();
    if (bannerVideoAd != null) {
        bannerVideoAd.resume();
    }
}

@Override
protected void onDestroy() {
    super.onDestroy();
    if (bannerVideoAd != null) {
        bannerVideoAd.destroy();
    }
}
circle-info

The ad object is provided in onBannerVideoAdLoaded(MediationBannerVideoAd ad). Keep a reference to it so you can call pause(), resume(), and destroy() at the appropriate lifecycle events.

Last updated