Last active
January 7, 2019 17:06
-
-
Save michael-riha/3daa9e09d4ea3800f88f08d5853a183f to your computer and use it in GitHub Desktop.
Basic Ad Setup for Bitmovin Player Android SDK - https://github.com/bitmovin/bitmovin-player-android-samples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/bitmovin/bitmovin-player-android-samples/blob/master/BasicAds/src/main/java/com/bitmovin/player/samples/ads/basic/MainActivity.java | |
... | |
import com.bitmovin.player.config.advertising.AdItem; | |
import com.bitmovin.player.config.advertising.AdSource; | |
import com.bitmovin.player.config.advertising.AdSourceType; | |
import com.bitmovin.player.config.advertising.AdvertisingConfiguration; | |
... | |
// These are IMA Sample Tags from https://developers.google.com/interactive-media-ads/docs/sdks/android/tags | |
private static final String AD_SOURCE_1 = "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dredirecterror&nofb=1&correlator="; | |
// add additional urls AD_SOURCE_2, AD_SOURCE_3, AD_SOURCE_4 ... | |
... | |
// Create AdSources | |
AdSource firstAdSource = new AdSource(AdSourceType.IMA, AD_SOURCE_1); | |
// add additional sources secondAdSource, thirdAdSource, fourthAdSource ... | |
... | |
// Setup a pre-roll ad | |
AdItem preRoll = new AdItem("pre", thirdAdSource); | |
// Setup a mid-roll waterfalling ad at 10% of the content duration | |
// NOTE: AdItems containing more than one AdSource, will be executed as waterfalling ad | |
AdItem midRoll = new AdItem("10%", firstAdSource, secondAdSource); | |
// Setup a post-roll ad | |
AdItem postRoll = new AdItem("post", fourthAdSource); | |
// Add the AdItems to the AdvertisingConfiguration | |
AdvertisingConfiguration advertisingConfiguration = new AdvertisingConfiguration(preRoll, midRoll, postRoll); | |
... | |
// Assing the AdvertisingConfiguration to the PlayerConfiguration | |
// All ads in the AdvertisingConfiguration will be scheduled automatically | |
playerConfiguration.setAdvertisingConfiguration(advertisingConfiguration); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment