google.ima. AdsManager
Provides the outer public API to the publisher and communicates with the inner instance of ads manager.
Methods
collapse
collapse() returns void
Collapse the current ad. This is no-op for HTML5 SDK.
- Returns
-
void
configureAdsManager
configureAdsManager(content, adsRenderingSettings) returns void
Sets required parameters for getting a reference to this AdManager from the AdsManagerLoaded event.
Parameter |
|
---|---|
content |
Object Object that plays back publisher's content. Value must not be null. |
adsRenderingSettings |
Optional (undefined, null, or non-null AdsRenderingSettings) Optional settings to control the rendering of ads. |
- Returns
-
void
destroy
destroy() returns 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.
- Returns
-
void
discardAdBreak
discardAdBreak() returns 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.
- Returns
-
void
expand
expand() returns void
Expand the current ad. This is no-op for HTML5 SDK.
- Returns
-
void
focus
focus() returns void
Puts the focus on the skip button, if present. If not present, focus is put on interactive elements, including icons or interactive creatives.
- Returns
-
void
getAdSkippableState
getAdSkippableState() returns 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() returns Array of 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
-
non-null Array of number
List of time offsets in seconds.
getRemainingTime
getRemainingTime() returns 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() returns 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, height, viewMode, videoElement) returns void
Call init to initialize the ad experience on the ads manager.
Parameter |
|
---|---|
width |
number The chosen width of the ad. |
height |
number The chosen height of the ad. |
viewMode |
ViewMode The chosen view mode. Value must not be null. |
videoElement |
Optional (undefined, null, or non-null HTMLVideoElement) 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. |
- Returns
-
void
isCustomClickTrackingUsed
isCustomClickTrackingUsed() returns 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() returns 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() returns 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.
- Returns
-
void
resize
resize(width, height, viewMode) returns void
Resizes the current ad.
Parameter |
|
---|---|
width |
number New ad slot width. |
height |
number New ad slot height. |
viewMode |
ViewMode The new view mode. Value must not be null. |
- Returns
-
void
resume
resume() returns 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.
- Returns
-
void
setVolume
setVolume(volume) returns void
Set the volume for the current ad.
Parameter |
|
---|---|
volume |
number The volume to set, from 0 (muted) to 1 (loudest). |
- Returns
-
void
skip
skip() returns 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.
- Returns
-
void
start
start() returns void
Start playing the ads.
Developers must call AdDisplayContainer.initialize()
first.
- Returns
-
void
stop
stop() returns void
Stop playing the ads. Calling this will get publisher back to the content.
- Returns
-
void
updateAdsRenderingSettings
updateAdsRenderingSettings(adsRenderingSettings) returns 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.
Parameter |
|
---|---|
adsRenderingSettings |
AdsRenderingSettings The updated ads rendering settings. Value must not be null. |
- Returns
-
void