Skip to main content

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.

ParameterTypeDescription
nativeIdstringThe nativeID of the <Video> playing the content
paramsVodAdParamsContent and ad configuration

VodAdParams​

FieldTypeDescription
adTagUrlstringAd tag URL issued by an ad server
contentIdstringContent's ID
Must be registered in the FLOWER backend system
durationMsnumberTotal playback time of the VOD content in milliseconds — the SDK places the breaks against it
playerTypePlayerType(Optional) Player library owning the view. Defaults to 'react-native-video'.
extraParamsStringMap(Optional) Additional information pre-agreed for targeting
adTagHeadersStringMap(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​

  1. Mount <Video nativeID="…" paused> on the content URL, held until the pre-roll is over. The URL is never rewritten for VOD.
  2. Subscribe to ad events with addAdEventListenerFor.
  3. Once onLoad fires, call requestVodAd() with that nativeID.
  4. On prepare, call play.
  5. On the first completed or error, start the content. From then on leave it alone — the SDK pauses and resumes it around a mid-roll. On a later mid-roll error, resume the content as a safety net (harmless if it is already playing), with no seek or reload. If the message starts with playback unrecoverable, reload the content or show an error instead.
  6. Call notifyContentEnded from the <Video> component's onEnd prop so a post-roll can run, after marking the content ended (a ref) so a post-roll error does not resume it.
  7. Call release when 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'},
});
caution

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.