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, and then pass the ad placement ID to the load method.

public class MainScript : MonoBehaviour {

    void Start () {

        // Initialise the SDK (Skip this if you already initialised it elsewhere...)
        AwesomeAds.init(true); // In production usages set logging parameter to false

        // Makes the whole video surface clickable
        SAVideoAd.disableSmallClick();

        // Set config to production
        SAVideoAd.setConfigurationProduction();

        // Enables test ads
        SAVideoAd.enableTestMode();

        // Locks orientation to portrait
        SAVideoAd.setOrientationPortrait();

        // Enables the back button (Android only)
        SAVideoAd.enableBackButton();

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

        // Disables auto-closing at the end
        SAVideoAd.disableCloseAtEnd();

        // Starts loading ad data for a placement
        SAVideoAd.load(30479);
    }
}

Configuration Methods

Video ads have some default settings which can be configured using the methods detailed in the following table:

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(), enableCloseButtonWithWarning(), enableCloseButtonWithDelay(5.0)
Small click button Disabled enableSmallClickButton(), disableSmallClickButton()
Back button Enabled enableBackButton(), disableBackButton()

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.

var options = new Dictionary<string, string>
  {
    ["key"] = "value"
  };

string openRTBPartnerId = "1234";
SAVideoAd.load(30471, openRTBPartnerId, options);

Display the video ad

To display the ad, call play (passing the placement ID), using 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:

      using tv.superawesome.sdk.publisher;
    
      public class MainScript : MonoBehaviour {
    
          void Start() {
    
              // Initialise the SDK (Skip this if you already initialised it elsewhere...)
              AwesomeAds.init(true); // In production usages set logging parameter to false
    
              // Configure the video ad
              SAVideoAd.disableCloseButton();
    
              // Uses the adLoaded callback to trigger playing the video
              SAVideoAd.setCallback((placementId, evt) => {
    
              // When the video loads, play it directly
              if (evt == SAEvent.adLoaded) {
                  SAVideoAd.play(placementId);
              }
          });
    
              // Loads the video
              SAVideoAd.load(30479);
          }
      }
    
  • Use the hasAdAvailable method to play the ad on another event, such as when the user clicks a button in the app.

      using tv.superawesome.sdk.publisher;
    
      public class MainScript : MonoBehaviour {
    
          void Start() {
    
              // Configure the video
              SAVideoAd.disableCloseButton();
    
              // Loads the ad
              SAVideoAd.load(30479);
          }
    
          public void onClick() {
    
              // Checks if ad was loaded
              if (SAVideoAd.hasAdAvailable(30479)) {
    
                  // Optionally add some configuration before playing
                  SAVideoAd.setOrientationLandscape();
    
                  // Play the video
                  SAVideoAd.play(30479);
              }
          }
      }