Preroll Ads
Preroll ads are video ads that play before your own video content. The SDK handles the transition from ad to content automatically. Each placement uses a Zone ID from the Empower dashboard.
Load and Control
using Empower.MobileAds;
// Load with the content video URL
EmpowerAds.LoadPrerollAd("YOUR_PREROLL_ZONE_ID", "https://example.com/video.mp4", muted: false);
// Playback control
EmpowerAds.PausePreroll("YOUR_PREROLL_ZONE_ID");
EmpowerAds.ResumePreroll("YOUR_PREROLL_ZONE_ID");
// Clean up
EmpowerAds.DestroyPreroll("YOUR_PREROLL_ZONE_ID");
Status and Lifecycle Events
Preroll reports both status changes (OnPrerollStatusChanged) and lifecycle events (OnPrerollEvent):
EmpowerAds.OnPrerollStatusChanged += (status, zoneId) =>
{
if (status == AdStatus.CompletePlaying)
Debug.Log("Ad finished — content video is now playing");
};
EmpowerAds.OnPrerollEvent += (eventName, zoneId, error) =>
{
// eventName: "ready", "started", "completed", "error"
Debug.Log($"Preroll event: {eventName}, zone: {zoneId}, error: {error}");
};
Key statuses: Ready, Active (playing), Shown, CompletePlaying (content video starts), Clicked, Impression, Failed.
EmpowerPrerollAd Component (no-code)
Attach the EmpowerPrerollAd MonoBehaviour to a GameObject and configure it in the Inspector.
| Property | Description |
|---|---|
| Zone ID | Your preroll zone ID. |
| Content Url | URL of the video content that plays after the preroll. |
| Muted | Start the preroll muted. |
| Auto Load | Loads automatically in Start() when checked. |
| On Status Changed | UnityEvent fired on status change. |
| On Preroll Event | UnityEvent fired for lifecycle events (ready, started, completed, error). |
Behavior: auto-loads on Start() (if Auto Load + Zone ID + Content Url are set); pauses on OnDisable, resumes on OnEnable; destroys on OnDestroy.
var preroll = GetComponent<EmpowerPrerollAd>();
preroll.ZoneId = "my_preroll_zone";
preroll.ContentUrl = "https://example.com/my-video.mp4";
preroll.Muted = false;
preroll.Load();
preroll.Pause();
preroll.Resume();
preroll.Destroy();
preroll.OnStatusChanged += (status) => Debug.Log($"Preroll: {status}");
preroll.OnPrerollEvent += (name, error) => Debug.Log($"Event: {name}");