Commit 6fa33815 authored by 王雪伟's avatar 王雪伟

修复激励视频加载问题

parent 66af472f
This diff is collapsed.
......@@ -13,5 +13,5 @@ public interface ZXADRewardVideoListener
//广告点击
void onAdVideoBarClick();
//关闭广告
void onAdClose();
void onAdClose(AdEntity entity);
}
......@@ -10,4 +10,6 @@ public interface ZXADSplashListener
void onAdSkip();
//获取广告 错误 广告
void onError(string errorMsg);
//最后的开屏也没有展示成功
void onLastError();
}
......@@ -68,7 +68,7 @@ public class ZXADConfig
}
private Dictionary<string, Queue<AdEntity>> AdCacheMap = new Dictionary<string, Queue<AdEntity>>();
private Dictionary<string, List<AdEntity>> AdCacheMap = new Dictionary<string, List<AdEntity>>();
/// <summary>
/// 保存缓存的广告数据
......@@ -78,16 +78,17 @@ public class ZXADConfig
/// <param name="type">广告组</param>
public void SetAdCache(string slotName, AdEntity entity,string type)
{
Queue<AdEntity> mAdCacheQueue;
Debug.unityLogger.Log("Reward", "Admanger Settype"+ entity.adPlatform+" " + type);
List<AdEntity> mAdCacheQueue;
if (AdCacheMap.ContainsKey(type + slotName))
{
mAdCacheQueue = AdCacheMap[type + slotName];
}
else
{
mAdCacheQueue = new Queue<AdEntity>();
mAdCacheQueue = new List<AdEntity>();
}
mAdCacheQueue.Enqueue(entity);
mAdCacheQueue.Add(entity);
AdCacheMap[type+slotName] = mAdCacheQueue;
}
......@@ -101,14 +102,14 @@ public class ZXADConfig
{
if (AdCacheMap.ContainsKey(type+slotName))
{
Queue<AdEntity> mAdCacheQueue = AdCacheMap[type + slotName];
List<AdEntity> mAdCacheQueue = AdCacheMap[type + slotName];
if (mAdCacheQueue != null && mAdCacheQueue.Count > 0)
{
return mAdCacheQueue.Dequeue();
return mAdCacheQueue[0];
}
else
{
AdCacheMap.Remove(type + slotName);
//AdCacheMap.Remove(type + slotName);
}
}
return null;
......@@ -116,10 +117,15 @@ public class ZXADConfig
public void RemoveAdCache(string slotName, string type)
{
//if (AdCacheMap.ContainsKey(type + slotName))
//{
// AdCacheMap.Remove(type + slotName);
//}
if (AdCacheMap.ContainsKey(type + slotName))
{
List<AdEntity> mAdCacheQueue = AdCacheMap[type + slotName];
if (mAdCacheQueue != null && mAdCacheQueue.Count > 0)
{
mAdCacheQueue.RemoveAt(0);
}
//AdCacheMap.Remove(type + slotName);
}
}
......
......@@ -41,7 +41,7 @@ public class CSJFullScreenUtil : MonoBehaviour
public void LoadCacheFullScreeVideoAd(AdEntity entity, Action<bool> callback)
public void LoadCacheFullScreeVideoAd(AdEntity entity, Action<AdEntity> callback)
{
//string iosSlotID = "945113164";
string iosSlotID = entity.codeId;
......@@ -68,7 +68,7 @@ public class CSJFullScreenUtil : MonoBehaviour
public void PlayCacheFullScreeVideoAd(AdEntity entity, ZXADFullScreenVideoListener listener, Action<bool> callback)
{
#if UNITY_IOS
ExpressFullScreenVideoAd fsAd = GetFSVideoAdForIOS(entity.codeGroup+entity.codeId);
ExpressFullScreenVideoAd fsAd = GetFSVideoAdForIOS(entity.codeGroup + entity.slotName);
if (fsAd!=null)
{
fsAd.SetFullScreenVideoAdInteractionListener(new FullScreenAdInteractionListener(entity,listener, callback));
......@@ -82,7 +82,7 @@ public class CSJFullScreenUtil : MonoBehaviour
#elif UNITY_ANDROID
FullScreenVideoAd fsAd = GetFSVideoAdForAndroid(entity.codeGroup + entity.codeId);
FullScreenVideoAd fsAd = GetFSVideoAdForAndroid(entity.codeGroup + entity.slotName);
if (fsAd != null)
{
fsAd.SetFullScreenVideoAdInteractionListener(new FullScreenAdInteractionListener(entity, listener, callback));
......@@ -103,8 +103,8 @@ public class CSJFullScreenUtil : MonoBehaviour
{
private CSJFullScreenUtil example;
private AdEntity entity;
private Action<bool> callback;
public FullScreenVideoAdListener(CSJFullScreenUtil example, AdEntity entity, Action<bool> callback)
private Action<AdEntity> callback;
public FullScreenVideoAdListener(CSJFullScreenUtil example, AdEntity entity, Action<AdEntity> callback)
{
this.example = example;
this.entity = entity;
......@@ -114,7 +114,7 @@ public class CSJFullScreenUtil : MonoBehaviour
public void OnError(int code, string message)
{
EventUtils.onEventPullFail(entity,code.ToString(),message);
callback(false);
callback(null);
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "CSJ 全屏视频 Error " + code + " meg " + message);
}
......@@ -122,8 +122,8 @@ public class CSJFullScreenUtil : MonoBehaviour
{
#if UNITY_IOS
EventUtils.onEventPullSuccess(entity);
callback(true);
example.SetFSVideoAdForIOS(entity.codeGroup+entity.codeId, ad);
callback(entity);
example.SetFSVideoAdForIOS(entity.codeGroup + entity.slotName, ad);
#endif
}
......@@ -131,8 +131,8 @@ public class CSJFullScreenUtil : MonoBehaviour
{
#if UNITY_ANDROID
EventUtils.onEventPullSuccess(entity);
callback(true);
example.SetFSVideoAdForAndroid(entity.codeGroup + entity.codeId, ad);
callback(entity);
example.SetFSVideoAdForAndroid(entity.codeGroup + entity.slotName, ad);
#endif
}
......
......@@ -45,7 +45,7 @@ public class CSJRewardUtil
/// </summary>
/// <param name="entity"></param>
/// <param name="callback"></param>
public void LoadCacheRewardAd(AdEntity entity, Action<bool> callback)
public void LoadCacheRewardAd(AdEntity entity, Action<AdEntity> callback)
{
//string iosSlotID = "945113162";
......@@ -86,9 +86,9 @@ public class CSJRewardUtil
{
#if UNITY_ANDROID
RewardVideoAd rewardAd = GetRewardVideoAdForAndroid(entity.codeGroup+entity.codeId);
RewardVideoAd rewardAd = GetRewardVideoAdForAndroid(entity.codeGroup + entity.slotName);
#elif UNITY_IOS
ExpressRewardVideoAd rewardAd = GetRewardVideoAdForIOS(entity.codeGroup+entity.codeId);
ExpressRewardVideoAd rewardAd = GetRewardVideoAdForIOS(entity.codeGroup + entity.slotName);
#endif
if (rewardAd != null)
{
......@@ -109,9 +109,9 @@ public class CSJRewardUtil
{
private CSJRewardUtil csjAD;
private AdEntity entity;
private Action<bool> callback;
private Action<AdEntity> callback;
public RewardVideoAdListener(CSJRewardUtil example, AdEntity entity, Action<bool> callback)
public RewardVideoAdListener(CSJRewardUtil example, AdEntity entity, Action<AdEntity> callback)
{
this.csjAD = example;
this.entity = entity;
......@@ -122,8 +122,8 @@ public class CSJRewardUtil
{
EventUtils.onEventPullFail(entity, code.ToString(),message);
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.adPlatform + " 激励视频 Error Group" + entity.codeGroup + " Code " + code + " msg" + message);
callback(false);
}
callback(null);
}
public void OnRewardVideoAdLoad(RewardVideoAd ad)
{
......@@ -135,8 +135,8 @@ public class CSJRewardUtil
//this.csjAD.rewardAd = ad;
#if UNITY_ANDROID
EventUtils.onEventPullSuccess(entity);
this.csjAD.SetRewardVideoAdForAndroid(entity.codeGroup + entity.codeId, ad);
callback(true);
this.csjAD.SetRewardVideoAdForAndroid(entity.codeGroup + entity.slotName, ad);
callback(entity);
#endif
}
......@@ -144,7 +144,7 @@ public class CSJRewardUtil
{
#if UNITY_IOS
EventUtils.onEventPullSuccess(entity);
this.csjAD.SetRewardVideoAdForIOS(entity.codeGroup+entity.codeId, ad);
this.csjAD.SetRewardVideoAdForIOS(entity.codeGroup + entity.slotName, ad);
callback(true);
#endif
}
......@@ -197,7 +197,7 @@ public class CSJRewardUtil
public void OnAdClose()
{
Debug.Log("rewardVideoAd close");
listener.onAdClose();
listener.onAdClose(entity);
//this.cjsAd.rewardAd = null;
#if UNITY_IOS
......@@ -271,6 +271,8 @@ public class CSJRewardUtil
{
return mRewardQueue.Dequeue();
}
}
return null;
}
......@@ -318,6 +320,7 @@ public class CSJRewardUtil
{
return mRewardQueue.Dequeue();
}
}
return null;
}
......
......@@ -219,7 +219,7 @@ public class CSJSplshADUtils
public void OnAdSkip()
{
EventUtils.onEventAdComplete(entity);
listener.onAdSkip();
//listener.onAdSkip();
Debug.Log("splash Ad OnAdSkip");
DestorySplash();
}
......
......@@ -42,11 +42,10 @@ public class AdDemo : MonoBehaviour
this.demo = demo;
}
public void onAdClose()
public void onAdClose(AdEntity entity)
{
this.demo.RewardAdResult.text = "Reward onAdClose";
AdManager.Instance.LoadCacheRewardVideoAd("video");
//AdManager.Instance.LoadCacheRewardVideoAd("video");
//YLBRewardAdUtil.Instance.LoadYLBAd();
}
......@@ -114,6 +113,11 @@ public class AdDemo : MonoBehaviour
{
this.demo.RewardAdResult.text = "开屏错误" + errorMsg;
}
public void onLastError()
{
}
}
......
......@@ -3028,7 +3028,7 @@ PrefabInstance:
- target: {fileID: 2853166085728200634, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: IS_TEST
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2853166085728200635, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
......
......@@ -28,7 +28,7 @@ public class GDTFullScreenAdUtil
/// </summary>
/// <param name="entity"></param>
/// <param name="callback"></param>
public void LoadCacheFullScreeVideoAd(AdEntity entity, Action<bool> callback)
public void LoadCacheFullScreeVideoAd(AdEntity entity, Action<AdEntity> callback)
{
//string posId = Constants.intersititialFullScreenVideoPosId;//全屏视频测试ID
......@@ -68,22 +68,23 @@ public class GDTFullScreenAdUtil
private GDTFullScreenAdUtil example;
private UnifiedInterstitialAd ad;
private ZXADFullScreenVideoListener listener;
private Action<bool> callback;
private Action<AdEntity> loadcallback;
private Action<bool> showcallback;
private bool isSkipAd;
public UnifiedInterstitialAdListener(AdEntity entity,GDTFullScreenAdUtil example, UnifiedInterstitialAd ad, Action<bool> callback)
public UnifiedInterstitialAdListener(AdEntity entity,GDTFullScreenAdUtil example, UnifiedInterstitialAd ad, Action<AdEntity> loadcallback)
{
this.entity = entity;
this.example = example;
this.ad = ad;
this.callback = callback;
this.loadcallback = loadcallback;
}
public UnifiedInterstitialAdListener(AdEntity entity, ZXADFullScreenVideoListener listener, Action<bool> callback)
public UnifiedInterstitialAdListener(AdEntity entity, ZXADFullScreenVideoListener listener, Action<bool> showcallback)
{
isSkipAd = true;
this.entity = entity;
this.listener = listener;
this.callback = callback;
this.showcallback = showcallback;
}
/// <summary>
......@@ -94,8 +95,8 @@ public class GDTFullScreenAdUtil
EventUtils.onEventPullSuccess(entity);
if (ad != null)
{
callback(true);
example.SetFSVideoAd(entity.codeGroup+entity.codeId, ad);
loadcallback(entity);
}
}
......@@ -105,7 +106,11 @@ public class GDTFullScreenAdUtil
public void OnError(AdError error)
{
EventUtils.onEventPullFail(entity, error.GetErrorCode().ToString(), error.GetErrorMsg());
callback(false);
if (ad != null)
{
loadcallback(null);
}
showcallback(false);
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "GDT 全屏视频 Error " + error.GetErrorCode() + " meg " + error.GetErrorMsg());
}
......@@ -229,7 +234,7 @@ public class GDTFullScreenAdUtil
{
listener.onError("GDT 全屏视频播放失败");
}
callback(false);
showcallback(false);
}
/// <summary>
......
......@@ -26,11 +26,11 @@ public class GDTRewardAdUtil
/// </summary>
/// <param name="entity"></param>
/// <param name="callback"></param>
public void LoadCacheRewardAd(AdEntity entity, Action<bool> callback)
public void LoadCacheRewardAd(AdEntity entity, Action<AdEntity> callback)
{
RewardVideoAd rewardVideoAd = new RewardVideoAd(entity.codeId);
rewardVideoAd.SetListener(new RewardVideoAdListener(this, entity, rewardVideoAd, callback, true));
rewardVideoAd.SetVideoMuted(false);//设置声音
rewardVideoAd.SetVideoMuted(false);//设置静音声音
rewardVideoAd.LoadAd();
}
......@@ -42,7 +42,7 @@ public class GDTRewardAdUtil
/// <param name="callback"></param>
public void playCacheRewardAd(AdEntity entity, ZXADRewardVideoListener listener, Action<bool> callback)
{
RewardVideoAd rewardAd = GetRewardVideoAd(entity.codeGroup + entity.codeId);
RewardVideoAd rewardAd = GetRewardVideoAd(entity.codeGroup + entity.slotName);
if (rewardAd != null)
{
......@@ -50,7 +50,7 @@ public class GDTRewardAdUtil
#if UNITY_IOS
rewardAd.SetEnableDefaultAudioSessionSetting(false);
#endif
rewardAd.SetVideoMuted(false);//设置是否打开声音
rewardAd.SetVideoMuted(false);//设置静音声音
rewardAd.ShowAD();
}
else
......@@ -69,23 +69,24 @@ public class GDTRewardAdUtil
private GDTRewardAdUtil gdtAdUtils;
private AdEntity entity;
private RewardVideoAd rewardVideo;
private Action<bool> callback;
private Action<AdEntity> loadcallback;
private Action<bool> showcallback;
private ZXADRewardVideoListener listener;
public RewardVideoAdListener(GDTRewardAdUtil gdtAdUtils, AdEntity entity, RewardVideoAd reward, Action<bool> callback, bool isLoad)
public RewardVideoAdListener(GDTRewardAdUtil gdtAdUtils, AdEntity entity, RewardVideoAd reward, Action<AdEntity> loadcallback, bool isLoad)
{
this.isLoad = isLoad;
this.entity = entity;
this.gdtAdUtils = gdtAdUtils;
this.rewardVideo = reward;
this.callback = callback;
this.loadcallback = loadcallback;
}
public RewardVideoAdListener(ZXADRewardVideoListener listener, AdEntity entity, Action<bool> callback, bool isLoad)
public RewardVideoAdListener(ZXADRewardVideoListener listener, AdEntity entity, Action<bool> showcallback, bool isLoad)
{
this.isLoad = isLoad;
this.entity = entity;
this.listener = listener;
this.callback = callback;
this.showcallback = showcallback;
}
public void OnAdClicked()
......@@ -101,7 +102,7 @@ public class GDTRewardAdUtil
{
if (listener != null)
{
listener.onAdClose();
listener.onAdClose(entity);
}
}
......@@ -124,7 +125,7 @@ public class GDTRewardAdUtil
if (listener != null)
{
listener.onAdShow();
callback(true);
showcallback(true);
}
}
......@@ -133,16 +134,17 @@ public class GDTRewardAdUtil
if (isLoad)
{
EventUtils.onEventPullFail(entity, error.GetErrorCode().ToString(), error.GetErrorMsg());
loadcallback(null);
}
else
{
EventUtils.onEventShowFail(entity);
showcallback(false);
}
if (listener != null)
{
listener.onError("GDT RewardVideo ErrorCode" + error.GetErrorCode() + " Msg:" + error.GetErrorMsg());
}
callback(false);
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.adPlatform + " 激励视频 Error Group" + entity.codeGroup + " Code " + error.GetErrorCode() + " msg" + error.GetErrorMsg());
}
......@@ -156,8 +158,8 @@ public class GDTRewardAdUtil
if (isLoad)
{
EventUtils.onEventPullSuccess(entity);
this.gdtAdUtils.SetRewardVideoAd(entity.codeGroup + entity.codeId, this.rewardVideo);
callback(true);
this.gdtAdUtils.SetRewardVideoAd(entity.codeGroup + entity.slotName, this.rewardVideo);
loadcallback(entity);
}
}
......
......@@ -28,7 +28,7 @@ public class YLBRewardAdUtil
/// </summary>
/// <param name="entity"></param>
/// <param name="callback"></param>
public void LoadCacheRewardAd(AdEntity entity, Action<bool> callback)
public void LoadCacheRewardAd(AdEntity entity, Action<AdEntity> callback)
{
#if UNITY_ANDROID
YLBRewardAD rewardVideoAd = new YLBRewardAD();
......@@ -47,7 +47,7 @@ public class YLBRewardAdUtil
/// <param name="callback"></param>
public void playCacheRewardAd(AdEntity entity, ZXADRewardVideoListener listener, Action<bool> callback)
{
YLBRewardAD rewardVideoAd = GetRewardVideoAd(entity.codeGroup + entity.codeId);
YLBRewardAD rewardVideoAd = GetRewardVideoAd(entity.codeGroup + entity.slotName);
if (rewardVideoAd != null)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.codeGroup+"YLB Not NUll");
......@@ -71,8 +71,8 @@ public class YLBRewardAdUtil
private YLBRewardAdUtil adUtil;
private AdEntity entity;
private YLBRewardAD rewardVideo;
private Action<bool> callback;
public RewardVideoAdLoadListener(YLBRewardAdUtil adUtil,AdEntity entity, YLBRewardAD rewardVideo, Action<bool> callback)
private Action<AdEntity> callback;
public RewardVideoAdLoadListener(YLBRewardAdUtil adUtil,AdEntity entity, YLBRewardAD rewardVideo, Action<AdEntity> callback)
{
this.adUtil = adUtil;
this.entity = entity;
......@@ -84,14 +84,14 @@ public class YLBRewardAdUtil
{
Debug.unityLogger.Log(entity.codeGroup+" codeID " +entity.codeId+"YLB Error code" +code+"message"+message);
EventUtils.onEventPullFail(entity, code.ToString(),message);
callback(false);
callback(null);
}
public void onLoad()
{
EventUtils.onEventPullSuccess(entity);
adUtil.SetRewardVideoAd(entity.codeGroup + entity.codeId, this.rewardVideo);
callback(true);
adUtil.SetRewardVideoAd(entity.codeGroup + entity.slotName, this.rewardVideo);
callback(entity);
}
}
......@@ -115,7 +115,7 @@ public class YLBRewardAdUtil
public void onAdClose()
{
listener.onAdClose();
listener.onAdClose(entity);
}
public void onAdShow()
......
......@@ -9,8 +9,7 @@ namespace ZXHC
// Start is called before the first frame update
void Start()
{
ZXHCADManager.Init("1000127");
ZXHCUtils.SetDeviceOaid("1231wsd3242f");
ZXHCADManager.Init("1000127",true);
}
// Update is called once per frame
......@@ -64,6 +63,11 @@ namespace ZXHC
{
Debug.unityLogger.Log("开屏错误"+ errorMsg);
}
public void onLastError()
{
}
}
public void OnClickOaid()
......
......@@ -92,29 +92,29 @@ public class ZXHCFeedUtil
}
public void OnAdClicked()
{
//EventUtils.onEventAdClick(entity);
EventUtils.onEventAdClick(entity);
}
public void OnAdClosed()
{
//EventUtils.onEventAdComplete(entity);
EventUtils.onEventAdComplete(entity);
}
public void OnAdLoaded()
{
//EventUtils.onEventPullSuccess(entity);
EventUtils.onEventPullSuccess(entity);
feedAdCacheList.Enqueue(feedAd);
callback(true);
}
public void OnAdShow()
{
//EventUtils.onEventShowSuccess(entity);
EventUtils.onEventShowSuccess(entity);
}
public void OnError(string code, string error)
{
//EventUtils.onEventPullFail(entity, code, error);
EventUtils.onEventPullFail(entity, code, error);
callback(false);
}
}
......
......@@ -63,12 +63,12 @@ public class ZXHCSplashUtil
public void OnAdClicked()
{
//EventUtils.onEventAdClick(entity);
EventUtils.onEventAdClick(entity);
}
public void OnAdClosed()
{
//EventUtils.onEventAdComplete(entity);
EventUtils.onEventAdComplete(entity);
this.listener.onAdSkip();
}
......@@ -88,13 +88,13 @@ public class ZXHCSplashUtil
public void OnAdShow()
{
//EventUtils.onEventShowSuccess(entity);
EventUtils.onEventShowSuccess(entity);
this.listener.onAdShow();
}
public void OnError(string code, string error)
{
//EventUtils.onEventPullFail(entity, code, error);
EventUtils.onEventPullFail(entity, code, error);
this.listener.onError("ZXHC Splsh Error Code" + code + " Msg " + error);
callback(false);
}
......
......@@ -9,11 +9,11 @@ namespace ZXHC
public class ZXHCADManager
{
private static bool hasInit = false;
public static bool Init(string appId)
public static bool Init(string appId,bool IsDebug)
{
#if UNITY_ANDROID
AndroidJavaObject hcAdManager = new AndroidJavaClass("com.ym.zxhcsdk.manager.ZXHCADManager").CallStatic<AndroidJavaObject>("getInstance");
hasInit = hcAdManager.Call<bool>("InitAd",ZXHCUtils.GetActivity(),appId);
hasInit = hcAdManager.Call<bool>("InitAd",ZXHCUtils.GetActivity(),appId, IsDebug);
OaidUtil.GetOaid(new Action<string>((oaid) => {
ZXHCUtils.SetDeviceOaid(oaid);
}));
......
......@@ -118,6 +118,11 @@ public class Splash : MonoBehaviour
{
SceneManager.LoadSceneAsync("AdDemo");
}
public void onLastError()
{
}
}
......
......@@ -14,13 +14,13 @@ EditorBuildSettings:
- enabled: 0
path: Assets/AdSDK/SplashDemo/Splash.unity
guid: 37af8cf3fb373478ab04e3ee2f3b700a
- enabled: 0
- enabled: 1
path: Assets/AdSDK/AD/Demo/AdDemo.unity
guid: ef80a35d44f809e4a8957d1ed9571fd2
- enabled: 0
path: Assets/AdSDK/NetWork/Demo/HttpDemo.unity
guid: 1d254830c8b62484bb74d303cbb2cc3d
- enabled: 1
- enabled: 0
path: Assets/AdSDK/AD/ZXHC/ZXHCDemo/ZXHCDemo.unity
guid: cb50b98bfef171a4ea884c941dd43fa3
m_configObjects: {}
......@@ -175,7 +175,7 @@ PlayerSettings:
androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1
applicationIdentifier:
Android: com.ym.yzqj
Android: com.ym.awpdd
Lumin: com.DefaultCompany.com.unity.template.mobile2D
Standalone: com.DefaultCompany.com.unity.template.mobile2D
iPhone: com.DefaultCompany.com.unity.template.mobile2D
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment