Version: 2.67.0

Android SDK Ads

Ad source configuration

 Using the THEOplayer ad manager

SourceDescription sourceDescription = SourceDescription.Builder.sourceDescription("https://cdn.theoplayer.com/video/elephants-dream/playlist.m3u8")
.ads(
THEOplayerAdDescription.Builder.adDescription("https://cdn.theoplayer.com/demos/preroll.xml")
.timeOffset("10")
.skipOffset("3")
.build()
)
.poster("http://cdn.theoplayer.com/video/big_buck_bunny/poster.jpg")
.build();
tpv.getPlayer().setSource(sourceDescription);

Using Google IMA

1. Enable Google IMA in the player config. 

THEOplayerConfig playerConfig = new THEOplayerConfig.Builder()
.googleIma(true)
.build();
THEOplayerView tpv = new THEOplayerView(this, playerConfig);

2. Configure the Google IMA ad source.

SourceDescription sourceDescription = SourceDescription.Builder.sourceDescription("https://cdn.theoplayer.com/video/elephants-dream/playlist.m3u8")
.ads(
GoogleImaAdDescription.Builder.googleImaAdDescription("https://cdn.theoplayer.com/demos/preroll.xml").build()
)
.poster("http://cdn.theoplayer.com/video/big_buck_bunny/poster.jpg")
.build();
tpv.getPlayer().setSource(sourceDescription);

SpotX pre-integration

  1. To configure the player to play SpotX ads, Google IMA should be configured.
THEOplayerConfig playerConfig = new THEOplayerConfig.Builder()
.googleIma(true)
.build();
THEOplayerView tpv = new THEOplayerView(this, playerConfig);

2. Add a SpotX ad configuration to the sources

SourceDescription source = SourceDescription.Builder.sourceDescription("http://cdn.theoplayer.com/video/sintel/index.m3u8")
.ads(
SpotXAdDescription.Builder.spotxAdDescription("12345")
.cacheBuster(true)
.build()
)
.build()
tpv.getPlayer().setSource(source);

YoSpace pre-integration

1. Include the yoAdManagement.aar and yoUtil.aar libraries in your Android project.

2. To configure the player to play YoSpace ads, Google IMA should be configured.

THEOplayerConfig playerConfig = new THEOplayerConfig.Builder()
.googleIma(true)
.build();
THEOplayerView tpv = new THEOplayerView(this, playerConfig);

3. Add a YoSpace ad configuration to the sources

String src = "http://csm-e.cds1.yospace.com/csm/extlive/yospace02,hlssample.m3u8?yo.br=true&yo.ac=true"
SsaiDescription yoSpaceDescription = new YoSpaceDescription.Builder()
.streamType(StreamType.LIVE)
.logLevel(YoSpaceLogLevelConfiguration.Builder.yoSpaceLogLevelConfiguration().http(true).build())
.build();
TypedSource typedSource = new TypedSource.Builder().src(src).ssai(yoSpaceDescription).type(SourceType.HLS).build();
SourceDescription source = new SourceDescription.Builder().sources(typedSource).build();
tpv.getPlayer().setSource(source);

4. Access to extended Yospace API
( WARNING! this gives you access to the Yospace Session object! Be careful with your modifications, it could affect how THEOplayer works!)

tpv.getPlayer().getYospace().addEventListener(YospaceEventTypes.SESSIONCHANGED, new EventListener<SessionChangedEvent>() {
@Override
public void handleEvent(SessionChangedEvent event) {
//from this moment you can access the Yospace session object:
com.yospace.android.hls.analytic.Session currentSession = tpv.getPlayer().getYospace().getActiveSession();
}
});