Skip to main content

Preroll Ads

Preroll ads are video ads that play before your content video. The package creates the player for you and shows it on top of the Unity view. The ad auto-plays.

Each ad format uses a Zone ID to identify the ad placement. Zone IDs are configured in the Empower dashboard.

tip

Load the preroll when your video screen opens, and destroy it when the screen closes.


Loading a Preroll Ad​

EmpowerAds.LoadPrerollAd(
"YOUR_PREROLL_ZONE_ID",
"https://example.com/your-content-video.mp4");

Parameters​

ParameterTypeRequiredDefaultDescription
zoneIdstringYesnoneThe zone ID for the preroll placement
contentUrlstringYesnoneURL of the content video that plays after the ad
mutedboolNofalseWhether playback starts muted

The player is a full-width 16:9 strip, centered on the screen on Android and at the top of the screen on iOS.

warning

Unity UI under the player does not receive touches until you call DestroyPreroll. Keep your controls outside that area.

iOS

On iOS the content video does not play after the ad yet. The player shows the ad only.


Listening to Preroll Events​

The SDK handles playback

The events are optional. Use them only if you need to track ad states for analytics or UI updates.

OnPrerollEvent delivers the event name, the zone ID and an error message:

Event nameRaised when
onAdReadyAd loaded and about to auto-play
onAdStartedAd playback started
onAdCompletedAd finished
onAdSkippedUser skipped the ad
onAdFailedAd failed. The error argument holds the message
onAdClickedUser clicked the ad

If you need to react to preroll events:

void OnEnable()
{
EmpowerAds.OnPrerollEvent += HandlePrerollEvent;
}

void OnDisable()
{
EmpowerAds.OnPrerollEvent -= HandlePrerollEvent;
}

private void HandlePrerollEvent(string eventName, string zoneId, string error)
{
if (zoneId != "YOUR_PREROLL_ZONE_ID") return;

switch (eventName)
{
case "onAdStarted":
break;
case "onAdCompleted":
break;
case "onAdFailed":
break;
}
}
iOS

The event names differ on iOS: started, completed, skipped and failed. Ready and clicked arrive as the Ready and Clicked statuses on OnPrerollStatusChanged.

OnPrerollStatusChanged reports the ad status in the same way as the other formats: Initializing, Ready, Shown, CompletePlaying, Skipped and Failed.


Lifecycle Management​

EmpowerAds.PausePreroll("YOUR_PREROLL_ZONE_ID");

EmpowerAds.ResumePreroll("YOUR_PREROLL_ZONE_ID");

// Remove the player when the video screen closes
EmpowerAds.DestroyPreroll("YOUR_PREROLL_ZONE_ID");

EmpowerPrerollAd Component (Optional)​

If you prefer the Inspector, attach the EmpowerPrerollAd component to a GameObject and set its Zone Id and Content Url. It loads the preroll in Start, pauses it while the GameObject is disabled and destroys it with the GameObject.