Video ads

This section provides details and examples of how to configure, load, and display a video ad. You can display the ad when it loads, or on some other specific event; for example, when the user clicks a button.

Set up and load a video ad

Before you can display an ad on your app or site, you first need to set the required configuration items, and then pass the ad placement ID to the load method. For example:

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // to display test ads
        SAVideoAd.enableTestMode();

        // set configuration to production
        SAVideoAd.setConfigurationProduction();

        // lock orientation to portrait or landscape
        SAVideoAd.setOrientationLandscape();

        // enable or disable the android back button
        SAVideoAd.enableBackButton();

        // enable or disable a close button that displays without a delay. Use instead of enableCloseButton.
        // WARNING: this will allow users to close the ad before the viewable tracking event is fired
        // and should only be used if you explicitly want this behavior over consistent tracking.
        SAVideoAd.enableCloseButtonNoDelay();

        // enable close button and warn user before closing
        SAVideoAd.enableCloseButtonWithWarning();

        // enable or disable auto-closing at the end
        SAVideoAd.disableCloseAtEnd();

        // make the whole video surface area clickable
        SAVideoAd.disableSmallClickButton();
    
        // mute the video on start
        SAVideoAd.enableMuteOnStart();

        // start loading ad data for a placement
        SAVideoAd.load(30480, MainActivity.this);
    }
}
Parameter Default value Configure using
Configuration Production setConfigurationProduction()
Test mode Disabled enableTestMode(), disableTestMode()
Orientation Any setOrientationPortrait(), setOrientationLandscape(), setOrientationAny()
Closes at end True enableCloseAtEnd(), disableCloseAtEnd()
Close button Disabled enableCloseButton(), disableCloseButton(), enableCloseButtonNoDelay(), enableCloseButtonWithDelay(5.0)
Small click button Disabled enableSmallClickButton(), disableSmallClickButton()
Back button Enabled enableBackButton(), disableBackButton()
Close with warning Disabled setCloseButtonWarning(true), setCloseButtonWarning(false)
Mute on start Disabled enableMuteOnStart(), disableMuteOnStart()

Aditional load parameters

You can also send additional options during the load() call as well as an optional OpenRTB partner ID. Both parameters are optional.

Map<String, Object> options = new HashMap<>();
options.put("key", "value");
String openRTBPartnerId = "1234";
SAVideoAd.load(30471, openRTBPartnerId, options);
val options = mapOf("key", "value")
val openRTBPartnerId = "1234"
SAVideoAd.load(30471, openRTBPartnerId, options)

Display the video ad

To display the ad, you can use either the adLoaded callback or the hasAdAvailable method.

  • Use the adLoaded callback to display the ad as soon as it is loaded. Add the callback before you call the load method. For example:
      // imports ...
      import tv.superawesome.sdk.publisher.*;
    
      public class MainActivity extends Activity {
    
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
    
              // set up the bumper page and disable the close button
              SAVideoAd.disableParentalGate();
              SAVideoAd.enableBumperPage();
              SAVideoAd.disableCloseButton();
                
              // use the adLoaded callback to trigger playing the ad
              SAVideoAd.setListener(new SAInterface() {
                  @Override
                  public void onEvent(int placementId, SAEvent event) {
                      // when the ad loads, play it directly
                      if (event == SAEvent.adLoaded) {
                          SAVideoAd.play(MainActivity.this);
                      }
                  }
              });
        
              // load the video
              SAVideoAd.load(30480, MainActivity.this);
          }
      }
    
  • Use the hasAdAvailable method to play the ad on some other event, such as when the user clicks a button in the app. For example:
      // imports ...
      import tv.superawesome.sdk.publisher.*;
    
      public class MainActivity extends Activity {
    
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
    
              // set app context
              SuperAwesome.getInstance().setApplicationContext(getApplicationContext());
    
              // set up the bumper page and disable the close button
              SAVideoAd.disableParentalGate();
              SAVideoAd.enableBumperPage();
              SAVideoAd.disableCloseButton();
    
              // load the video
              SAVideoAd.load(30480, MainActivity.this);
          }
    
          public void onClick(View view) {
              // check if ad is loaded
              if (SAVideoAd.hasAdAvailable(30480)) {
    
                  // set the video orientation
                  SAVideoAd.setOrientationAny();
    
                  // and play
                  SAVideoAd.play(30480, MainActivity.this);
              }
          }
      }