ImaServerSideAdInsertionMediaSource.AdsLoader.Builder


public final class ImaServerSideAdInsertionMediaSource.AdsLoader.Builder


Builder for building an AdsLoader.

Summary

Public constructors

Builder(Context context, AdViewProvider adViewProvider)

Creates an instance.

Public methods

ImaServerSideAdInsertionMediaSource.AdsLoader

Returns a new AdsLoader.

ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

Sets the optional AdErrorEvent.AdErrorListener that will be passed to addAdErrorListener when the stream manager becomes available.

ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

Sets the optional AdEventListener that will be passed to addAdEventListener when the stream manager becomes available.

ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

Sets the optional state to resume with.

ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

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

ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

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

ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

Sets the IMA SDK settings.

ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

Sets the optional StreamEventListener that will be called for stream events.

Public constructors

Builder

public Builder(Context context, AdViewProvider adViewProvider)

Creates an instance.

Parameters
Context context

A context.

AdViewProvider adViewProvider

A provider for ViewGroup instances.

Public methods

setAdErrorListener

@UnstableApi
@CanIgnoreReturnValue
public ImaServerSideAdInsertionMediaSource.AdsLoader.Builder setAdErrorListener(AdErrorEvent.AdErrorListener adErrorListener)

Sets the optional AdErrorEvent.AdErrorListener that will be passed to addAdErrorListener when the stream manager becomes available.

Note: This method can be considered a stable API as long as the is provided by the IMA library. We can't declare this method stable because we don't have the same guarantee from the library we depend on.

Returns
ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

This builder, for convenience.

setAdEventListener

@UnstableApi
@CanIgnoreReturnValue
public ImaServerSideAdInsertionMediaSource.AdsLoader.Builder setAdEventListener(AdEvent.AdEventListener adEventListener)

Sets the optional AdEventListener that will be passed to addAdEventListener when the stream manager becomes available.

Note: This method can be considered a stable API as long as the AdEventListener is provided by the IMA library. We can't declare this method stable because we don't have the same guarantee from the library we depend on.

Parameters
AdEvent.AdEventListener adEventListener

The ad event listener.

Returns
ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

This builder, for convenience.

setAdsLoaderState

@CanIgnoreReturnValue
public ImaServerSideAdInsertionMediaSource.AdsLoader.Builder setAdsLoaderState(
    ImaServerSideAdInsertionMediaSource.AdsLoader.State state
)

Sets the optional state to resume with.

The state can be received when releasing the AdsLoader.

Parameters
ImaServerSideAdInsertionMediaSource.AdsLoader.State state

The state to resume with.

Returns
ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

This builder, for convenience.

setCompanionAdSlots

@UnstableApi
@CanIgnoreReturnValue
public ImaServerSideAdInsertionMediaSource.AdsLoader.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
ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

This builder, for convenience.

setFocusSkipButtonWhenAvailable

@UnstableApi
@CanIgnoreReturnValue
public ImaServerSideAdInsertionMediaSource.AdsLoader.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
ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

This builder, for convenience.

setImaSdkSettings

@UnstableApi
@CanIgnoreReturnValue
public ImaServerSideAdInsertionMediaSource.AdsLoader.Builder setImaSdkSettings(ImaSdkSettings imaSdkSettings)

Sets the IMA SDK settings.

If this method is not called, the default settings will be used with the language set to the preferred system language.

Parameters
ImaSdkSettings imaSdkSettings

The ImaSdkSettings.

Returns
ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

This builder, for convenience.

setStreamEventListener

@UnstableApi
@CanIgnoreReturnValue
public ImaServerSideAdInsertionMediaSource.AdsLoader.Builder setStreamEventListener(
    ImaServerSideAdInsertionMediaSource.StreamEventListener streamEventListener
)

Sets the optional StreamEventListener that will be called for stream events.

Parameters
ImaServerSideAdInsertionMediaSource.StreamEventListener streamEventListener

The stream event listener.

Returns
ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

This builder, for convenience.