在 google IMA 广告中查找广告状态(已完成或已跳过)?
Finding ad status in google IMA ads (Completed or Skipped)?
我需要查找广告被跳过或完成的天气。还启动或加载和/或单击。我对 google 的开发文档感到困惑。我需要得到这样的东西,
if (google.ima.AdEvent.Type.COMPLETE){
console.log("Ad has been completed")
}
有这样的东西吗?
google.ima.AdEvent 包括“已跳过”和“已完成”等(参见 here for full reference list). You can track each of these adEvent.type using and event listener attached to the adsManager instance (details here):
//get ads manager
adsManager = adsManagerLoadedEvent.getAdsManager(
videoContent, adsRenderingSettings);
//add eventlistener
adsManager.addEventListener(google.ima.AdEvent.Type.LOADED, onAdEvent);
adsManager.addEventListener(google.ima.AdEvent.Type.SKIPPED, onAdEvent);
adsManager.addEventListener(google.ima.AdEvent.Type.STARTED, onAdEvent);
adsManager.addEventListener(google.ima.AdEvent.Type.COMPLETE, onAdEvent);
//adEvent function
function onAdEvent(adEvent) {
var ad = adEvent.getAd();
switch (adEvent.type) {
case google.ima.AdEvent.Type.LOADED:
console.log('loaded');
break;
case google.ima.AdEvent.Type.STARTED:
console.log('started');
break;
case google.ima.AdEvent.Type.COMPLETE:
console.log('complete');
break;
case google.ima.AdEvent.Type.SKIPPED:
console.log('skipped');
break;
}
}
您可以下载工作示例和详细示例 here(具体请参阅“简单”示例)。
我需要查找广告被跳过或完成的天气。还启动或加载和/或单击。我对 google 的开发文档感到困惑。我需要得到这样的东西,
if (google.ima.AdEvent.Type.COMPLETE){
console.log("Ad has been completed")
}
有这样的东西吗?
google.ima.AdEvent 包括“已跳过”和“已完成”等(参见 here for full reference list). You can track each of these adEvent.type using and event listener attached to the adsManager instance (details here):
//get ads manager
adsManager = adsManagerLoadedEvent.getAdsManager(
videoContent, adsRenderingSettings);
//add eventlistener
adsManager.addEventListener(google.ima.AdEvent.Type.LOADED, onAdEvent);
adsManager.addEventListener(google.ima.AdEvent.Type.SKIPPED, onAdEvent);
adsManager.addEventListener(google.ima.AdEvent.Type.STARTED, onAdEvent);
adsManager.addEventListener(google.ima.AdEvent.Type.COMPLETE, onAdEvent);
//adEvent function
function onAdEvent(adEvent) {
var ad = adEvent.getAd();
switch (adEvent.type) {
case google.ima.AdEvent.Type.LOADED:
console.log('loaded');
break;
case google.ima.AdEvent.Type.STARTED:
console.log('started');
break;
case google.ima.AdEvent.Type.COMPLETE:
console.log('complete');
break;
case google.ima.AdEvent.Type.SKIPPED:
console.log('skipped');
break;
}
}
您可以下载工作示例和详细示例 here(具体请参阅“简单”示例)。