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);