ImaAdsLoader.Builder
public final class ImaAdsLoader.Builder
Builder for ImaAdsLoader.
Summary
Constants |
|
|---|---|
static final long |
The default duration in milliseconds for which the player must buffer while preloading an ad group before that ad group is skipped and marked as having failed to load. |
Public constructors |
|---|
|
Creates a new builder for |
Public methods |
|
|---|---|
ImaAdsLoader |
build()Returns a new |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets a listener for ad errors that will be passed to |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets a listener for ad events that will be passed to |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets the MIME types to prioritize for linear ad media. |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets the duration in milliseconds for which the player must buffer while preloading an ad group before that ad group is skipped and marked as having failed to load. |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets the ad UI elements to be rendered by the IMA SDK. |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets the slots to use for companion ads, if they are present in the loaded ad. |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets whether to enable outputting verbose logs for the IMA extension and IMA SDK. |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets whether to enable continuous playback. |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets whether to focus the skip button (when available) on Android TV devices. |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets the IMA SDK settings. |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets the media maximum recommended bitrate for ads, in bps. |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets the ad media load timeout, in milliseconds. |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets whether to play an ad before the start position when beginning playback. |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets the VAST load timeout, in milliseconds. |
ImaAdsLoader.Builder |
@CanIgnoreReturnValueSets a callback to receive video ad player events. |
Constants
DEFAULT_AD_PRELOAD_TIMEOUT_MS
@UnstableApi
public static final long DEFAULT_AD_PRELOAD_TIMEOUT_MS = 10000
The default duration in milliseconds for which the player must buffer while preloading an ad group before that ad group is skipped and marked as having failed to load.
This value should be large enough not to trigger discarding the ad when it actually might load soon, but small enough so that user is not waiting for too long.
| See also | |
|---|---|
setAdPreloadTimeoutMs |
Public constructors
Builder
public Builder(Context context)
Creates a new builder for ImaAdsLoader.
| Parameters | |
|---|---|
Context context |
The context; |
Public methods
setAdErrorListener
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setAdErrorListener(AdErrorEvent.AdErrorListener adErrorListener)
Sets a listener for ad errors that will be passed to addAdErrorListener and addAdErrorListener.
| Parameters | |
|---|---|
AdErrorEvent.AdErrorListener adErrorListener |
The ad error listener. |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
setAdEventListener
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setAdEventListener(AdEvent.AdEventListener adEventListener)
Sets a listener for ad events that will be passed to addAdEventListener.
| Parameters | |
|---|---|
AdEvent.AdEventListener adEventListener |
The ad event listener. |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
setAdMediaMimeTypes
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setAdMediaMimeTypes(List<String> adMediaMimeTypes)
Sets the MIME types to prioritize for linear ad media. If not specified, MIME types supported by the adMediaSourceFactory used to construct the AdsMediaSource will be used.
| Parameters | |
|---|---|
List<String> adMediaMimeTypes |
The MIME types to prioritize for linear ad media. May contain |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
| See also | |
|---|---|
setMimeTypes |
setAdPreloadTimeoutMs
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setAdPreloadTimeoutMs(long adPreloadTimeoutMs)
Sets the duration in milliseconds for which the player must buffer while preloading an ad group before that ad group is skipped and marked as having failed to load. Pass TIME_UNSET if there should be no such timeout. The default value is DEFAULT_AD_PRELOAD_TIMEOUT_MS ms.
The purpose of this timeout is to avoid playback getting stuck in the unexpected case that the IMA SDK does not load an ad break based on the player's reported content position.
The value will be adjusted to be greater or equal to the one in setVastLoadTimeoutMs if provided.
| Parameters | |
|---|---|
long adPreloadTimeoutMs |
The timeout buffering duration in milliseconds, or |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
setAdUiElements
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setAdUiElements(Set<UiElement> adUiElements)
Sets the ad UI elements to be rendered by the IMA SDK.
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
| See also | |
|---|---|
setUiElements |
setCompanionAdSlots
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setCompanionAdSlots(Collection<CompanionAdSlot> companionAdSlots)
Sets the slots to use for companion ads, if they are present in the loaded ad.
| Parameters | |
|---|---|
Collection<CompanionAdSlot> companionAdSlots |
The slots to use for companion ads. |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
| See also | |
|---|---|
setCompanionSlots |
setDebugModeEnabled
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setDebugModeEnabled(boolean debugModeEnabled)
Sets whether to enable outputting verbose logs for the IMA extension and IMA SDK. The default value is false. This setting is intended for debugging only, and should not be enabled in production applications.
| Parameters | |
|---|---|
boolean debugModeEnabled |
Whether to enable outputting verbose logs for the IMA extension and IMA SDK. |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
| See also | |
|---|---|
setDebugMode |
setEnableContinuousPlayback
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setEnableContinuousPlayback(boolean enableContinuousPlayback)
Sets whether to enable continuous playback. Pass true if content videos will be played continuously, similar to a TV broadcast. This setting may modify the ads request but does not affect ad playback behavior. The requested value is unknown by default.
| Parameters | |
|---|---|
boolean enableContinuousPlayback |
Whether to enable continuous playback. |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
| See also | |
|---|---|
setContinuousPlayback |
setFocusSkipButtonWhenAvailable
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setFocusSkipButtonWhenAvailable(boolean focusSkipButtonWhenAvailable)
Sets whether to focus the skip button (when available) on Android TV devices. The default setting is true.
| Parameters | |
|---|---|
boolean focusSkipButtonWhenAvailable |
Whether to focus the skip button (when available) on Android TV devices. |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
| See also | |
|---|---|
setFocusSkipButtonWhenAvailable |
setImaSdkSettings
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setImaSdkSettings(ImaSdkSettings imaSdkSettings)
Sets the IMA SDK settings. The provided settings instance's player type and version fields may be overwritten.
If this method is not called the default settings will be used.
| Parameters | |
|---|---|
ImaSdkSettings imaSdkSettings |
The |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
setMaxMediaBitrate
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setMaxMediaBitrate(@IntRange(from = 1) int bitrate)
Sets the media maximum recommended bitrate for ads, in bps.
| Parameters | |
|---|---|
@IntRange(from = 1) int bitrate |
The media maximum recommended bitrate for ads, in bps. |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
| See also | |
|---|---|
setBitrateKbps |
setMediaLoadTimeoutMs
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setMediaLoadTimeoutMs(@IntRange(from = 1) int mediaLoadTimeoutMs)
Sets the ad media load timeout, in milliseconds.
| Parameters | |
|---|---|
@IntRange(from = 1) int mediaLoadTimeoutMs |
The ad media load timeout, in milliseconds. |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
| See also | |
|---|---|
setLoadVideoTimeout |
setPlayAdBeforeStartPosition
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setPlayAdBeforeStartPosition(boolean playAdBeforeStartPosition)
Sets whether to play an ad before the start position when beginning playback. If
true, an ad will be played if there is one at or before the start position. If
false, an ad will be played only if there is one exactly at the start position. The default setting is true.
| Parameters | |
|---|---|
boolean playAdBeforeStartPosition |
Whether to play an ad before the start position when beginning playback. |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
setVastLoadTimeoutMs
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setVastLoadTimeoutMs(@IntRange(from = 1) int vastLoadTimeoutMs)
Sets the VAST load timeout, in milliseconds.
| Parameters | |
|---|---|
@IntRange(from = 1) int vastLoadTimeoutMs |
The VAST load timeout, in milliseconds. |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
| See also | |
|---|---|
setVastLoadTimeout |
setVideoAdPlayerCallback
@CanIgnoreReturnValue
@UnstableApi
public ImaAdsLoader.Builder setVideoAdPlayerCallback(
VideoAdPlayer.VideoAdPlayerCallback videoAdPlayerCallback
)
Sets a callback to receive video ad player events. Note that these events are handled internally by the IMA SDK and this ads loader. For analytics and diagnostics, new implementations should generally use events from the top-level Player listeners instead of setting a callback via this method.
| Parameters | |
|---|---|
VideoAdPlayer.VideoAdPlayerCallback videoAdPlayerCallback |
The callback to receive video ad player events. |
| Returns | |
|---|---|
ImaAdsLoader.Builder |
This builder, for convenience. |
| See also | |
|---|---|
VideoAdPlayer.VideoAdPlayerCallback |