本文整理汇总了Java中com.google.ads.interactivemedia.v3.api.AdEvent类的典型用法代码示例。如果您正苦于以下问题:Java AdEvent类的具体用法?Java AdEvent怎么用?Java AdEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AdEvent类属于com.google.ads.interactivemedia.v3.api包,在下文中一共展示了AdEvent类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onAdEvent
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
/**
* Responds to AdEvents.
*/
@Override
public void onAdEvent(AdEvent adEvent) {
if (DEBUG) {
Log.d(TAG, "Event: " + adEvent.getType());
}
// These are the suggested event types to handle. For full list of all ad event types,
// see the documentation for AdEvent.AdEventType.
switch (adEvent.getType()) {
case LOADED:
// AdEventType.LOADED will be fired when ads are ready to be played.
// AdsManager.start() begins ad playback. This method is ignored for VMAP or ad
// rules playlists, as the SDK will automatically start executing the playlist.
mAdsManager.start();
break;
case COMPLETED:
// AdEventType.COMPLETED is fire when ad is completed, but before the fire of
// AdEventType.CONTENT_RESUME_REQUESTED.
mAdControllerCallback.onAdCompleted();
release();
break;
default:
break;
}
}
开发者ID:googlesamples,项目名称:androidtv-sample-inputs,代码行数:28,代码来源:AdController.java
示例2: onAdEvent
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
@Override
public void onAdEvent(AdEvent event) {
switch (event.getType()) {
case LOADED:
adsManager.start();
break;
case CONTENT_PAUSE_REQUESTED:
pauseContent();
break;
case CONTENT_RESUME_REQUESTED:
resumeContent();
break;
default:
break;
}
}
开发者ID:googleads,项目名称:google-media-framework-android,代码行数:17,代码来源:ImaPlayer.java
示例3: onAdEvent
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
@Override
public void onAdEvent(AdEvent adEvent) {
Log.i(LOGTAG, "Event: " + adEvent.getType());
// These are the suggested event types to handle. For full list of all ad event
// types, see the documentation for AdEvent.AdEventType.
switch (adEvent.getType()) {
case LOADED:
// AdEventType.LOADED will be fired when ads are ready to be played.
// AdsManager.start() begins ad playback. This method is ignored for VMAP or
// ad rules playlists, as the SDK will automatically start executing the
// playlist.
mAdsManager.start();
break;
case CONTENT_PAUSE_REQUESTED:
// AdEventType.CONTENT_PAUSE_REQUESTED is fired immediately before a video
// ad is played.
mIsAdDisplayed = true;
mVideoPlayer.pause();
break;
case CONTENT_RESUME_REQUESTED:
// AdEventType.CONTENT_RESUME_REQUESTED is fired when the ad is completed
// and you should start playing your content.
mIsAdDisplayed = false;
mVideoPlayer.play();
break;
case ALL_ADS_COMPLETED:
if (mAdsManager != null) {
mAdsManager.destroy();
mAdsManager = null;
}
break;
default:
break;
}
}
开发者ID:googleads,项目名称:googleads-ima-android,代码行数:37,代码来源:MyActivity.java
示例4: onAdEvent
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
/**
* Responds to AdEvents.
*/
@Override
public void onAdEvent(AdEvent adEvent) {
LOGD(TAG, "Start onAdEvent " + adEvent.getType().name());
if (mListener != null) {
mListener.onAdEvent(adEvent.getType(), adJSONValue(adEvent));
}
}
开发者ID:kaltura,项目名称:player-sdk-native-android,代码行数:13,代码来源:KIMAManager.java
示例5: adJSONValue
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
private String adJSONValue(AdEvent adEvent) {
if (adEvent == null) {
return "(null)";
}
Ad ad = adEvent.getAd();
JSONObject jsonValue = null;
try {
jsonValue = new JSONObject();
switch (adEvent.getType()) {
case LOADED:
mAdsManager.start();
jsonValue.put(IsLinearKey, ad.isLinear());
jsonValue.put(AdIDKey, ad.getAdId());
jsonValue.put(AdSystemKey, "null");
jsonValue.put(AdPositionKey, ad.getAdPodInfo().getAdPosition());
break;
case COMPLETED:
jsonValue.put(AdIDKey, ad.getAdId());
break;
case CLICKED:
jsonValue.put(IsLinearKey, ad.isLinear());
break;
case SKIPPED:
jsonValue.put(IsLinearKey, ad.isLinear());
break;
}
} catch (Exception e) {
}
return jsonValue.toString();
}
开发者ID:kaltura,项目名称:player-sdk-native-android,代码行数:32,代码来源:KIMAManager.java
示例6: adDurationUpdate
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
@Override
public void adDurationUpdate(float totalTime) {
JSONObject jsonValue = new JSONObject();
try {
jsonValue.put(DurationKey, totalTime);
mListener.onAdEvent(AdEvent.AdEventType.STARTED, jsonValue.toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
开发者ID:kaltura,项目名称:player-sdk-native-android,代码行数:11,代码来源:KIMAManager.java
示例7: onAdEvent
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
@Override
public void onAdEvent(AdEvent.AdEventType eventType, String jsonValue) {
if (playerListener != null) {
playerListener.eventWithJSON(player, KIMAManagerEvents.eventName(eventType), jsonValue);
}
switch (eventType) {
case CONTENT_RESUME_REQUESTED:
((View)player).setVisibility(View.VISIBLE);
isIMAActive = false;
player.setShouldCancelPlay(false);
player.play();
break;
case CONTENT_PAUSE_REQUESTED:
isIMAActive = true;
pause();
((View)player).setVisibility(View.INVISIBLE);
break;
case ALL_ADS_COMPLETED:
if (isContentCompleted && playerListener != null) {
playerListener.eventWithValue(player, KPlayerListener.EndedKey, null);
isContentCompleted = false;
}
removeAdPlayer();
break;
}
}
开发者ID:kaltura,项目名称:player-sdk-native-android,代码行数:28,代码来源:KPlayerController.java
示例8: onAdEvent
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
@Override
public void onAdEvent(AdEvent adEvent) {
AdEventType adEventType = adEvent.getType();
boolean isLogAdEvent = adEventType == AdEventType.LOG;
if (DEBUG || isLogAdEvent) {
Log.w(TAG, "onAdEvent: " + adEventType);
if (isLogAdEvent) {
for (Map.Entry<String, String> entry : adEvent.getAdData().entrySet()) {
Log.w(TAG, " " + entry.getKey() + ": " + entry.getValue());
}
}
}
if (adsManager == null) {
Log.w(TAG, "Dropping ad event after release: " + adEvent);
return;
}
Ad ad = adEvent.getAd();
switch (adEvent.getType()) {
case LOADED:
// The ad position is not always accurate when using preloading. See [Internal: b/62613240].
AdPodInfo adPodInfo = ad.getAdPodInfo();
int podIndex = adPodInfo.getPodIndex();
adGroupIndex = podIndex == -1 ? adPlaybackState.adGroupCount - 1 : podIndex;
int adPosition = adPodInfo.getAdPosition();
int adCountInAdGroup = adPodInfo.getTotalAds();
adsManager.start();
if (DEBUG) {
Log.d(TAG, "Loaded ad " + adPosition + " of " + adCountInAdGroup + " in ad group "
+ adGroupIndex);
}
adPlaybackState.setAdCount(adGroupIndex, adCountInAdGroup);
updateAdPlaybackState();
break;
case CONTENT_PAUSE_REQUESTED:
// After CONTENT_PAUSE_REQUESTED, IMA will playAd/pauseAd/stopAd to show one or more ads
// before sending CONTENT_RESUME_REQUESTED.
imaPausedContent = true;
pauseContentInternal();
break;
case STARTED:
if (ad.isSkippable()) {
focusSkipButton();
}
break;
case TAPPED:
if (eventListener != null) {
eventListener.onAdTapped();
}
break;
case CLICKED:
if (eventListener != null) {
eventListener.onAdClicked();
}
break;
case CONTENT_RESUME_REQUESTED:
imaPausedContent = false;
resumeContentInternal();
break;
case ALL_ADS_COMPLETED:
// Do nothing. The ads manager will be released when the source is released.
default:
break;
}
}
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:65,代码来源:ImaAdsLoader.java
示例9: addAdEventListener
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
public void addAdEventListener(final AdEvent.AdEventListener l) {
adEventListeners.add(l);
if (adsManager != null) {
adsManager.addAdEventListener(l);
}
}
开发者ID:satorufujiwara,项目名称:exoplayer-ima,代码行数:7,代码来源:AdPlayerController.java
示例10: removeAdEventListener
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
public void removeAdEventListener(final AdEvent.AdEventListener l) {
adEventListeners.remove(l);
if (adsManager != null) {
adsManager.removeAdEventListener(l);
}
}
开发者ID:satorufujiwara,项目名称:exoplayer-ima,代码行数:7,代码来源:AdPlayerController.java
示例11: onAdEvent
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
@Override
public void onAdEvent(AdEvent adEvent) {
AdEventType adEventType = adEvent.getType();
boolean isLogAdEvent = adEventType == AdEventType.LOG;
if (DEBUG || isLogAdEvent) {
Log.w(TAG, "onAdEvent: " + adEventType);
if (isLogAdEvent) {
for (Map.Entry<String, String> entry : adEvent.getAdData().entrySet()) {
Log.w(TAG, " " + entry.getKey() + ": " + entry.getValue());
}
}
}
if (adsManager == null) {
Log.w(TAG, "Dropping ad event after release: " + adEvent);
return;
}
Ad ad = adEvent.getAd();
switch (adEvent.getType()) {
case LOADED:
// The ad position is not always accurate when using preloading. See [Internal: b/62613240].
AdPodInfo adPodInfo = ad.getAdPodInfo();
int podIndex = adPodInfo.getPodIndex();
adGroupIndex =
podIndex == -1 ? (adPlaybackState.adGroupCount - 1) : (podIndex + podIndexOffset);
int adPosition = adPodInfo.getAdPosition();
int adCount = adPodInfo.getTotalAds();
adsManager.start();
if (DEBUG) {
Log.d(TAG, "Loaded ad " + adPosition + " of " + adCount + " in group " + adGroupIndex);
}
adPlaybackState.setAdCount(adGroupIndex, adCount);
updateAdPlaybackState();
break;
case CONTENT_PAUSE_REQUESTED:
// After CONTENT_PAUSE_REQUESTED, IMA will playAd/pauseAd/stopAd to show one or more ads
// before sending CONTENT_RESUME_REQUESTED.
imaPausedContent = true;
pauseContentInternal();
break;
case STARTED:
if (ad.isSkippable()) {
focusSkipButton();
}
break;
case TAPPED:
if (eventListener != null) {
eventListener.onAdTapped();
}
break;
case CLICKED:
if (eventListener != null) {
eventListener.onAdClicked();
}
break;
case CONTENT_RESUME_REQUESTED:
imaPausedContent = false;
resumeContentInternal();
break;
case ALL_ADS_COMPLETED:
// Do nothing. The ads manager will be released when the source is released.
default:
break;
}
}
开发者ID:y20k,项目名称:transistor,代码行数:65,代码来源:ImaAdsLoader.java
示例12: onAdsManagerLoaded
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
/**
* An event raised when ads are successfully loaded from the ad server via AdsLoader.
*/
@Override
public void onAdsManagerLoaded(AdsManagerLoadedEvent adsManagerLoadedEvent) {
// Ads were successfully loaded, so get the AdsManager instance. AdsManager has
// events for ad playback and errors.
mAdsManager = adsManagerLoadedEvent.getAdsManager();
// Attach event and error event listeners.
mAdsManager.addAdErrorListener(new AdErrorEvent.AdErrorListener() {
/**
* An event raised when there is an error loading or playing ads.
*/
@Override
public void onAdError(AdErrorEvent adErrorEvent) {
log("Ad Error: " + adErrorEvent.getError().getMessage());
resumeContent();
}
});
mAdsManager.addAdEventListener(new AdEvent.AdEventListener() {
/**
* Responds to AdEvents.
*/
@Override
public void onAdEvent(AdEvent adEvent) {
log("Event: " + adEvent.getType());
// These are the suggested event types to handle. For full list of all ad
// event types, see the documentation for AdEvent.AdEventType.
switch (adEvent.getType()) {
case LOADED:
// AdEventType.LOADED will be fired when ads are ready to be
// played. AdsManager.start() begins ad playback. This method is
// ignored for VMAP or ad rules playlists, as the SDK will
// automatically start executing the playlist.
mAdsManager.start();
break;
case CONTENT_PAUSE_REQUESTED:
// AdEventType.CONTENT_PAUSE_REQUESTED is fired immediately before
// a video ad is played.
pauseContent();
break;
case CONTENT_RESUME_REQUESTED:
// AdEventType.CONTENT_RESUME_REQUESTED is fired when the ad is
// completed and you should start playing your content.
resumeContent();
break;
case PAUSED:
mIsAdPlaying = false;
break;
case RESUMED:
mIsAdPlaying = true;
break;
case ALL_ADS_COMPLETED:
if (mAdsManager != null) {
mAdsManager.destroy();
mAdsManager = null;
}
break;
default:
break;
}
}
});
mAdsManager.init();
}
开发者ID:googleads,项目名称:googleads-ima-android,代码行数:68,代码来源:VideoPlayerController.java
示例13: eventName
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
public static String eventName(AdEvent.AdEventType adEventType) {
switch (adEventType) {
case ALL_ADS_COMPLETED:
return "allAdsCompleted";
case CLICKED:
return "adClicked";
case COMPLETED:
return "adCompleted";
case CONTENT_PAUSE_REQUESTED:
return "contentPauseRequested";
case CONTENT_RESUME_REQUESTED:
return "contentResumeRequested";
case FIRST_QUARTILE:
return "firstQuartile";
case LOG:
break;
case AD_BREAK_READY:
break;
case MIDPOINT:
return "midpoint";
case PAUSED:
break;
case RESUMED:
break;
case SKIPPED:
return "adSkipped";
case STARTED:
return "adStart";
case TAPPED:
break;
case THIRD_QUARTILE:
return "thirdQuartile";
case LOADED:
return "adLoaded";
case AD_BREAK_STARTED:
break;
case AD_BREAK_ENDED:
break;
}
return null;
}
开发者ID:kaltura,项目名称:player-sdk-native-android,代码行数:42,代码来源:KIMAManagerEvents.java
示例14: onAdEvent
import com.google.ads.interactivemedia.v3.api.AdEvent; //导入依赖的package包/类
void onAdEvent(AdEvent.AdEventType eventType, String jsonValue);
开发者ID:kaltura,项目名称:player-sdk-native-android,代码行数:2,代码来源:KIMAManagerListener.java
注:本文中的com.google.ads.interactivemedia.v3.api.AdEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论