googleads / videojs-ima

IMA SDK Plugin for Video.js
Apache License 2.0
455 stars 285 forks source link

What is best way to read title from the current ad? #1021

Closed damjan25 closed 2 years ago

damjan25 commented 2 years ago

for example it can be done by this player.ima.getAdsManager().l.h.title This will return Tittle from the XML of the current ad loaded into IMA.

Is there some more clean way to read it ? Because the problem here is that this letter after getAdsManager() is always changing (probably because of uglified code) player.ima.getAdsManager().h.g.title (used to be this) player.ima.getAdsManager().l.h.title (now it changed to this)

I see here in docs (https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima.Ad#getTitle) that there is getTitle function, and that you are supposed to run it on google.ima.Ad.getTitle() but Ad object is not defined on google.ima object

damjan25 commented 2 years ago

Ok looks like there is a better way to read the title, just add listener to loaded event and check ad obj

player.ima.addEventListener(EventType.LOADED, (ad) => {
        console.log(ad.getAdData().title);
});

Does anyone know if this is also possible on returned object from player.ima.getAdsManager() ?

If not then this issue can be closed.

Kiro705 commented 2 years ago

Based on the APIs available for the IMA Ads Manager, it does not seem to be possible to read the title without calling ad.getAdData(). Using the LOADED event is the recommended way to achieve this.

Closing the issue.