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. That is where the app pauses the content and calls play; the break ends with completed, where the content resumes.
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="…">on the content URL. It is never rewritten for VOD. - Subscribe to ad events with
addAdEventListenerFor. - Once
onLoadfires, callrequestVodAd()with thatnativeID. - On
prepare, pause the content and callplay. Oncompleted, resume it. - Call
notifyContentEndedfrom the<Video>component'sonEndprop so a post-roll can run. - 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.