soyoo-cocos/networks/mraid_support.js

67 lines
2.0 KiB
JavaScript
Raw Normal View History

2024-12-05 21:14:41 +08:00
// 填入对应的商店地址
2025-01-13 16:18:28 +08:00
var iosUrl = "https://apps.apple.com/kr/app/id6467117398"
var androidUrl = "https://play.google.com/store/apps/details?id=com.mxdzzkr.google"
2024-12-05 21:14:41 +08:00
class SoyooLifecyle {
static Ready = 100 // 游戏初始化完成
static Start = 200 // 游戏正式开始
static Pause = 300 // 游戏暂停
static Resume = 400 // 游戏从暂停恢复
static Complete = 500 // 游戏结束, 全部完成
}
window.$soyooFacadeImpl = {
onLifecyleReport(lifecyle) {
switch(lifecyle) {
default:
console.log("[SoyooFacadeImpl] not handled: ", lifecyle)
}
},
onGameInstall() {
const gameUrl = /iphone|ipad|ipod|macintosh/i.test(
window.navigator.userAgent.toLowerCase()
)
? iosUrl
: androidUrl;
mraid.open(gameUrl)
console.log("[SoyooFacadeImpl] onGameInstall")
}
}
!(function () {
var n = !1,
e = !1;
function i() {
return mraid.isViewable() && "hidden" !== mraid.getState();
}
function a() {
n
? i() && e
? (window.resumeGame(), (e = !1))
: i() || e || (window.pauseGame(), (e = !0))
: i() && (window.startGame(), (n = !0));
}
function t() {}
function d(n) {
n ? window.unmuteAudio() : window.muteAudio()
}
var o = function () {
"undefined" != typeof mraid
? (mraid.removeEventListener("ready", o),
mraid.addEventListener("viewableChange", a),
mraid.addEventListener("stateChange", a),
mraid.addEventListener("orientationchange", t),
mraid.addEventListener("audioVolumeChange", d),
a())
: window.startGame();
};
window.addEventListener("DOMContentLoaded", function () {
"undefined" != typeof mraid
? "loading" === mraid.getState()
? mraid.addEventListener("ready", o)
: o()
: window.startGame();
});
})();