This article explains how to integrate a VAST and VMAP through THEOplayer's own Advertisement system, as well as through Google IMA.
The snippets below demonstrate how to configure a VAST advertisement to be scheduled at second 15.
let vmapSource =
"//cdn.theoplayer.com/demos/ads/vmap/single-pre-mid-post-no-skip.xml";
let offset = "00:00:15";
let ad = [{ sources: vmapSource, timeOffset: offset }];
let source = {
sources: [typedSource],
ads: ad,
};
player.source = source;
String vmapSource = "//cdn.theoplayer.com/demos/preroll.xml";
String offset = "00:00:15";
AdDescription ad = THEOplayerAdDescription.Builder.adDescription(vmapSource).timeOffset(offset).build();
SourceDescription sourceDescription = SourceDescription.Builder.sourceDescription(typedSource)
.ads(ad)
.build();
tpv.getPlayer().setSource(sourceDescription);
let vmapSource = "//cdn.theoplayer.com/demos/ads/vmap/single-pre-mid-post-no-skip.xml"
let offset = "00:00:15"
let ad = THEOAdDescription(src : vmapSource, timeOffset: offset)
let source = SourceDescription(source : typedSource, ads: [ad])
theoplayer.source = source
Set offset
in the snippets above to "start"
to schedule the ad as a pre-roll, and to "end"
to schedule the ad as a post-roll.
The snippets below demonstrate how to configure a VMAP advertisement.
// Declare a VMAP ad source. No timeOffset here, because the VMAP itself arranges this.
let vmapSource =
"//cdn.theoplayer.com/demos/ads/vmap/single-pre-mid-post-no-skip.xml";
let ad = [{ sources: vmapSource }];
let source = {
sources: [typedSource],
ads: ad,
};
player.source = source;
// Declare a VMAP ad source. No timeOffset here, because the VMAP itself arranges this.
String vmapSource = "//cdn.theoplayer.com/demos/ads/vmap/single-pre-mid-post-no-skip.xml";
AdDescription ad = THEOplayerAdDescription.Builder.adDescription(vmapSource).build();
SourceDescription sourceDescription = SourceDescription.Builder.sourceDescription(typedSource)
.ads(ad)
.build();
tpv.getPlayer().setSource(sourceDescription);
// Declare a VMAP ad source. No timeOffset here, because the VMAP itself arranges this.
let vmapSource = "//cdn.theoplayer.com/demos/ads/vmap/single-pre-mid-post-no-skip.xml"
let ad = THEOAdDescription(src : vmapSource)
let source = SourceDescription(source : typedSource, ads: [ad])
theoplayer.source = source
Advertisement can also be scheduled through Google IMA.
Google IMA has a dependency on the IMA library. Hence, this library needs to be included.
Include the IMA's JavaScript library:
<script
type="text/javascript"
src="//imasdk.googleapis.com/js/sdkloader/ima3.js"
></script>
Google IMA has to be enabled in the THEOplayerConfig
:
THEOplayerConfig playerConfig = new THEOplayerConfig.Builder()
.googleIma(true)
.build();
Google IMA has to be enabled in the THEOplayerConfiguration:
let playerConfig = THEOplayerConfiguration(chromeless: false, jsPaths: [], googleIMA: true, analytics : [])
You have to set integration to "google-ima". For example, in the above VMAP example, you have to use
let ad = [{ sources: vmapSource, integration: "google-ima" }];
instead of
let ad = [{ sources: vmapSource }];
You have to use a GoogleImaAdDescription�
instead of a THEOAdDescription
. For example, in the above VMAP example, you have to use
GoogleImaAdDescription ad = GoogleImaAdDescription.Builder.googleImaAdDescription(vmapSource).build();
instead of
AdDescription ad = THEOplayerAdDescription.Builder.adDescription(vmapSource).timeOffset(offset).build();
You have to use a GoogleImaAdDescription�
instead of a THEOAdDescription
. For example, in the above VMAP example, you have to use
let ad = GoogleImaAdDescription(src : vmapSource)
instead of
let ad = THEOAdDescription(src : vmapSource)