Video Integration

On this page, you will find the integration documentation for your video adspace inside Android and iOS apps.

Getting Started

To set up a video adspace in your SPX inventory, all you have to do create a new adspace in SPX and select “Video” from the ad format dropdown.

As soon as you have done this, you will be given the following Video Type options:

NAME DESCRIPTION
Instream (Pre-Roll) A video ad playing in a video environment (e.g. video content streaming app) preceding the content.
Instream (Mid-Roll) A video ad playing in a video environment (e.g. video content streaming app) running between/interrupting the content.
Instream (Post-Roll) A video ad playing in a video environment (e.g. video content streaming app) following a content element.
Outstream A video ad playing outside of a dedicated video environment (e.g. a website article or a news feed.)
Interstitial Interstitial/fullscreen skippable video ad (previously referred to as VAST Video)
Rewarded Fullscreen non-skippable video ad

Recommended Ad Sizes

VIDEO TYPE RECOMMENDED AD SIZES
Interstitial Videos
  • 480*320, 320*480, 1024*768, 768*1024
Rewarded Videos
  • 480*320,1024*768 (we recommend to play Rewarded videos in Landscape Mode)
Outstream Videos
  • 300*250
Instream Videos
  • Depends on the Renditions you might use:
  • Low Definition Renditions: 640*360
  • Standard Definition Renditions: 854*480
  • High Definition Renditions: 1280*720
  • Full Definition Renditions: 1920*1080

Interstitial Video Adspaces

Android SDK Integrations

First, 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 on the VAST ads. Your IDE will ask you to implement the following methods:

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(MyActivity.this);
    }
    // Called when the banner has been loaded.
    public void onReadyToShow() {
        // TODO
        // Call this when you want to show the video ad.
        videoAd.show();
    }
 
    // Called when the ad will show.
    public void onWillShow() {
        // TODO
    }
 
    // Called when the banner has been clicked.
    public void onWillOpenLandingPage() {
        // TODO
    }
 
    // Called when Interstitial ad will be close.
    public void onWillClose() {
        // TODO
    }
 
    // called when banner failed to load.
    public void onFailedToLoadAd() {
        // TODO
    }
}

Of course, you will also need to provide your SPX Publisher ID and AdSpace IDs to the SDK. Please use the following code for that:

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

Lastly, to load a new Video Ad, use the following method:

videoAd.asyncLoadNewBanner();

iOS SDK Integrations

Integration is as simple as integrating an Interstitial Ad using the SOMAInterstitialVideoAdView class. Here is an example:

// Step 1: Instantiate and start loading
SOMAInterstitialAdView* adview = [[SOMAInterstitialVideoAdView alloc] init];
adView.delegate = self;
adView.load();
  
// Step 2:  Present the ad once loaded in the following SOMAAdViewDelegate method:
- (void)somaAdViewDidLoadAd:(SOMAAdView*)adview{
    adview.show();
}

Rewarded Video Adspaces

Android SDK Integrations

Similar to interstitial adspaces, rewarded 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.

To set up a rewarded adspace, you first need to add the following activity declaration to the rewarded video player in your AndroidManifest.xml:

<activity android:name="com.smaato.soma.video.VASTAdActivity">
</activity>

Next, you need to instantiate a rewarded video object in the activity where you want to show rewarded video ads and to implement the RewardedVideoListener interface to have more control over the rewarded video ads.

import com.smaato.soma.video.RewardedVideo;
import com.smaato.soma.video.RewardedVideoListener;
 
public class MyActivity extends Activity implements RewardedVideoListener {
 
    RewardedVideo rewardedVideo;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rewardedvideo_sample);
        rewardedVideo = new RewardedVideo(MyActivity.this);
    }
 
    // Called when the banner has been loaded.
    @Override
    public void onReadyToShow() {
        rewardedVideo.show();   // call this when to show the RewardedVideo ad.
    }
 
        // Called when the ad will be displayed.
        @Override
        public void onWillShow() { }
 
        // Called when the RewardedVideo or the EndCard is clicked after video completion
        @Override
        public void onWillOpenLandingPage () { }
 
        // Called when the ad is closed.
        @Override
        public void onWillClose () { }
 
        // Called when there is No ad or Ad failed to Load
        @Override
        public void onFailedToLoadAd () { }
 
        @Override
        public void onRewardedVideoStarted () { }
 
        @Override
        public void onFirstQuartileCompleted () { }
 
        @Override
        public void onSecondQuartileCompleted () { }
 
        @Override
        public void onThirdQuartileCompleted () { }
 
        // Called when the Video ad display completed.
        @Override
        public void onRewardedVideoCompleted () { } // TODO
 
    } 

You can configure an auto-close duration in seconds, to auto-close after completion of the rewarded video ad.

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

You can also completely disable the auto close feature using:

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

Of course, you will also need to provide the SDK with your Smaato Publisher ID and AdSpace ID using the following code:

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

Finally, to load a new Video Ad, use the following method:

rewardedVideo.asyncLoadNewBanner();

iOS SDK Integrations

Similar to interstitial video ad units, rewarded video ads are shown in fullscreen mode. The video ad will be cached in the background thread and will be waiting for a signal to show up.

To integrate a rewarded ad you will need to you the following SOMARewardedVideo class:

// Step 1: Instantiate and start loading
SOMARewardedVideo* adview = [[SOMARewardedVideo alloc] init];
adView.delegate = self;
[adView load];
 
   
// Step 2:  Present the ad once loaded in the following SOMAAdViewDelegate method:
- (void)somaAdViewDidLoadAd:(SOMAAdView*)adview{
    if(adview.isLoaded) {
        [adview show]; /* Before showing an ad, we recomment you to check if the ad is in loaded state using adView.isLoaded property. */
    }
}

You can track different events such as video started, 25%, 50%, 75%, and 100 % completion for rewarded video using didReceiveVideoAdEvent delegate as described below:

- (void)somaAdView:(SOMAAdView *)adview didReceiveVideoAdEvent:(SOMAVideoAdTrackingEvent)event {
    if (event == SOMAVideoAdTrackingEventStart) {
        NSLog(@"Video Ad Started");
    } else if (event == SOMAVideoAdTrackingEventFirstQuartile) {
        NSLog(@"Video Ad reached first quartile");
    } else if (event == SOMAVideoAdTrackingEventMidpoint) {
        NSLog(@"Video Ad reached mid point");
    } else if (event == SOMAVideoAdTrackingEventThirdQuartile) {
        NSLog(@"Video Ad reached third quartile");
    } else if (event == SOMAVideoAdTrackingEventComplete) {
        NSLog(@"Video Ad Completed");
    }
}

Publishers can set the allowHTTPVideo flag to YES if ATS for the application has been disabled. Here is an example:

adView.adSettings.allowHTTPVideo = YES; // Default is set to NO

Modified: September 30, 2019 at 10:36 am