Google IMA DAI SDK APIs

    1. google.ima.dai.api.Ad
    2. google.ima.dai.api.AdPodInfo
    3. google.ima.dai.api.AdProgressData
    4. google.ima.dai.api.CompanionAd
    5. google.ima.dai.api.CuePoint
    6. google.ima.dai.api.LiveStreamRequest
    7. google.ima.dai.api.StreamData
    8. google.ima.dai.api.StreamEvent
    9. google.ima.dai.api.StreamEvent.Type
    10. google.ima.dai.api.StreamManager
    11. google.ima.dai.api.StreamRequest
    12. google.ima.dai.api.VODStreamRequest
    13. google.ima.VERSION

Class google.ima.dai.api.Ad

Methods

A class representing an ad object during dynamic ad insertion. This class exposes a subset of the ima.Ad properties.

getAdId()


Returns string:

getAdPodInfo()


Returns google.ima.dai.api.AdPodInfo:

getAdSystem()


Returns string:

getAdvertiserName()


Returns string:

getApiFramework()


Returns string:

getCompanionAds()


Returns Array.<google.ima.dai.api.CompanionAd>:

getCreativeAdId()


Returns string:

getCreativeId()


Returns string:

getDealId()


Returns string:

getDescription()


Returns string:

getDuration()


Returns number:

getTitle()


Returns string:

getVastMediaHeight()


Returns number:

getVastMediaWidth()


Returns number:

getWrapperAdIds()


Returns Array.<string>:

getWrapperAdSystems()


Returns Array.<string>:

getWrapperCreativeIds()


Returns Array.<string>:

Class google.ima.dai.api.AdPodInfo

Methods

A class representing an ad pod info object during dynamic ad insertion. This class exposes a subset of the ima.AdPodInfo properties.

getAdPosition()


Returns number:

getMaxDuration()


Returns number:

getPodIndex()


Returns number:

getTimeOffset()


Returns number:

getTotalAds()


Returns number:

Class google.ima.dai.api.AdProgressData

Fields

A class for specifying ad progress data.

Properties

Name Type Description
adBreakDuration

adPosition

currentTime

duration

totalAds

Class google.ima.dai.api.CompanionAd

Methods

A class representing a companion ad object during dynamic ad insertion. This class exposes a subset of the ima.CompanionAd properties.

getAdSlotId()


Returns string:

getContent()


Returns string:

getContentType()


Returns string:

getHeight()


Returns number:

getWidth()


Returns number:

Class google.ima.dai.api.CuePoint

Fields

A class for specifying properties of a cuepoint, which represents an ad break in DAI VOD streams.

Properties

Name Type Description
end

The end time for this cuepoint.

played

If this cuepoint has been played.

start

The start time for this cuepoint.

Class google.ima.dai.api.LiveStreamRequest

Fields

A class for specifying properties of the live stream request.

Constructor:
Parameter Type Description
opt_liveStreamRequest Object

object that already has stream request properties assigned.

Properties

Name Type Description
assetKey

This is used to determine which stream should be played. The live stream request asset key is an identifier which can be found in the DFP UI.

Class google.ima.dai.api.StreamData

Fields

A class for specifying stream data.

Properties

Name Type Description
adProgressData

Timing related information for currently playing ad.

cuepoints

The ad cuepoints for the on-demand stream. These may change as the stream progresses. This will only be populated in the event listener for the CUEPOINTS_CHANGED AdEvent.

errorMessage

streamId

subtitles

url

Class google.ima.dai.api.StreamEvent

Methods

This event type is raised by the stream manager as a notification when the stream state changes.

getAd()


Returns google.ima.dai.api.Ad: return object with ad information.

getStreamData()


Returns google.ima.dai.api.StreamData: return object with stream information.

Enum google.ima.dai.api.StreamEvent.Type

Fields

List of event types supported by the IMA SDK.

Values

Value Description
AD_BREAK_ENDED

Fired when an ad break ends.

AD_BREAK_STARTED

Fired when an ad break starts.

AD_PROGRESS

Fired when there is an update to an ad's progress.

CLICK

Dispatched when the click element is clicked or tapped while an ad is being played.

COMPLETE

Fired when an ad is complete.

CUEPOINTS_CHANGED

Dispatched for on-demand streams when the cuepoints change.

ERROR

Fired when an error occurs.

FIRST_QUARTILE

Fired when an ad reaches its first quartile.

LOADED

Fired when the stream manifest is available.

MIDPOINT

Fired when an ad reaches its midpoint.

STARTED

Fired when an ad starts.

STREAM_INITIALIZED

Fired when the stream is initialized.

THIRD_QUARTILE

Fired when an ad reaches its third quartile.

Class google.ima.dai.api.StreamManager

Methods

Handles dynamic ad insertion streams. It manages interactions with the DAI backend and handles tracking pings as well as forwarding stream and ad events to the publisher. This manager does not inherit from the BaseAdsManager since it isn't a manager for a specific ad, but one for the entire stream

Constructor:
Parameter Type Description
videoElement HTMLVideoElement

The actual video player element.

contentTimeForStreamTime(streamTime)

Returns the content time without ads for a given stream time. Returns the given stream time for live streams.

Returns number: the content time that corresponds with the given stream time once ads are removed.

Parameter Type Description
streamTime number

the stream time with inserted ads (in seconds).

onTimedMetadata(metadata)

Passes in a dictionary of processed metadata. The dictionary expects the key 'TXXX' with the user-defined metadata string as the value. If your player provides raw metadata, call ima.dai.api.StreamManager.processMetadata instead.

Parameter Type Description
metadata Object

The dictionary of metadata.

previousCuePointForStreamTime(streamTime)

Returns the previous cuepoint for the given stream time. Returns null if no such cuepoint exists. This is used to implement features like snap back, and called when the publisher detects that the user seeked in order to return the user to an ad break.

Returns google.ima.dai.api.CuePoint: the previous cuepoint for the given stream time.

Parameter Type Description
streamTime number

the stream time that was seeked to.

processMetadata(type, data, timestamp)

Processes timed metadata for live streams. Use if your video player provides unparsed metadata along with timestamps, otherwise, call ima.dai.api.StreamManager.onTimedMetadata.

Parameter Type Description
type string

Type for metadata. Must be 'ID3'.

data Uint8Array

Raw tag data. For ID3, must be the entire tag.

timestamp number

Time when data should be processed.

requestStream(streamRequest)

Requests a stream to be loaded using provided stream parameters.

Parameter Type Description
streamRequest google.ima.dai.api.StreamRequest

contains parameters to load the stream metadata.

setClickElement(clickElement)

Sets the ads click through element. This element is used as the click or tap receiver while an ad is playing, and may result in navigation away from the current page.

Parameter Type Description
clickElement Element

the element used as the ad click through.

streamTimeForContentTime(contentTime)

Returns the stream time with ads for a given content time. Returns the given content time for live streams.

Returns number: the stream time that corresponds with the given content time once ads are inserted.

Parameter Type Description
contentTime number

the content time without any ads (in seconds).

Class google.ima.dai.api.StreamRequest

Fields

A class for specifying properties of the stream request.

Properties

Name Type Description
adTagParameters

You can override a limited set of ad tag parameters on your stream request. Supply targeting parameters to your stream provides more information. You can use the dai-ot and dai-ov parameters for stream variant preference. See Override Stream Variant Parameters for more information.

apiKey

The stream request API key. It's configured through the DFP Admin UI and provided to the publisher to unlock their content. It verifies the applications that are attempting to access the content.

streamActivityMonitorId

The ID to be used to debug the stream with the stream activity monitor. This is used to provide a convenient way to allow publishers to find a stream log in the stream activity monitor tool.

Class google.ima.dai.api.VODStreamRequest

Fields

A class for specifying properties of the VOD stream request.

Constructor:
Parameter Type Description
opt_VODStreamRequest Object

object that already has stream request properties assigned.

Properties

Name Type Description
contentSourceId

Unique identifier for the publisher content, from a CMS. Required for on-demand streams.

videoId

Identifier for the video content source. Required for on-demand streams.

Constant google.ima.VERSION

A string containing the full version of the SDK.