Skip to content

Latest commit

 

History

History
210 lines (129 loc) · 7.13 KB

api.md

File metadata and controls

210 lines (129 loc) · 7.13 KB

Ad player API

configureAdsManager(content, adsRenderingSettings)

Same as AdsManager.configureAdsManager() method.

discardAdBreak()

Same as AdsManager.discardAdBreak() method.

destroy()

Destroy the ad player instance. It stop and cleanup all internal instances and created DOM elements.

player.destroy() // This method may dispatch `ad_end` ad player event

ended()

Signals the video content is finished. This will allow to play post-roll ads (if any).

player.ended()

focus()

Same as AdsManager.focus() method.

getAdSkippableState()

Same as AdsManager.getAdSkippableState() method.

This method returns null if AdsManager instance is unavailable.

getCuePoints()

Same as AdsManager.getCuePoints() method.

This method returns null if AdsManager instance is unavailable.

getDisplayContainer()

Get the DOM element used to display the ads in. (The HTML element set in displayContainer configuration option)

getRemainingTime()

Same as AdsManager.getRemainingTime() method.

This method returns null if AdsManager instance is unavailable.

getVolume()

Same as AdsManager.getVolume() method.

This method returns null if AdsManager instance is unavailable.

initAdDisplayContainer()

Initialize the ad display container. This method must be called as the result of a user action.

It is automaticalled called by play() method, but may be usefull to call it before play() to store user interaction.

player.initAdDisplayContainer()

isCustomClickTrackingUsed()

Same as AdsManager.isCustomClickTrackingUsed() method.

This method returns null if AdsManager instance is unavailable.

isCustomPlaybackUsed()

Same as AdsManager.isCustomPlaybackUsed() method.

This method returns null if AdsManager instance is unavailable.

off(name[, cb])

Remove one or all event listener(s).

Name Type Description
name string The event name
cb Function Optional listener callback function
player.off('ad_begin', function(o) {/* ... */})

player.off('ad_begin') // Unbind all listeners

on(name, cb)

Add an event listener.

Name type Description
name string The event name
cb Function The listener callback function
player.on('ad_begin', function(o) {
    /**
     * o.name is event name
     * o.data is event object (may equals undefined)
     * o.target is ad player instance
     */
})

pause()

Same as AdsManager.pause() method.

play()

Start the ad player. This method must be called as the result of a user action (if autoplay not permitted).

player.play()

request([options])

Request ads from ad server. It is usefull, for example, to pre-request ads when autoplay is not allowed.

Name Type Description
options object Optional ads request properties defined in the IMA SDK documentation
player.request()

// Overrides ads request properties set with "adsRequestOptions" configuration option
player.request({vastLoadTimeout: 10000})

resize(width, height[, viewMode])

Signals the ad player to resize the current ad.

Name Type Description
width integer The new width
height integer The new height
viewMode integer The optional new view mode. (default is google.ima.ViewMode.NORMAL)
player.resize(320, 240)

resume()

Same as AdsManager.resume() method.

setAdWillAutoPlay(autoPlay)

Same as adWillAutoPlay configuration option. This method must be called before play() or request().

player.setAdWillAutoPlay(false)

setAdWillPlayMuted(muted)

Same as adWillPlayMuted configuration option. This method must be called before play() or request().

player.setAdWillPlayMuted(true)

setContinuousPlayback(continuousPlayback)

Same as continuousPlayback configuration option. This method must be called before play() or request().

player.setContinuousPlayback(true)

setVolume(volume)

Set the volume for the current ad.

Name Type Description
volume number Number value between 0 (mute) and 1 (loudest)
player.setVolume(0.5)

skip()

Same as AdsManager.skip() method.

stop()

Stop the ad player.

player.stop()

updateAdsRenderingSettings(adsRenderingSettings)

Same as AdsManager.updateAdsRenderingSettings() method.