Interstitial Ads
Methods
requestAd
function requestAd(nativeId: string, params: InlineAdParams): Promise<void>;
Requests an inline (interstitial) ad break, played in the overlay over <Video nativeID={nativeId}> on the SDK's own ad player.
Pausing and resuming the content around it is the app's business, which is also why this call — unlike changeChannelUrl and requestVodAd — does not need the video's player to exist yet. Only the view is looked up.
Ads arrive as a prepare event and then wait for play.
| Parameter | Type | Description |
|---|---|---|
| nativeId | string | The nativeID of the view the ad overlay mounts on |
| params | InlineAdParams | Ad configuration |
InlineAdParams
| Field | Type | Description |
|---|---|---|
| adTagUrl | string | Ad tag URL issued by an ad server |
| playerType | PlayerType | (Optional) Player library owning the view. Defaults to 'react-native-video'. |
| extraParams | StringMap | (Optional) Additional information pre-agreed for targeting |
| adTagHeaders | StringMap | (Optional) HTTP headers added to ad requests |
export type InlineAdParams = {
adTagUrl: string;
playerType?: PlayerType;
extraParams?: StringMap;
adTagHeaders?: StringMap;
};
Rejects when no view carries that nativeID.
note
playerType still matters here even though the break plays on the SDK's own ad player: it decides which kind of view is looked up to mount the overlay on.
play
Starts the prepared break. See play.
stop
Ends ad playback. See stop.
Work Process
- Mount the
<Video nativeID="…">the overlay should cover. For a full-screen interstitial, make it full screen. - Subscribe to ad events with
addAdEventListenerFor. - Call
requestAd()at the point the break belongs in your flow. - On
prepare, pause your content and callplay. Oncompletedorerror, resume it and callstop. - Call
releasewhen the view unmounts.
// arg0: nativeId, the nativeID of the view the ad overlay mounts on
// params.adTagUrl: url from the flower system
// You must file a request to Anypoint Media to receive an adTagUrl.
// params.extraParams: (Optional) values you can provide for targeting
// params.adTagHeaders: (Optional) values included in headers for ad requests
await requestAd('inline-1', {
adTagUrl: 'https://ad_request',
extraParams: {genre: 'horror'},
adTagHeaders: {'custom-ad-header': 'custom-ad-header-value'},
});