ImaAdsLoader.Builder


class ImaAdsLoader.Builder


Builder for ImaAdsLoader.

Summary

Constants

const 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

Builder(context: Context!)

Creates a new builder for ImaAdsLoader.

Public functions

ImaAdsLoader!

Returns a new ImaAdsLoader.

ImaAdsLoader.Builder!

Sets a listener for ad errors that will be passed to addAdErrorListener and addAdErrorListener.

ImaAdsLoader.Builder!

Sets a listener for ad events that will be passed to addAdEventListener.

ImaAdsLoader.Builder!

Sets the MIME types to prioritize for linear ad media.

ImaAdsLoader.Builder!

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.

ImaAdsLoader.Builder!

Sets the ad UI elements to be rendered by the IMA SDK.

ImaAdsLoader.Builder!

Sets the slots to use for companion ads, if they are present in the loaded ad.

ImaAdsLoader.Builder!

Sets whether to enable outputting verbose logs for the IMA extension and IMA SDK.

ImaAdsLoader.Builder!

Sets whether to enable continuous playback.

ImaAdsLoader.Builder!

Sets whether to focus the skip button (when available) on Android TV devices.

ImaAdsLoader.Builder!

Sets the IMA SDK settings.

ImaAdsLoader.Builder!

Sets the media maximum recommended bitrate for ads, in bps.

ImaAdsLoader.Builder!

Sets the ad media load timeout, in milliseconds.

ImaAdsLoader.Builder!

Sets whether to play an ad before the start position when beginning playback.

ImaAdsLoader.Builder!

Sets the VAST load timeout, in milliseconds.

ImaAdsLoader.Builder!

Sets a callback to receive video ad player events.

Constants

DEFAULT_AD_PRELOAD_TIMEOUT_MS

@UnstableApi
const val DEFAULT_AD_PRELOAD_TIMEOUT_MS = 10000: 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.

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.

Public constructors

Builder

Builder(context: Context!)

Creates a new builder for ImaAdsLoader.

Parameters
context: Context!

The context;

Public functions

build

fun build(): ImaAdsLoader!

Returns a new ImaAdsLoader.

setAdErrorListener

@CanIgnoreReturnValue
@UnstableApi
fun setAdErrorListener(adErrorListener: AdErrorEvent.AdErrorListener!): ImaAdsLoader.Builder!

Sets a listener for ad errors that will be passed to addAdErrorListener and addAdErrorListener.

Parameters
adErrorListener: AdErrorEvent.AdErrorListener!

The ad error listener.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.

setAdEventListener

@CanIgnoreReturnValue
@UnstableApi
fun setAdEventListener(adEventListener: AdEvent.AdEventListener!): ImaAdsLoader.Builder!

Sets a listener for ad events that will be passed to addAdEventListener.

Parameters
adEventListener: AdEvent.AdEventListener!

The ad event listener.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.

setAdMediaMimeTypes

@CanIgnoreReturnValue
@UnstableApi
fun setAdMediaMimeTypes(adMediaMimeTypes: (Mutable)List<String!>!): ImaAdsLoader.Builder!

Sets the MIME types to prioritize for linear ad media. If not specified, MIME types supported by the adMediaSourceFactory used to construct the will be used.

Parameters
adMediaMimeTypes: (Mutable)List<String!>!

The MIME types to prioritize for linear ad media. May contain APPLICATION_MPD, APPLICATION_M3U8, VIDEO_MP4, VIDEO_WEBM, VIDEO_H263, AUDIO_MP4 and AUDIO_MPEG.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.

See also
setMimeTypes

setAdPreloadTimeoutMs

@CanIgnoreReturnValue
@UnstableApi
fun setAdPreloadTimeoutMs(adPreloadTimeoutMs: Long): ImaAdsLoader.Builder!

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.

Parameters
adPreloadTimeoutMs: Long

The timeout buffering duration in milliseconds, or TIME_UNSET for no timeout.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.

setAdUiElements

@CanIgnoreReturnValue
@UnstableApi
fun setAdUiElements(adUiElements: (Mutable)Set<UiElement!>!): ImaAdsLoader.Builder!

Sets the ad UI elements to be rendered by the IMA SDK.

Parameters
adUiElements: (Mutable)Set<UiElement!>!

The ad UI elements to be rendered by the IMA SDK.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.

See also
setUiElements

setCompanionAdSlots

@CanIgnoreReturnValue
@UnstableApi
fun setCompanionAdSlots(
    companionAdSlots: (Mutable)Collection<CompanionAdSlot!>!
): ImaAdsLoader.Builder!

Sets the slots to use for companion ads, if they are present in the loaded ad.

Parameters
companionAdSlots: (Mutable)Collection<CompanionAdSlot!>!

The slots to use for companion ads.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.

setDebugModeEnabled

@CanIgnoreReturnValue
@UnstableApi
fun setDebugModeEnabled(debugModeEnabled: Boolean): ImaAdsLoader.Builder!

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
debugModeEnabled: Boolean

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
fun setEnableContinuousPlayback(enableContinuousPlayback: Boolean): ImaAdsLoader.Builder!

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
enableContinuousPlayback: Boolean

Whether to enable continuous playback.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.

setFocusSkipButtonWhenAvailable

@CanIgnoreReturnValue
@UnstableApi
fun setFocusSkipButtonWhenAvailable(focusSkipButtonWhenAvailable: Boolean): ImaAdsLoader.Builder!

Sets whether to focus the skip button (when available) on Android TV devices. The default setting is true.

Parameters
focusSkipButtonWhenAvailable: Boolean

Whether to focus the skip button (when available) on Android TV devices.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.

setImaSdkSettings

@CanIgnoreReturnValue
@UnstableApi
fun setImaSdkSettings(imaSdkSettings: ImaSdkSettings!): ImaAdsLoader.Builder!

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 ImaSdkSettings.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.

setMaxMediaBitrate

@CanIgnoreReturnValue
@UnstableApi
fun setMaxMediaBitrate(bitrate: @IntRange(from = 1) Int): ImaAdsLoader.Builder!

Sets the media maximum recommended bitrate for ads, in bps.

Parameters
bitrate: @IntRange(from = 1) Int

The media maximum recommended bitrate for ads, in bps.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.

See also
setBitrateKbps

setMediaLoadTimeoutMs

@CanIgnoreReturnValue
@UnstableApi
fun setMediaLoadTimeoutMs(mediaLoadTimeoutMs: @IntRange(from = 1) Int): ImaAdsLoader.Builder!

Sets the ad media load timeout, in milliseconds.

Parameters
mediaLoadTimeoutMs: @IntRange(from = 1) Int

The ad media load timeout, in milliseconds.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.

setPlayAdBeforeStartPosition

@CanIgnoreReturnValue
@UnstableApi
fun setPlayAdBeforeStartPosition(playAdBeforeStartPosition: Boolean): ImaAdsLoader.Builder!

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
playAdBeforeStartPosition: Boolean

Whether to play an ad before the start position when beginning playback.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.

setVastLoadTimeoutMs

@CanIgnoreReturnValue
@UnstableApi
fun setVastLoadTimeoutMs(vastLoadTimeoutMs: @IntRange(from = 1) Int): ImaAdsLoader.Builder!

Sets the VAST load timeout, in milliseconds.

Parameters
vastLoadTimeoutMs: @IntRange(from = 1) Int

The VAST load timeout, in milliseconds.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.

setVideoAdPlayerCallback

@CanIgnoreReturnValue
@UnstableApi
fun setVideoAdPlayerCallback(
    videoAdPlayerCallback: VideoAdPlayer.VideoAdPlayerCallback!
): ImaAdsLoader.Builder!

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
videoAdPlayerCallback: VideoAdPlayer.VideoAdPlayerCallback!

The callback to receive video ad player events.

Returns
ImaAdsLoader.Builder!

This builder, for convenience.