From b6548069964bc0a212dd7da669d4d35979e1ef84 Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Fri, 20 Jul 2018 03:01:16 -0700 Subject: [PATCH] Add support for setting companion ad slots ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=205373398 --- RELEASENOTES.md | 6 ++++-- .../android/exoplayer2/ext/ima/ImaAdsLoader.java | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 13d983285c..1007a97612 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -79,8 +79,10 @@ be directly made with the `Player.EventListener` interface. * Deprecate `DefaultAnalyticsListener` as selective listener overrides can be directly made with the `AnalyticsListener` interface. -* IMA: Fix behavior when creating/releasing the player then releasing - `ImaAdsLoader` ([#3879](https://github.com/google/ExoPlayer/issues/3879)). +* IMA: + * Fix behavior when creating/releasing the player then releasing + `ImaAdsLoader` ([#3879](https://github.com/google/ExoPlayer/issues/3879)). + * Add support for setting slots for companion ads. * Fix issue playing DRM protected streams on Asus Zenfone 2 ([#4403](https://github.com/google/ExoPlayer/issues/4413)). * Add support for multiple audio and video tracks in MPEG-PS streams diff --git a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java index ddab7d834f..1f646982b7 100644 --- a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java +++ b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java @@ -38,6 +38,7 @@ import com.google.ads.interactivemedia.v3.api.AdsManager; import com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent; import com.google.ads.interactivemedia.v3.api.AdsRenderingSettings; import com.google.ads.interactivemedia.v3.api.AdsRequest; +import com.google.ads.interactivemedia.v3.api.CompanionAdSlot; import com.google.ads.interactivemedia.v3.api.ImaSdkFactory; import com.google.ads.interactivemedia.v3.api.ImaSdkSettings; import com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider; @@ -63,6 +64,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -414,6 +416,17 @@ public final class ImaAdsLoader return adsLoader; } + /** + * Sets the slots for displaying companion ads. Individual slots can be created using {@link + * ImaSdkFactory#createCompanionAdSlot()}. + * + * @param companionSlots Slots for displaying companion ads. + * @see AdDisplayContainer#setCompanionSlots(Collection) + */ + public void setCompanionSlots(Collection companionSlots) { + adDisplayContainer.setCompanionSlots(companionSlots); + } + /** * Requests ads, if they have not already been requested. Must be called on the main thread. *