//快手信息流广告
private void showKuaishouXinxiliuAd(long posId,ViewGroup viewGroup) {
KsScene scene = new KsScene.Builder(posId).adNum(1).build();
KsAdSDK.getLoadManager()
.loadFeedAd(scene, new KsLoadManager.FeedAdListener() {
@Override
public void onError(int code, String msg) {
// ToastUtil.showToast(mContext, "广告数据请求失败" + code + msg);
}
@Override
public void onFeedAdLoad(@Nullable List<KsFeedAd> adList) {
// if (mListView != null) {
// mListView.setLoadingFinish();
// }
if (adList == null || adList.isEmpty()) {
return;
}
for (KsFeedAd ksFeedAd : adList) {
if (ksFeedAd == null) {
continue;
}
KsAdVideoPlayConfig videoPlayConfig = new KsAdVideoPlayConfig.Builder()
.videoSoundEnable(false) // 是否有声播放
.dataFlowAutoStart(false) // 是否非WiFi下自动播放
.build();
ksFeedAd.setVideoPlayConfig(videoPlayConfig);
// 设置监听
ksFeedAd.setVideoSoundEnable(false);//视频播放是否,默认静音播放
ksFeedAd.setAdInteractionListener(new KsFeedAd.AdInteractionListener() {
@Override
public void onAdClicked() {
// ToastUtil.showToast(mContext, "广告点击回调");
}
@Override
public void onAdShow() {
// ToastUtil.showToast(mContext, "广告曝光回调");
}
@Override
public void onDislikeClicked() {
// ToastUtil.showToast(mContext, "广告不喜欢回调");
// mDataList.remove(ksFeedAd);
// notifyDataSetChanged();
}
});
View videoView = ksFeedAd.getFeedView(DailyWelfareActivity.this);
if (videoView != null && videoView.getParent() == null) {
viewGroup.removeAllViews();
viewGroup.addView(videoView);
}
}
}
});
}
网友评论