ATInterstitialJS.js 5.0 KB

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