| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- require("./AnyThinkAds/ATInterstitialJSSDK");
- require("./AnyThinkAds/ATJSSDK");
- var ATInterstitialJS = cc.Class({
- name: "ATInterstitialJS",
- /** 代理脚本(TS) */
- proxy: null,
- ctor: function () {
- // console.log("ATNativeJS created! ");
- },
- init: function () {
- ATInterstitialJSSDK.setAdListener(this);
- },
- /** 广告位id */
- placementID: function () {
- return this.proxy.placementID();
- },
- /**
- * 检查插屏是否加载成功
- * @returns
- */
- hasAdReady: function () {
- if (this.proxy == null) return;
- return ATInterstitialJSSDK.hasAdReady(this.placementID()) ? true : false;
- },
- /**
- * 插屏广告加载
- */
- loadInter: function () {
- //v5.6.8新增,只针对Sigmob平台,Sigmob的激励视频广告源当做插屏使用
- var setting = {};
- setting[ATInterstitialJSSDK.UseRewardedVideoAsInterstitial] = false;
- ATInterstitialJSSDK.loadInterstitial(this.placementID(), setting);
- },
- /**
- * 显示插屏
- */
- showInter: function () {
- ATInterstitialJSSDK.showAd(this.placementID());
- },
- /**
- * 插屏广告加载成功
- * @param {*} placementId 广告位Id
- * @returns
- */
- onInterstitialAdLoaded: function (placementId) {
- //ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdLoaded(" + placementId + ")");
- if (this.proxy == null) return;
- this.proxy.onInterstitialAdLoaded(placementId);
- },
- /**
- * 插屏广告加载失败
- * @param {*} placementId 广告位Id
- * @param {*} errorInfo 错误信息
- * @returns
- */
- onInterstitialAdLoadFail: function (placementId, errorInfo) {
- ATJSSDK.printLog("===[AnyThinkInterstitialDemo::onInterstitialAdLoadFail(" + placementId + ", " + errorInfo + ")");
- if (this.proxy == null) return;
- this.proxy.onInterstitialAdLoadFail(placementId, errorInfo);
- },
- /**
- * 插屏广告显示成功
- * @param {*} placementId 广告位id
- * @param {*} callbackInfo 回调信息
- * @returns
- */
- onInterstitialAdShow: function (placementId, callbackInfo) {
- //ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdShow(" + placementId + ", " + callbackInfo + ")");
- if (this.proxy == null) return;
- this.proxy.onInterstitialAdShow(placementId, callbackInfo);
- },
- //广告视频开始播放,部分平台有此回调
- /**
- * 插屏广告开始播放视屏,部分广告平台有此回调
- * @param {*} placementId 广告位id
- * @param {*} callbackInfo 回调信息
- */
- onInterstitialAdStartPlayingVideo: function (placementId, callbackInfo) {
- // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdStartPlayingVideo(" + placementId + ", " + callbackInfo + ")");
- },
- /**
- * 插屏广告视频播放结束,部分广告平台有此回调
- * @param {*} placementId 广告位id
- * @param {*} callbackInfo 回调信息
- */
- onInterstitialAdEndPlayingVideo: function (placementId, callbackInfo) {
- // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdEndPlayingVideo(" + placementId + ", " + callbackInfo + ")");
- },
- /**
- * 插屏广告视频播放失败,部分广告平台有此回调
- * @param {*} placementId 广告位id
- * @param {*} errorInfo 错误回调
- */
- onInterstitialAdFailedToPlayVideo: function (placementId, errorInfo) {
- // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdFailedToPlayVideo(" + placementId + ", " + errorInfo + ")");
- if (this.proxy == null) return;
- this.proxy.onInterstitialAdFailedToPlayVideo(placementId, errorInfo);
- },
- /**
- * 插屏广告显示失败
- * @param {*} placementId 广告位id
- */
- onInterstitialAdFailedToShow: function (placementId) {
- // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdFailedToShow(" + placementId + ")");
- },
- /**
- * 广告被关闭
- * @param {*} placementId 广告位id
- * @param {*} callbackInfo 回调信息
- * @returns
- */
- onInterstitialAdClose: function (placementId, callbackInfo) {
- // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdClose(" + placementId + ", " + callbackInfo + ")");
- if (this.proxy == null) return;
- this.proxy.onInterstitialAdClose(placementId, callbackInfo);
- },
- /**
- * 广告被点击
- * @param {*} placementId 广告位id
- * @param {*} callbackInfo 回调信息
- * @returns
- */
- onInterstitialAdClick: function (placementId, callbackInfo) {
- // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdClick(" + placementId + ", " + callbackInfo + ")");
- if (this.proxy == null) return;
- this.proxy.onInterstitialAdClick(placementId, callbackInfo);
- }
- });
- module.exports = ATInterstitialJS;
- if (!cc["ATInterstitialJS"]) {
- cc["ATInterstitialJS"] = new ATInterstitialJS();
- }
|