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
Appends an event listener for events whose type attribute value is type.
contentComplete
Signals to the SDK that the content is finished.
destroy
Cleans up the internal state.
dispatchEvent
Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
getSettings
Returns the IMA SDK settings instance.
getVersion
Returns the version of the current SDK.
removeEventListener
Removes the event listener in target's event listener list with the same type, callback, and options.
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: string, handler: null | object, capture?: boolean, handlerScope?: null | object): void
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.

When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.

The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.

MDN Reference
Parameters
type: string
handler: null | object
Optional capture: boolean
Optional handlerScope: null | object

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.

dispatchEvent

dispatchEvent(event: null | Event): boolean
Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

MDN Reference
Parameters
event: null | Event
Returns
boolean

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: string, handler: null | object, capture?: boolean, handlerScope?: null | object): void
Removes the event listener in target's event listener list with the same type, callback, and options.

MDN Reference
Parameters
type: string
handler: null | object
Optional capture: boolean
Optional handlerScope: null | object

requestAds

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