1.设置各个广告平台的参数
平台参数以json的格式组织,样子如下。
{
"isTesting":true,//是否是测试模式
"rateModel":1,//广告平台排序规则,0表示priority是权重,各个平台按比例显示广告,1表示priority是顺序,各个平台按顺序展示广告
"platforms":[
{"class":"AdmobAdapter","priority":90,"key1":"ca-app-pub-xxx/xxx","key2":"ca-app-pub-xxx/xxx"},//admob 平台 ,key1 banner ID,key2全屏id
{"class":"AmazonAdapter","priority":20,"key1":"xxx"},//amazon 平台 ,key1 appkey
{"class":"ChartboostAdapter","priority":40,"key1":"xxx","key2":"xxx"},//chartboost 平台 ,key1 appID,key2 signature
{"class":"InmobiAdapter","priority":50,"key1":"xxx"},//inmobi 平台 ,key1 appid
{"class":"IadAdapter","priority":50,"key1":"877393773"},//iad 平台 ,android上会被自动忽略
{"class":"KeymobAdapter","priority":50,"key1":"appid"},//keymob.com 自售广告,交叉推广需要
{"class":"BaiduAdapter","priority":50,"key1":"appsid","key2":"appsec"},//baidu 平台
{"class":"GDTAdapter","priority":50,"key1":"appid","key2":"banner id","param":"full id"},//广点通 平台
{"class":"AdcolonyAdapter","priority":50,"key1":"appid","key2":"full id","param":"video id"},//adcolony 平台
{"class":"MMediaAdapter","priority":10,"key1":"xxx","key2":"xxx"}//mmedia 平台 ,key1 banner ID,key2全屏id
]
}
2.初始化KeyMob
初始化KeyMob管理库是调用其他广告功能函数的前提,必须先初始化才能做别的调用,下面是使用json配置文件的方式初始化KeyMob
KeyMob.initFromJSON(jsonString);
3.加载视频广告
KeyMob.loadVideo();
4.检查视频广告是否加载成功
KeyMob.isVideoReady(function (isReady) {
if (isReady) {
alert("Video is load success,you can show it now");
}
});
5.展示视频广告
KeyMob.showVideo();
6.flex显示视频广告
显示广告前先加载,加载完成了再显示,整体就是下面的样式
keymob.isVideoReady(function (isReady) {
if (isReady) {
keymob.showVideo();
}
});
KeyMob是一个专业的移动应用广告管理工具,支持百度广告,admob广告,广点通,mmedia,inmobi,chartboost,iad,adcolony视频广告等众多流行广告平台。