mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Allow setting the ad UI elements to be rendered in ImaAdsLoader
This commit is contained in:
parent
861b81694d
commit
cfcbd2114b
1 changed files with 25 additions and 0 deletions
|
|
@ -40,6 +40,7 @@ import com.google.ads.interactivemedia.v3.api.AdsRequest;
|
||||||
import com.google.ads.interactivemedia.v3.api.CompanionAdSlot;
|
import com.google.ads.interactivemedia.v3.api.CompanionAdSlot;
|
||||||
import com.google.ads.interactivemedia.v3.api.ImaSdkFactory;
|
import com.google.ads.interactivemedia.v3.api.ImaSdkFactory;
|
||||||
import com.google.ads.interactivemedia.v3.api.ImaSdkSettings;
|
import com.google.ads.interactivemedia.v3.api.ImaSdkSettings;
|
||||||
|
import com.google.ads.interactivemedia.v3.api.UiElement;
|
||||||
import com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider;
|
import com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider;
|
||||||
import com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer;
|
import com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer;
|
||||||
import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate;
|
import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate;
|
||||||
|
|
@ -69,6 +70,7 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/** Loads ads using the IMA SDK. All methods are called on the main thread. */
|
/** Loads ads using the IMA SDK. All methods are called on the main thread. */
|
||||||
public final class ImaAdsLoader
|
public final class ImaAdsLoader
|
||||||
|
|
@ -91,6 +93,7 @@ public final class ImaAdsLoader
|
||||||
|
|
||||||
private @Nullable ImaSdkSettings imaSdkSettings;
|
private @Nullable ImaSdkSettings imaSdkSettings;
|
||||||
private @Nullable AdEventListener adEventListener;
|
private @Nullable AdEventListener adEventListener;
|
||||||
|
private @Nullable Set<UiElement> adUiElements;
|
||||||
private int vastLoadTimeoutMs;
|
private int vastLoadTimeoutMs;
|
||||||
private int mediaLoadTimeoutMs;
|
private int mediaLoadTimeoutMs;
|
||||||
private int mediaBitrateKbps;
|
private int mediaBitrateKbps;
|
||||||
|
|
@ -135,6 +138,18 @@ public final class ImaAdsLoader
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the ad UI elements to be rendered by the IMA SDK.
|
||||||
|
*
|
||||||
|
* @param adUiElements The ad UI elements to be rendered by the IMA SDK.
|
||||||
|
* @return This builder, for convenience.
|
||||||
|
* @see AdsRenderingSettings#setUiElements(Set)
|
||||||
|
*/
|
||||||
|
public Builder setAdUiElements(Set<UiElement> adUiElements) {
|
||||||
|
this.adUiElements = Assertions.checkNotNull(adUiElements);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the VAST load timeout, in milliseconds.
|
* Sets the VAST load timeout, in milliseconds.
|
||||||
*
|
*
|
||||||
|
|
@ -197,6 +212,7 @@ public final class ImaAdsLoader
|
||||||
vastLoadTimeoutMs,
|
vastLoadTimeoutMs,
|
||||||
mediaLoadTimeoutMs,
|
mediaLoadTimeoutMs,
|
||||||
mediaBitrateKbps,
|
mediaBitrateKbps,
|
||||||
|
adUiElements,
|
||||||
adEventListener,
|
adEventListener,
|
||||||
imaFactory);
|
imaFactory);
|
||||||
}
|
}
|
||||||
|
|
@ -217,6 +233,7 @@ public final class ImaAdsLoader
|
||||||
vastLoadTimeoutMs,
|
vastLoadTimeoutMs,
|
||||||
mediaLoadTimeoutMs,
|
mediaLoadTimeoutMs,
|
||||||
mediaBitrateKbps,
|
mediaBitrateKbps,
|
||||||
|
adUiElements,
|
||||||
adEventListener,
|
adEventListener,
|
||||||
imaFactory);
|
imaFactory);
|
||||||
}
|
}
|
||||||
|
|
@ -271,6 +288,7 @@ public final class ImaAdsLoader
|
||||||
private final int vastLoadTimeoutMs;
|
private final int vastLoadTimeoutMs;
|
||||||
private final int mediaLoadTimeoutMs;
|
private final int mediaLoadTimeoutMs;
|
||||||
private final int mediaBitrateKbps;
|
private final int mediaBitrateKbps;
|
||||||
|
private final @Nullable Set<UiElement> adUiElements;
|
||||||
private final @Nullable AdEventListener adEventListener;
|
private final @Nullable AdEventListener adEventListener;
|
||||||
private final ImaFactory imaFactory;
|
private final ImaFactory imaFactory;
|
||||||
private final Timeline.Period period;
|
private final Timeline.Period period;
|
||||||
|
|
@ -358,6 +376,7 @@ public final class ImaAdsLoader
|
||||||
/* vastLoadTimeoutMs= */ TIMEOUT_UNSET,
|
/* vastLoadTimeoutMs= */ TIMEOUT_UNSET,
|
||||||
/* mediaLoadTimeoutMs= */ TIMEOUT_UNSET,
|
/* mediaLoadTimeoutMs= */ TIMEOUT_UNSET,
|
||||||
/* mediaBitrateKpbs= */ BITRATE_UNSET,
|
/* mediaBitrateKpbs= */ BITRATE_UNSET,
|
||||||
|
/* adUiElements= */ null,
|
||||||
/* adEventListener= */ null,
|
/* adEventListener= */ null,
|
||||||
/* imaFactory= */ new DefaultImaFactory());
|
/* imaFactory= */ new DefaultImaFactory());
|
||||||
}
|
}
|
||||||
|
|
@ -383,6 +402,7 @@ public final class ImaAdsLoader
|
||||||
/* vastLoadTimeoutMs= */ TIMEOUT_UNSET,
|
/* vastLoadTimeoutMs= */ TIMEOUT_UNSET,
|
||||||
/* mediaLoadTimeoutMs= */ TIMEOUT_UNSET,
|
/* mediaLoadTimeoutMs= */ TIMEOUT_UNSET,
|
||||||
/* mediaBitrateKbps= */ BITRATE_UNSET,
|
/* mediaBitrateKbps= */ BITRATE_UNSET,
|
||||||
|
/* adUiElements= */ null,
|
||||||
/* adEventListener= */ null,
|
/* adEventListener= */ null,
|
||||||
/* imaFactory= */ new DefaultImaFactory());
|
/* imaFactory= */ new DefaultImaFactory());
|
||||||
}
|
}
|
||||||
|
|
@ -395,6 +415,7 @@ public final class ImaAdsLoader
|
||||||
int vastLoadTimeoutMs,
|
int vastLoadTimeoutMs,
|
||||||
int mediaLoadTimeoutMs,
|
int mediaLoadTimeoutMs,
|
||||||
int mediaBitrateKbps,
|
int mediaBitrateKbps,
|
||||||
|
@Nullable Set<UiElement> adUiElements,
|
||||||
@Nullable AdEventListener adEventListener,
|
@Nullable AdEventListener adEventListener,
|
||||||
ImaFactory imaFactory) {
|
ImaFactory imaFactory) {
|
||||||
Assertions.checkArgument(adTagUri != null || adsResponse != null);
|
Assertions.checkArgument(adTagUri != null || adsResponse != null);
|
||||||
|
|
@ -403,6 +424,7 @@ public final class ImaAdsLoader
|
||||||
this.vastLoadTimeoutMs = vastLoadTimeoutMs;
|
this.vastLoadTimeoutMs = vastLoadTimeoutMs;
|
||||||
this.mediaLoadTimeoutMs = mediaLoadTimeoutMs;
|
this.mediaLoadTimeoutMs = mediaLoadTimeoutMs;
|
||||||
this.mediaBitrateKbps = mediaBitrateKbps;
|
this.mediaBitrateKbps = mediaBitrateKbps;
|
||||||
|
this.adUiElements = adUiElements;
|
||||||
this.adEventListener = adEventListener;
|
this.adEventListener = adEventListener;
|
||||||
this.imaFactory = imaFactory;
|
this.imaFactory = imaFactory;
|
||||||
if (imaSdkSettings == null) {
|
if (imaSdkSettings == null) {
|
||||||
|
|
@ -952,6 +974,9 @@ public final class ImaAdsLoader
|
||||||
if (mediaBitrateKbps != BITRATE_UNSET) {
|
if (mediaBitrateKbps != BITRATE_UNSET) {
|
||||||
adsRenderingSettings.setBitrateKbps(mediaBitrateKbps);
|
adsRenderingSettings.setBitrateKbps(mediaBitrateKbps);
|
||||||
}
|
}
|
||||||
|
if (adUiElements != null) {
|
||||||
|
adsRenderingSettings.setUiElements(adUiElements);
|
||||||
|
}
|
||||||
|
|
||||||
// Set up the ad playback state, skipping ads based on the start position as required.
|
// Set up the ad playback state, skipping ads based on the start position as required.
|
||||||
long[] adGroupTimesUs = getAdGroupTimesUs(adsManager.getAdCuePoints());
|
long[] adGroupTimesUs = getAdGroupTimesUs(adsManager.getAdCuePoints());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue