Class AdsLoader


AdsLoader allows clients to request ads from ad servers. To do so, users must register for the AdsManagerLoadedEvent event and then request ads.
Constructors
constructor
Constructor.
Methods
addEventListener
Adds a listener for ads manager loaded events.
contentComplete
Signals to the SDK that the content is finished.
destroy
Cleans up the internal state.
getSettings
Returns the IMA SDK settings instance.
getVersion
Returns the version of the current SDK.
removeEventListener
Removes a listener for ads manager loaded events.
requestAds
Request ads from a server.

Constructors


constructor

new AdsLoader(container: AdDisplayContainer): AdsLoader
Constructor.
Parameters
container: AdDisplayContainer The display container for ads.
Returns
AdsLoader

Methods


addEventListener

addEventListener(type: ADS_MANAGER_LOADED, listener: ((event: AdsManagerLoadedEvent) => void), optCapture?: boolean, optHandlerScope?: object): void
Adds a listener for ads manager loaded events.
Parameters
type: ADS_MANAGER_LOADED The type of event to listen for.
listener: ((event: AdsManagerLoadedEvent) => void) A function called each time an event of this type occurs.
Optional optCapture: boolean Deprecated and a no-op; retained for backward compatibility.
Optional optHandlerScope: object Deprecated: Listener scope object. Use arrow functions or bind listener instead.
addEventListener(type: google.ima.AdEvent.Type, listener: ((event: AdEvent) => void), optCapture?: boolean, optHandlerScope?: object): void
Adds a listener for ad events.
Parameters
type: google.ima.AdEvent.Type The type of event to listen for.
listener: ((event: AdEvent) => void) A function called each time an event of this type occurs.
Optional optCapture: boolean Deprecated and a no-op; retained for backward compatibility.
Optional optHandlerScope: object Deprecated: Listener scope object. Use arrow functions or bind listener instead.
addEventListener(type: AD_ERROR, listener: ((event: AdErrorEvent) => void), optCapture?: boolean, optHandlerScope?: object): void
Adds a listener for ad error events.
Parameters
type: AD_ERROR The type of event to listen for.
listener: ((event: AdErrorEvent) => void) A function called each time an event of this type occurs.
Optional optCapture: boolean Deprecated and a no-op; retained for backward compatibility.
Optional optHandlerScope: object Deprecated: Listener scope object. Use arrow functions or bind listener instead.

contentComplete

contentComplete(): void
Signals to the SDK that the content is finished. This will allow the SDK to play post-roll ads, if any are loaded through ad rules.

destroy

destroy(): void
Cleans up the internal state.

getSettings

getSettings(): ImaSdkSettings
Returns the IMA SDK settings instance. To change the settings, just call the methods on the instance. The changes will apply for all the ad requests made with this ads loader.
Returns
ImaSdkSettings The settings instance.

getVersion

getVersion(): string
Returns the version of the current SDK.
Returns
string

removeEventListener

removeEventListener(type: ADS_MANAGER_LOADED, listener: ((event: AdsManagerLoadedEvent) => void), optCapture?: boolean, optHandlerScope?: object): void
Removes a listener for ads manager loaded events. The listener must be equal by reference to the one previously passed to addEventListener.
Parameters
type: ADS_MANAGER_LOADED The type of event for which to remove the listener.
listener: ((event: AdsManagerLoadedEvent) => void) The function to remove as a listener.
Optional optCapture: boolean Deprecated and a no-op; retained for backward compatibility.
Optional optHandlerScope: object Deprecated: Listener scope object. Use arrow functions or bind listener instead.
removeEventListener(type: google.ima.AdEvent.Type, listener: ((event: AdEvent) => void), optCapture?: boolean, optHandlerScope?: object): void
Removes a listener for ad events. The listener must be equal by reference to the one previously passed to addEventListener.
Parameters
type: google.ima.AdEvent.Type The type of event for which to remove the listener.
listener: ((event: AdEvent) => void) The function to remove as a listener.
Optional optCapture: boolean Deprecated and a no-op; retained for backward compatibility.
Optional optHandlerScope: object Deprecated: Listener scope object. Use arrow functions or bind listener instead.
removeEventListener(type: AD_ERROR, listener: ((event: AdErrorEvent) => void), optCapture?: boolean, optHandlerScope?: object): void
Removes a listener for ad error events. The listener function must be equal by reference to the one previously passed to addEventListener.
Parameters
type: AD_ERROR The type of event for which to remove the listener.
listener: ((event: AdErrorEvent) => void) The function to remove as a listener.
Optional optCapture: boolean Deprecated and a no-op; retained for backward compatibility.
Optional optHandlerScope: object Deprecated: Listener scope object. Use arrow functions or bind listener instead.

requestAds

requestAds(adsRequest: AdsRequest, userRequestContext?: object): void
Request ads from a server.
Parameters
adsRequest: AdsRequest AdsRequest instance containing data for the ads request.
Optional userRequestContext: object User-provided object that is associated with the ads request. It can be retrieved when the ads are loaded.