Ad Controls Plugin
mp4e:ad-controls draws an ad break's controls — pause, mute, the time remaining, a skip button and Learn more — over the ad video.
Overview
Ad controls (mp4e:ad-controls, an official plugin) is the template of an ad break: during the break it covers the ad video with pause and mute buttons, the time remaining, a skip button that counts down and then skips, and a Learn more button. It is the default template of Linear ads, and any site can use it for breaks it requests itself.
Ad controls decides nothing. Whether and when the ad may be skipped is set by the player for the break; the button only shows it. The player draws its own Ad label above the template, which the template cannot cover.
Using it
Install it in the video from the marketplace (or, as a site, add it through overrides). It is never placed on the timeline: the player puts it over the whole picture for each break that names it as its template — Linear ads does so by default, and a site names it in requestInterstitial. A break whose template is not installed in the video is refused.
await playerRef.current?.requestInterstitial({
placement: 'midroll',
template: {
plugin: 'mp4e:ad-controls',
config: { clickThroughUrl: 'https://acme.example/', learnMoreLabel: 'Shop now' },
},
media: { src: 'https://cdn.example.com/acme-15s.mp4', width: 1280, height: 720, durationSeconds: 15 },
skippableAfter: 5,
advertiser: 'Acme Shoes',
});Settings
Set per break, in the template's config:
| Prop | Type | Default | Description |
|---|---|---|---|
clickThroughUrl | string | '' | Where Learn more goes. Empty: no Learn more button. Linear ads fills it from the ad's click-through. |
learnMoreLabel | string | 'Learn more' | The Learn more button's text. |
skipLabel | string | 'Skip ad' | The skip button's text once skipping is allowed. |
showPause | boolean | true | A Pause / Play button for the ad. false hides it. Linear ads sets it from its adControls.showPause. |
showMute | boolean | true | A Mute / Unmute button for the ad. false hides it. Linear ads sets it from its adControls.showMute. |
What the viewer sees
- Pause and Mute, bottom left: Pause / Play pauses and resumes the ad, Mute / Unmute its sound (each button reads what a press does next). Time the ad stays paused does not count toward the break's time limit, and a mute the viewer changes during the ad carries over to the video after it. Hidden with
showPause/showMutefalse. - Time remaining, next to them, counting down the ad in m:ss.
- Skip, bottom right, only when the break can be skipped: it reads "Skip in N" until the player allows it, then the skip label; pressing it ends the ad and the video resumes.
- Learn more, next to Skip, only with a click-through URL: it reports the click to the player (the ad's click trackers fire) and opens the URL.
- When a shoppable ad holds on its last frame, the time remaining, Pause, Mute and Skip are hidden; Learn more stays.
- Everything is sized with the video, so the controls keep their proportions on every screen. Only the buttons take clicks: the rest of the picture, and another template drawn over the ad, keep theirs.
Writing your own template
Any overlay plugin can be a template. It reads the break with mp4e.getInterstitial(), skips with mp4e.skipInterstitial(), returns to the video with mp4e.endInterstitial({ label }), reports a click-through with mp4e.interstitialClick(), pauses and resumes the ad with mp4e.pauseVideo() / mp4e.playVideo() and mutes it with mp4e.setMuted(muted) (the ad's current mute is getInterstitial().muted) — see Ad Breaks in the plugin API.