Skip to content

Video Ad Integration

rprunskas edited this page May 31, 2022 · 5 revisions

Preparing view in code

For the AdInline to load video ads, you need to integrate the ad view as described in Integrating Inline Ad.

Java:

adView = (AdInline) findViewById(R.id.custom_ad_view);
adView.setMasterTagId(12345);

Kotlin:

adView = findViewById(R.id.custom_ad_view)
adView.masterTagId = 12345

Now the view is ready to load video banners. Just execute loadAd(); and banner will be loaded.

Java:

adView.loadAd();

Kotlin:

adView.loadAd()

It is no longer to required to set banner type for video ads, method setBannerType(bannerType) is deprecated. Whole video ad set up can be found in SampleDemo app with its custom configuration settings.

Custom properties

Video ad has custom properties that defines some of the video view behavior.

Debug mode

To test how the video banner handles VAST type of content, you can enable debug mode, and provide the configuration directly to be rendered by the view. All you need to do is to set debug mode setDebugMode([true/false]), and pass in debug content setDebugContent([VAST configuration content as String]).

Java:

adView.setDebugMode(true);
adView.setDebugContent(Utils.isToString(getResources().openRawResource(R.raw.vast)));

Kotlin:

adView.debugMode = true
adView.debugContent = Utils.isToString(getResources().openRawResource(R.raw.vast))

For more information, try looking at SampleDemo.

Mute on initialization

By default, when video is loaded and started, video is muted. To edit this behavior you can use setVideoMuteOnInit([true/false]).

Java:

adInline.setVideoMuteOnInit(true);

Kotlin:

adInline.videoMuteOnInit = true

Close when finished

By default, video banner will close after its finished playing content. To edit this behavior you can use setVideoCloseOnComplete(true/false).

Java:

adInline.setVideoCloseOnComplete(true);

Kotlin:

adInline.videoCloseOnComplete = true

Close button show behavior

By default, close button is always hidden when video ad is displayed. This property can be changed by defining property type in setVideoCloseButtonShowBehavior(VideoSettings.CloseButtonShowBehavior.[ALWAYS/AFTER_COMPLETE/HIDE]).

Java:

adInline.setVideoCloseButtonShowBehavior(VideoSettings.CloseButtonShowBehavior.ALWAYS);
adInline.setVideoCloseButtonShowBehavior(VideoSettings.CloseButtonShowBehavior.AFTER_COMPLETE);
adInline.setVideoCloseButtonShowBehavior(VideoSettings.CloseButtonShowBehavior.HIDE);

Kotlin:

adInline.videoCloseButtonShowBehavior = VideoSettings.CloseButtonShowBehavior.ALWAYS
adInline.videoCloseButtonShowBehavior = VideoSettings.CloseButtonShowBehavior.AFTER_COMPLETE
adInline.videoCloseButtonShowBehavior = VideoSettings.CloseButtonShowBehavior.HIDE

Skin

Video player also has different skin types that can be set by using setVideoPlayerSkinType(AdformEnum.VideoPlayerSkinType.[DEFAULT/MINIMAL]).

Java:

adInline.setVideoPlayerSkinType(AdformEnum.VideoPlayerSkinType.DEFAULT);
adInline.setVideoPlayerSkinType(AdformEnum.VideoPlayerSkinType.MINIMAL);

Kotlin:

adInline.videoPlayerSkinType = AdformEnum.VideoPlayerSkinType.DEFAULT
adInline.videoPlayerSkinType = AdformEnum.VideoPlayerSkinType.MINIMAL

Video ads fallback

In order to set up video ads fallback, you need to set fallback master tag of other HTML ad.

Java:

adInline.setFallbackMasterTagId(123456);

Kotlin:

adInline.fallbackMasterTagId = 123456
Clone this wiki locally