You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ads request properties defined in the IMA SDK documentation. (will override default settings)
adWillAutoPlay
boolean
no
Tell the SDK if ad player is started as the result of a user action. (default is true)
adWillPlayMuted
boolean
no
Tell the SDK if ad player is started while muted. (default is false)
clickTrackingElement
HTMLElement
no
Optional video ad click HTML element. (see also AdDisplayContaineropt_clickTrackingElement argument)
continuousPlayback
boolean
no
Tell the SDK if ad player intends to continuously play the content videos one after another. (default is to not tell the SDK)
debug
boolean
no
Lazy load the debug version of the IMA SDK library if set to true. (default is false)
displayContainer
HTMLElement
yes
The HTML element to display the ads in. (must be already inserted into the DOM)
locale
string
no
The locale (language) in which to display UI elements. (default is to not set locale)
maxDuration
integer
no
The maximum duration in milliseconds an ad is displayed. (default is none)
nonLinearMaxDuration
integer
no
The maximum duration in milliseconds a non-linear ad is displayed. (default is none, default observed duration is 45 seconds)
restoreVideo
boolean
no
Tell the SDK if custom playback content video state must be restored. (default is false)
tag
string
yes
The VAST Ad tag URL.
timeout
integer
no
The duration in milliseconds to wait for the IMA SDK library to be loaded. (default is 6000)
video
HTMLVideoElement
yes
HTML Video element (content video element)
vpaidMode
integer
no
The VPAID playback mode : ImaAdPlayer.vpaidMode.DISABLED, ImaAdPlayer.vpaidMode.ENABLED and ImaAdPlayer.vpaidMode.INSECURE. (default is to not set VPAID mode. IMA SDK default is ENABLED)
Advanced configuration example
// Ad player assumes the ad display container and video element are correctly positioned and sizedvarvideoElement=document.querySelector('.a-video-element');varadContainer=document.querySelector('.a-display-container-element');// var clickTrackingElement = document.querySelector('.optional-click-tracking-element');ImaAdPlayer({video: videoElement,displayContainer: adContainer,tag: 'https://myadserver.com/path/to/vast/tag.xml',vpaidMode: ImaAdPlayer.vpaidMode.INSECURE,locale: 'fr',maxDuration: 30000,nonLinearMaxDuration: 8000,// restoreVideo: true,adsRequestOptions: {vastLoadTimeout: 10000,},adsRenderingOptions: {loadVideoTimeout: 10000,useStyledLinearAds: true,useStyledNonLinearAds: true,},timeout: 2000,// debug: true,// clickTracking: clickTrackingElement,// adWillAutoPlay: false, // Default is true// adWillPlayMuted: true, // Default is false// continuousPlayback: true, // Default is undefined},function(player,error){if(error){// Ad player creation failedreturnconsole.log(error);}player.on('ad_begin',function(o){// Pause content video});player.on('ad_end',function(o){// Play or resume content video/** * o.name is event name * o.data is event object (may equals undefined) * o.target is ad player instance */console.log(o);});// Must be done via a user interaction (if autoplay not permitted)// player.initAdDisplayContainer()player.play();});