From 7e2ac66d7c532a5725635fa3913789bb17c1e157 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 21 十月 2021 13:46:33 +0800 Subject: [PATCH] 隐私合规,青少年模式,64位兼容 --- library-video/src/main/java/com/yeshi/video/ui/PPTVPlayFragment.java | 206 ++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 144 insertions(+), 62 deletions(-) diff --git a/library-video/src/main/java/com/yeshi/video/ui/PPTVPlayFragment.java b/library-video/src/main/java/com/yeshi/video/ui/PPTVPlayFragment.java index c13431c..05ba387 100644 --- a/library-video/src/main/java/com/yeshi/video/ui/PPTVPlayFragment.java +++ b/library-video/src/main/java/com/yeshi/video/ui/PPTVPlayFragment.java @@ -33,9 +33,15 @@ import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd; import com.lcjian.library.RetainViewFragment; import com.lcjian.library.util.common.ClipboardUtil; +import com.qq.e.ads.cfg.VideoOption; +import com.qq.e.ads.interstitial2.UnifiedInterstitialAD; +import com.qq.e.ads.interstitial2.UnifiedInterstitialADListener; +import com.qq.e.comm.util.AdError; import com.umeng.analytics.MobclickAgent; +import com.yeshi.base.entity.ad.AdPositionEnum; import com.yeshi.base.ui.dialog.LoadingDialogUtil; import com.yeshi.base.utils.RouteConstant; +import com.yeshi.base.utils.ad.AdUtil; import com.yeshi.base.utils.ad.CSJConstant; import com.yeshi.video.R; import com.yeshi.video.utils.PPJavaInterface; @@ -265,7 +271,7 @@ @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - + showInterstitialAd(); return super.onCreateView(inflater, container, savedInstanceState); } @@ -462,74 +468,150 @@ TTFullScreenVideoAd mttFullVideoAd = null; private boolean isInterstitialAdShown = false; + private UnifiedInterstitialAD iad; private void showInterstitialAd() { if (isInterstitialAdShown) return; + if (AdUtil.getAdType(getContext(), AdPositionEnum.videoDetailFullVideo) == null) { + return; + } - TTAdNative mTTAdNative = TTAdSdk.getAdManager().createAdNative(getContext()); - AdSlot adSlot = new AdSlot.Builder() - .setCodeId(CSJConstant.PPTV_INTERSTITIALAD) - //妯℃澘骞垮憡闇�瑕佽缃湡鏈涗釜鎬у寲妯℃澘骞垮憡鐨勫ぇ灏�,鍗曚綅dp,婵�鍔辫棰戝満鏅紝鍙璁剧疆鐨勫�煎ぇ浜�0鍗冲彲 - .setExpressViewAcceptedSize(300, 500) - .setSupportDeepLink(true) - .setOrientation(TTAdConstant.VERTICAL)//蹇呭~鍙傛暟锛屾湡鏈涜棰戠殑鎾斁鏂瑰悜锛歍TAdConstant.HORIZONTAL 鎴� TTAdConstant.VERTICAL - .build(); - mTTAdNative.loadFullScreenVideoAd(adSlot, new TTAdNative.FullScreenVideoAdListener() { - //璇锋眰骞垮憡澶辫触 - @Override - public void onError(int code, String message) { + boolean csj = TTAdSdk.isInitSuccess(); + if (csj) { + TTAdNative mTTAdNative = TTAdSdk.getAdManager().createAdNative(getContext()); + AdSlot adSlot = new AdSlot.Builder() + .setCodeId(getString(R.string.ad_csj_pid_pptv_insert)) + //妯℃澘骞垮憡闇�瑕佽缃湡鏈涗釜鎬у寲妯℃澘骞垮憡鐨勫ぇ灏�,鍗曚綅dp,婵�鍔辫棰戝満鏅紝鍙璁剧疆鐨勫�煎ぇ浜�0鍗冲彲 + .setExpressViewAcceptedSize(300, 500) + .setSupportDeepLink(true) + .setOrientation(TTAdConstant.VERTICAL)//蹇呭~鍙傛暟锛屾湡鏈涜棰戠殑鎾斁鏂瑰悜锛歍TAdConstant.HORIZONTAL 鎴� TTAdConstant.VERTICAL + .build(); + mTTAdNative.loadFullScreenVideoAd(adSlot, new TTAdNative.FullScreenVideoAdListener() { + //璇锋眰骞垮憡澶辫触 + @Override + public void onError(int code, String message) { - } - - //骞垮憡鐗╂枡鍔犺浇瀹屾垚鐨勫洖璋� - @Override - public void onFullScreenVideoAdLoad(TTFullScreenVideoAd ad) { - mttFullVideoAd = ad; - mttFullVideoAd.setFullScreenVideoAdInteractionListener(new TTFullScreenVideoAd.FullScreenVideoAdInteractionListener() { - //骞垮憡鐨勫睍绀哄洖璋� - @Override - public void onAdShow() { - isInterstitialAdShown = true; - } - - //骞垮憡鐨勪笅杞絙ar鐐瑰嚮鍥炶皟 - @Override - public void onAdVideoBarClick() { - - } - - //骞垮憡鍏抽棴鐨勫洖璋� - @Override - public void onAdClose() { - - } - - //瑙嗛鎾斁瀹屾瘯鐨勫洖璋� - @Override - public void onVideoComplete() { - - } - - //璺宠繃瑙嗛鎾斁 - @Override - public void onSkippedVideo() { - - } - }); - } - - //骞垮憡瑙嗛/鍥剧墖鍔犺浇瀹屾垚鐨勫洖璋冿紝鎺ュ叆鏂瑰彲浠ュ湪杩欎釜鍥炶皟鍚庡睍绀哄箍鍛� - @Override - public void onFullScreenVideoCached() { - if (mttFullVideoAd != null) { - //灞曠ず骞垮憡锛屽苟浼犲叆骞垮憡灞曠ず鐨勫満鏅� - if (getActivity() != null) - mttFullVideoAd.showFullScreenVideoAd(getActivity(), TTAdConstant.RitScenes.GAME_GIFT_BONUS, null); - mttFullVideoAd = null; } - } - }); + + //骞垮憡鐗╂枡鍔犺浇瀹屾垚鐨勫洖璋� + @Override + public void onFullScreenVideoAdLoad(TTFullScreenVideoAd ad) { + mttFullVideoAd = ad; + mttFullVideoAd.setFullScreenVideoAdInteractionListener(new TTFullScreenVideoAd.FullScreenVideoAdInteractionListener() { + //骞垮憡鐨勫睍绀哄洖璋� + @Override + public void onAdShow() { + isInterstitialAdShown = true; + } + + //骞垮憡鐨勪笅杞絙ar鐐瑰嚮鍥炶皟 + @Override + public void onAdVideoBarClick() { + + } + + //骞垮憡鍏抽棴鐨勫洖璋� + @Override + public void onAdClose() { + + } + + //瑙嗛鎾斁瀹屾瘯鐨勫洖璋� + @Override + public void onVideoComplete() { + + } + + //璺宠繃瑙嗛鎾斁 + @Override + public void onSkippedVideo() { + + } + }); + } + + //骞垮憡瑙嗛/鍥剧墖鍔犺浇瀹屾垚鐨勫洖璋冿紝鎺ュ叆鏂瑰彲浠ュ湪杩欎釜鍥炶皟鍚庡睍绀哄箍鍛� + @Override + public void onFullScreenVideoCached() { + if (mttFullVideoAd != null) { + //灞曠ず骞垮憡锛屽苟浼犲叆骞垮憡灞曠ず鐨勫満鏅� + if (getActivity() != null) + mttFullVideoAd.showFullScreenVideoAd(getActivity(), TTAdConstant.RitScenes.GAME_GIFT_BONUS, null); + mttFullVideoAd = null; + } + } + + @Override + public void onFullScreenVideoCached(TTFullScreenVideoAd ttFullScreenVideoAd) { + if (ttFullScreenVideoAd != null) { + //灞曠ず骞垮憡锛屽苟浼犲叆骞垮憡灞曠ず鐨勫満鏅� + if (getActivity() != null) + ttFullScreenVideoAd.showFullScreenVideoAd(getActivity(), TTAdConstant.RitScenes.GAME_GIFT_BONUS, null); + } + } + }); + } else { + iad = new UnifiedInterstitialAD(getActivity(), getString(R.string.ad_gdt_pid_pptv_insert), new UnifiedInterstitialADListener() { + + @Override + public void onADReceive() { + iad.showAsPopupWindow(getActivity()); + } + + @Override + public void onVideoCached() { + + } + + @Override + public void onNoAD(AdError adError) { + + Log.i("gdt", adError.toString()); + } + + @Override + public void onADOpened() { + + } + + @Override + public void onADExposure() { + + } + + @Override + public void onADClicked() { + + } + + @Override + public void onADLeftApplication() { + + } + + @Override + public void onADClosed() { + + } + + @Override + public void onRenderSuccess() { + + } + + @Override + public void onRenderFail() { + + } + }); + VideoOption.Builder builder = new VideoOption.Builder(); + VideoOption + option = builder.setAutoPlayMuted(true) + .setAutoPlayPolicy(VideoOption.AutoPlayPolicy.WIFI).build(); + iad.setVideoOption(option); + iad.loadAD(); + } } -- Gitblit v1.8.0