AI-generated Key Takeaways
-
The
AdsManager
interface provides the public API for publishers to interact with and control the inner ad manager, extendingImaEventTarget
. -
It offers various methods to manage ads, including starting, pausing, resuming, skipping, collapsing, expanding, and stopping ad playback.
-
The
AdsManager
enables configuration for ad rendering settings and content playback, and provides ways to get information about ad playback, such as remaining time and skippable state. -
Custom click tracking and playback can be enabled, and methods are available to check if they are being utilized.
-
Methods exist to add and remove event listeners, allowing the publisher to respond to various events triggered by the ad playback.
Methods | |
---|---|
add
|
Adds a listener for ad events. |
collapse
|
Collapse the current ad. |
configure
|
Sets required parameters for getting a reference to this AdManager from the
AdsManagerLoaded event.
|
destroy
|
Removes ad assets loaded at runtime that need to be properly removed at the time of
ad completion and stops the ad and all tracking.
|
discard
|
If an ad break is currently playing, discard it and resume content. |
expand
|
Expand the current ad. |
focus
|
Puts the focus on the skip button, if present. |
get
|
Returns true if the ad can currently be skipped. |
get
|
Returns an array of offsets in seconds indicating when a scheduled ad break will
play.
|
get
|
Get the remaining time of the current ad that is playing. |
get
|
Get the volume for the current ad. |
init
|
Call init to initialize the ad experience on the ads manager. |
is
|
Returns true if a custom click tracking element is being used for click tracking on
the current ad.
|
is
|
Returns true if a custom video element is being used to play the current ad.
|
pause
|
Pauses the current ad that is playing. |
remove
|
Removes a listener for ad events. |
resize
|
Resizes the current ad. |
resume
|
Resumes the current ad that is loaded and paused. |
set
|
Set the volume for the current ad. |
skip
|
Skips the current ad when
AdsManager.getAdSkippableState() is true.
|
start
|
Start playing the ads. |
stop
|
Stop playing the ads. |
update
|
Updates the ads rendering settings. |
Methods
addEventListener
addEventListener(type: google.ima.AdEvent.Type, listener: ((event: AdEvent) => void),
optCapture?: boolean,
optHandlerScope?: object): void
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. |
|
Deprecated and a no-op; retained for backward compatibility. |
|
Deprecated: Listener scope object. Use arrow functions or bind listener instead. |
addEventListener(type: AD_ERROR, listener: ((event: AdErrorEvent) => void),
optCapture?: boolean,
optHandlerScope?: object): void
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. |
|
Deprecated and a no-op; retained for backward compatibility. |
|
Deprecated: Listener scope object. Use arrow functions or bind listener instead. |
collapse
collapse(): void
configureAdsManager
configureAdsManager(content: object, adsRenderingSettings?: AdsRenderingSettings): void
Parameters | |
---|---|
content: object
|
Object that plays back publisher's content. |
|
Optional settings to control the rendering of ads. |
destroy
destroy(): void
discardAdBreak
discardAdBreak(): void
expand
expand(): void
focus
focus(): void
getAdSkippableState
getAdSkippableState(): boolean
AdsManager
fires an AdEvent.SKIPPABLE_STATE_CHANGED
event.
Returns | |
---|---|
boolean
|
True if the ad can currently be skipped, false otherwise. |
getCuePoints
getCuePoints(): number[]
Returns | |
---|---|
number[]
|
List of time offsets in seconds. |
getRemainingTime
getRemainingTime(): number
Returns | |
---|---|
number
|
Returns the time remaining for current ad. If the remaining time is undefined for the current ad (for example custom ads), the value returns -1. |
getVolume
getVolume(): number
Returns | |
---|---|
number
|
The volume of the current ad, from 0 (muted) to 1 (loudest). |
init
init(width: number,
height: number, viewMode?: unknown, videoElement?: HTMLVideoElement): void
Parameters | |
---|---|
width: number
|
The chosen width of the ad. |
height: number
|
The chosen height of the ad. |
|
This value is ignored and can be omitted. Pass undefined if further
arguments are passed.
|
|
The video element for custom playback. This video element overrides the one provided in the AdDisplayContainer constructor. Only use this property if absolutely necessary - otherwise we recommend specifying this video element while creating the AdDisplayContainer. |
isCustomClickTrackingUsed
isCustomClickTrackingUsed(): boolean
AdDisplayContainer
, custom playback is used,
and the current ad is not an AdSense/AdX ad.
Returns | |
---|---|
boolean
|
Whether custom click tracking is used. |
isCustomPlaybackUsed
isCustomPlaybackUsed(): boolean
AdDisplayContainer
on platforms where a custom video element would
provide a more seamless ad viewing experience.
Returns | |
---|---|
boolean
|
Whether custom playback is used. |
pause
pause(): void
removeEventListener
removeEventListener(type: google.ima.AdEvent.Type, listener: ((event: AdEvent) => void),
optCapture?: boolean,
optHandlerScope?: object): void
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. |
|
Deprecated and a no-op; retained for backward compatibility. |
|
Deprecated: Listener scope object. Use arrow functions or bind listener instead. |
removeEventListener(type: AD_ERROR, listener: ((event: AdErrorEvent) => void),
optCapture?: boolean,
optHandlerScope?: object): void
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. |
|
Deprecated and a no-op; retained for backward compatibility. |
|
Deprecated: Listener scope object. Use arrow functions or bind listener instead. |
resize
resize(width: number, height: number,
viewMode?: unknown): void
Parameters | |
---|---|
width: number
|
New ad slot width. |
height: number
|
New ad slot height. |
|
This value is ignored and should be omitted. |
resume
resume(): void
setVolume
setVolume(volume: number): void
Parameters | |
---|---|
volume: number
|
The volume to set, from 0 (muted) to 1 (loudest). |
skip
skip(): void
AdsManager.getAdSkippableState()
is true. When
called under other circumstances, skip has no effect. After the skip is completed the
AdsManager
fires an AdEvent.SKIPPED
event.
AdsManager.skip()
only skips ads if IMA does not render the 'Skip
ad' button.
start
start(): void
Developers must call
AdDisplayContainer.initialize()
first.
stop
stop(): void
updateAdsRenderingSettings
updateAdsRenderingSettings(adsRenderingSettings: AdsRenderingSettings): void
Parameters | |
---|---|
adsRenderingSettings:
AdsRenderingSettings
|
The updated ads rendering settings. |