VOD
Methods
requestVodAd
function requestVodAd(nativeId: string, params: VodAdParams): Promise<void>;
Requests the ad breaks of a VOD content playing in <Video nativeID={nativeId}>.
Nothing is rewritten here — the content keeps playing from its own URL, and each break arrives as a prepare event (a mid-roll's when the content reaches its position), which is where the app calls play.
The SDK does not hold the content for a pre-roll, so mount the <Video> paused and start the content on the first completed or error. completed also arrives when there is no pre-roll, the ad response is empty or the request fails. After that, leave the content alone: by default the break plays on the SDK's own ad player, and for a mid-roll the SDK pauses the content, and at completed seeks it back by the rewind duration (5 seconds) and resumes it. Do not pause, seek or re-source the content once it has started. That includes an error after the content has started: after a failed mid-roll the SDK has already brought the content back, and the app only resumes it as a safety net (videoRef.current?.resume(), or player.play() with Bitmovin — harmless if it is already playing); after a post-roll error the content has ended. Only an error whose message starts with playback unrecoverable — the content itself stopped — calls for reloading it or showing an error. See VOD Ad Implementation.
The same requirement as changeChannelUrl applies: the <Video> player must already exist.
| Parameter | Type | Description |
|---|---|---|
| nativeId | string | The nativeID of the <Video> playing the content |
| params | VodAdParams | Content and ad configuration |
VodAdParams
| Field | Type | Description |
|---|---|---|
| adTagUrl | string | Ad tag URL issued by an ad server |
| contentId | string | Content's ID Must be registered in the FLOWER backend system |
| durationMs | number | Total playback time of the VOD content in milliseconds — the SDK places the breaks against it |
| 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 VodAdParams = {
adTagUrl: string;
contentId: string;
durationMs: number;
playerType?: PlayerType;
extraParams?: StringMap;
adTagHeaders?: StringMap;
};
Rejects when no view carries that nativeID, or when its player has not been built yet.
notifyContentEnded
Tells the SDK the content played to its end, so a post-roll can run. See notifyContentEnded.
play
Starts a prepared break. See play.
stop
Ends the current break. See stop.
Work Process
- Mount
<Video nativeID="…" paused>on the content URL, held until the pre-roll is over. The URL is never rewritten for VOD. - Subscribe to ad events with
addAdEventListenerFor. - Once
onLoadfires, callrequestVodAd()with thatnativeID. - On
prepare, callplay. - On the first
completedorerror, start the content. From then on leave it alone — the SDK pauses and resumes it around a mid-roll. On a later mid-rollerror, resume the content as a safety net (harmless if it is already playing), with no seek or reload. If the message starts withplayback unrecoverable, reload the content or show an error instead. - Call
notifyContentEndedfrom the<Video>component'sonEndprop so a post-roll can run, after marking the content ended (a ref) so a post-rollerrordoes not resume it. - Call
releasewhen the<Video>unmounts.
// arg0: nativeId, the nativeID of the <Video> playing the content
// params.adTagUrl: url from the flower system
// You must file a request to Anypoint Media to receive an adTagUrl.
// params.contentId: unique content id in your service
// params.durationMs: duration of the vod content in milliseconds
// params.extraParams: (Optional) values you can provide for targeting
// params.adTagHeaders: (Optional) values included in headers for ad requests
await requestVodAd('vod-1', {
adTagUrl: 'https://ad_request',
contentId: '100',
durationMs: 3600000,
extraParams: {genre: 'horror'},
adTagHeaders: {'custom-ad-header': 'custom-ad-header-value'},
});
durationMs must be the real total duration of the content. The SDK places the break positions against it, so a wrong value puts the mid-rolls in the wrong place.