Provides the outer public API to the publisher and communicates with the inner instance of
ads manager.
Methods | |
---|---|
add
|
Appends an event listener for events whose type attribute value is type.
Inherited from
|
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. |
dispatch
|
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.
Inherited from
|
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 the event listener in target's event listener list with the same type,
callback, and options.
Inherited from
|
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: 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
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
|
|
|
|
|
collapse
collapse(): void
Collapse the current ad. This is no-op for HTML5 SDK.
configureAdsManager
configureAdsManager(content: object, adsRenderingSettings?: null | AdsRenderingSettings): void
Sets required parameters for getting a reference to this AdManager from the
AdsManagerLoaded event.
Parameters | |
---|---|
content: object
|
Object that plays back publisher's content. |
|
Optional settings to control the rendering of ads. |
destroy
destroy(): void
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.
discardAdBreak
discardAdBreak(): void
If an ad break is currently playing, discard it and resume content. Otherwise, ignore
the next scheduled ad break. For example, this can be called immediately after the ads
manager loads to ignore a preroll without losing future midrolls or postrolls. This is
a no-op unless the ad request returned a playlist or VMAP response.
dispatchEvent
dispatchEvent(event: 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
MDN Reference
Parameters | |
---|---|
event: Event
|
Returns | |
---|---|
boolean
|
expand
expand(): void
Expand the current ad. This is no-op for HTML5 SDK.
focus
focus(): void
Puts the focus on the skip button, if present. If not present, focus is put on
interactive elements, including icons or interactive creatives.
getAdSkippableState
getAdSkippableState(): boolean
Returns true if the ad can currently be skipped. When this value changes, the
AdsManager
fires an AdEvent.SKIPPABLE_STATE_CHANGED
event.
Returns | |
---|---|
boolean
|
True if the ad can currently be skipped, false otherwise. |
getCuePoints
getCuePoints(): number[]
Returns an array of offsets in seconds indicating when a scheduled ad break will play.
A preroll is represented by 0, and a postroll is represented by -1. An empty array
indicates the ad or ad pod has no schedule and can be played at any time.
Returns | |
---|---|
number[]
|
List of time offsets in seconds. |
getRemainingTime
getRemainingTime(): number
Get the remaining time of the current ad that is playing. If the ad is not loaded yet
or has finished playing, the API would return -1.
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
Get the volume for the current ad.
Returns | |
---|---|
number
|
The volume of the current ad, from 0 (muted) to 1 (loudest). |
init
init(width: number,
height: number, viewMode: ViewMode, videoElement?: null | HTMLVideoElement): void
Call init to initialize the ad experience on the ads manager.
Parameters | |
---|---|
width: number
|
The chosen width of the ad. |
height: number
|
The chosen height of the ad. |
viewMode:
ViewMode
|
The chosen view mode. |
|
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
Returns true if a custom click tracking element is being used for click tracking on
the current ad. Custom click tracking is only used when an optional click tracking
element is provided to the
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
Returns true if a custom video element is being used to play the current ad. Custom
playback occurs when an optional video element is provided to the
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
Pauses the current ad that is playing. This function will be no-op when a static
overlay is being shown or if the ad is not loaded yet or is done playing.
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
MDN Reference
Parameters | |
---|---|
type: string
|
|
handler: null | object
|
|
|
|
|
resize
resume
resume(): void
Resumes the current ad that is loaded and paused. This function will be no-op when a
static overlay is being shown or if the ad is not loaded yet or is done playing.
setVolume
setVolume(volume: number): void
Set the volume for the current ad.
Parameters | |
---|---|
volume: number
|
The volume to set, from 0 (muted) to 1 (loudest). |
skip
skip(): void
Skips the current ad when
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
Start playing the ads.
Developers must call
Developers must call
AdDisplayContainer.initialize()
first.
stop
stop(): void
Stop playing the ads. Calling this will get publisher back to the content.
updateAdsRenderingSettings
updateAdsRenderingSettings(adsRenderingSettings: AdsRenderingSettings): void
Updates the ads rendering settings. This should be used specifically for VMAP use
cases between ad breaks when ads rendering settings such as bitrate need to be
updated.
Parameters | |
---|---|
adsRenderingSettings:
AdsRenderingSettings
|
The updated ads rendering settings. |