A good starting point to get acquainted with THEOplayer’s advertising features is THEOplayer’s Knowledge Base.
While THEOplayer supports a wide range of different
ad types,
react-native-theoplayer
currently supports:
In the next section we discuss how to integrate them on each platform.
Additional functionality, such as scheduling ads at runtime, is provided by the ads API.
The final section describes how to subscribe and add custom logic to ad events.
First enable Google IMA support, which requires a different approach on each platform.
When providing the player with a source that includes a list of ads, make sure to
set the integration
property to "google-ima"
, as shown in one of the sources of the example app:
const imaSource = {
sources: [
{
src: 'https://cdn.theoplayer.com/video/dash/webvtt-embedded-in-isobmff/Manifest.mpd',
type: 'application/dash+xml',
},
],
ads: [
{
integration: 'google-ima' as AdIntegrationKind,
sources: {
src: 'https://cdn.theoplayer.com/demos/ads/vast/dfp-preroll-no-skip.xml',
},
},
],
};
The API’s AdSource
description provides additional information on
the configurable properties.
First enable Google DAI support, which requires a different approach on each platform.
Providing a Google DAI source description to the player requires providing an ssai
object and
specifying "google-dai"
as integration type:
const daiSource = {
sources: {
ssai: {
integration: 'google-dai',
availabilityType: 'vod',
contentSourceID: '2528370',
videoID: 'tears-of-steel',
} as GoogleDAIVodConfiguration,
},
};
A full description of the available source properties can be found in the API definition.
THEOads is an ad-insertion service for both VOD and LIVE content, created by THEO Technologies, utilizing Server-Guided Ad-Insertion (SGAI). For more information we refer to the THEOads documentation.
THEOplayer provides an AdsAPI that enables additional features such as:
The THEOplayer
is provided with a callback on the THEOplayerView
component:
const onPlayerReady = (player: THEOplayer) => {
this.player = player;
}
<THEOplayerView onPlayerReady={onPlayerReady}/>
After which the AdsAPI can be used:
const isPlayingAd = () => {
return this.player.ads.playing();
};
Google DAI has its own API, which includes DAI-specific features, such as
converting time stamps between stream time and content time, and manipulating the snapback
flag that prevents
users from seeking across ad breaks.
// Convert timestamps using the DAI ads api.
const streamTimeForContentTime = (contentTime: number): Promise<number> | undefined => {
return this.player.ads.dai?.streamTimeForContentTime(contentTime);
};
THEOplayer allows you to subscribe to ad events:
const onAdEvent = (event: AdEvent) => {
console.log(event)
}
player.addEventListener(PlayerEventType.AD_EVENT, onAdEvent);
See AdEvent, Ad and AdBreak for more information.
Note that the availability of the events being dispatched depends on the platform.