google.ima. AdDisplayContainer
This class represents a container for displaying ads. The SDK will automatically create structures inside the containerElement parameter to house video and overlay ads.
When an instance of this class is created, it creates an IFRAME in the
containerElement and loads the SDK core. This IFRAME must be preserved
in order for the SDK to function properly. Once all ads have been played
and the SDK is no longer needed, use the destroy()
method
to unload the SDK.
The containerElement parameter must be an element that is part of the DOM. It is necessary to correctly position the containerElement in order for the ads to be displayed correctly. It is recommended to position it above the content video player and size it to cover the whole video player. Refer to the SDK documentation for details about recommended implementations.
Note: It is always necessary to call the
initialize()
method in code that was directly invoked by a
user action (such as a click or tap).
Constructor
AdDisplayContainer
new AdDisplayContainer(containerElement, videoElement, clickTrackingElement)
Parameter |
|
---|---|
containerElement |
The element to display the ads in. The element must be inserted into the DOM before creating AdDisplayContainer. Value must not be null. |
videoElement |
Optional Specifies the alternative video ad playback element. We recommend always passing in your content video player. |
clickTrackingElement |
Optional Specifies the alternative video ad click element. Leave this null to let the SDK handle clicks. Even if supplied, the SDK will only use the custom click tracking element when non-AdSense/AdX creatives are displayed in environments that do not support UI elements overlaying a video player (for example, iPhone or pre-4.0 Android). The custom click tracking element should never be rendered over the video player because it can intercept clicks to UI elements that the SDK renders. Also note that the SDK will not modify the visibility of the custom click tracking element. This means that if a custom click tracking element is supplied, it must be properly displayed when the linear ad is played. You can check ima.AdsManager.isCustomClickTrackingUsed when the ima.AdEvent.Type.STARTED event is fired to determine whether or not to display your custom click tracking element. If appropriate for your UI, you should hide the click tracking element when the ima.AdEvent.Type.CONTENT_RESUME_REQUESTED event fires. |
- Implements
- AdDisplayContainerInterface
Methods
destroy
destroy() returns void
Destroys internal state and previously created DOM elements. The IMA SDK will be unloaded and no further calls to any APIs should be made.
- Returns
-
void
initialize
initialize() returns void
Initializes the internal video elements for playback. You must call this method as a direct result of a user action, so that the browser can mark the video element as user initiated.
Some browsers will allow video playback without user interactions if the
video is muted. For this behavior, use
AdsRequest.setAdWillPlayMuted(true)
and call this method before
AdsManager.start()
.
- Returns
-
void