From 9bb64b7e44dee50baf8eed7ee444575aa6ddaf87 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 1829d4a956..1249be7acb 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -13,8 +13,10 @@ * DRM: * Allow DrmInitData to carry a license server URL ([#3393](https://github.com/google/ExoPlayer/issues/3393)). -* 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 9045ee777a..cce45f2d2c 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; @@ -62,6 +63,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; @@ -395,6 +397,17 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A 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. *