ATInterstitialJS.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. require("./AnyThinkAds/ATInterstitialJSSDK");
  2. require("./AnyThinkAds/ATJSSDK");
  3. var ATInterstitialJS = cc.Class({
  4. name: "ATInterstitialJS",
  5. /** 代理脚本(TS) */
  6. proxy: null,
  7. ctor: function () {
  8. // console.log("ATNativeJS created! ");
  9. },
  10. init: function () {
  11. ATInterstitialJSSDK.setAdListener(this);
  12. },
  13. /** 广告位id */
  14. placementID: function () {
  15. return this.proxy.placementID();
  16. },
  17. /**
  18. * 检查插屏是否加载成功
  19. * @returns
  20. */
  21. hasAdReady: function () {
  22. if (this.proxy == null) return;
  23. return ATInterstitialJSSDK.hasAdReady(this.placementID()) ? true : false;
  24. },
  25. /**
  26. * 插屏广告加载
  27. */
  28. loadInter: function () {
  29. //v5.6.8新增,只针对Sigmob平台,Sigmob的激励视频广告源当做插屏使用
  30. var setting = {};
  31. setting[ATInterstitialJSSDK.UseRewardedVideoAsInterstitial] = false;
  32. ATInterstitialJSSDK.loadInterstitial(this.placementID(), setting);
  33. },
  34. /**
  35. * 显示插屏
  36. */
  37. showInter: function () {
  38. ATInterstitialJSSDK.showAd(this.placementID());
  39. },
  40. /**
  41. * 插屏广告加载成功
  42. * @param {*} placementId 广告位Id
  43. * @returns
  44. */
  45. onInterstitialAdLoaded: function (placementId) {
  46. //ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdLoaded(" + placementId + ")");
  47. if (this.proxy == null) return;
  48. this.proxy.onInterstitialAdLoaded(placementId);
  49. },
  50. /**
  51. * 插屏广告加载失败
  52. * @param {*} placementId 广告位Id
  53. * @param {*} errorInfo 错误信息
  54. * @returns
  55. */
  56. onInterstitialAdLoadFail: function (placementId, errorInfo) {
  57. ATJSSDK.printLog("===[AnyThinkInterstitialDemo::onInterstitialAdLoadFail(" + placementId + ", " + errorInfo + ")");
  58. if (this.proxy == null) return;
  59. this.proxy.onInterstitialAdLoadFail(placementId, errorInfo);
  60. },
  61. /**
  62. * 插屏广告显示成功
  63. * @param {*} placementId 广告位id
  64. * @param {*} callbackInfo 回调信息
  65. * @returns
  66. */
  67. onInterstitialAdShow: function (placementId, callbackInfo) {
  68. //ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdShow(" + placementId + ", " + callbackInfo + ")");
  69. if (this.proxy == null) return;
  70. this.proxy.onInterstitialAdShow(placementId, callbackInfo);
  71. },
  72. //广告视频开始播放,部分平台有此回调
  73. /**
  74. * 插屏广告开始播放视屏,部分广告平台有此回调
  75. * @param {*} placementId 广告位id
  76. * @param {*} callbackInfo 回调信息
  77. */
  78. onInterstitialAdStartPlayingVideo: function (placementId, callbackInfo) {
  79. // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdStartPlayingVideo(" + placementId + ", " + callbackInfo + ")");
  80. },
  81. /**
  82. * 插屏广告视频播放结束,部分广告平台有此回调
  83. * @param {*} placementId 广告位id
  84. * @param {*} callbackInfo 回调信息
  85. */
  86. onInterstitialAdEndPlayingVideo: function (placementId, callbackInfo) {
  87. // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdEndPlayingVideo(" + placementId + ", " + callbackInfo + ")");
  88. },
  89. /**
  90. * 插屏广告视频播放失败,部分广告平台有此回调
  91. * @param {*} placementId 广告位id
  92. * @param {*} errorInfo 错误回调
  93. */
  94. onInterstitialAdFailedToPlayVideo: function (placementId, errorInfo) {
  95. // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdFailedToPlayVideo(" + placementId + ", " + errorInfo + ")");
  96. if (this.proxy == null) return;
  97. this.proxy.onInterstitialAdFailedToPlayVideo(placementId, errorInfo);
  98. },
  99. /**
  100. * 插屏广告显示失败
  101. * @param {*} placementId 广告位id
  102. */
  103. onInterstitialAdFailedToShow: function (placementId) {
  104. // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdFailedToShow(" + placementId + ")");
  105. },
  106. /**
  107. * 广告被关闭
  108. * @param {*} placementId 广告位id
  109. * @param {*} callbackInfo 回调信息
  110. * @returns
  111. */
  112. onInterstitialAdClose: function (placementId, callbackInfo) {
  113. // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdClose(" + placementId + ", " + callbackInfo + ")");
  114. if (this.proxy == null) return;
  115. this.proxy.onInterstitialAdClose(placementId, callbackInfo);
  116. },
  117. /**
  118. * 广告被点击
  119. * @param {*} placementId 广告位id
  120. * @param {*} callbackInfo 回调信息
  121. * @returns
  122. */
  123. onInterstitialAdClick: function (placementId, callbackInfo) {
  124. // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdClick(" + placementId + ", " + callbackInfo + ")");
  125. if (this.proxy == null) return;
  126. this.proxy.onInterstitialAdClick(placementId, callbackInfo);
  127. }
  128. });
  129. module.exports = ATInterstitialJS;
  130. if (!cc["ATInterstitialJS"]) {
  131. cc["ATInterstitialJS"] = new ATInterstitialJS();
  132. }