198 lines
5.2 KiB
JavaScript
198 lines
5.2 KiB
JavaScript
function i(e, o) {
|
|
if (!(e instanceof o)) {
|
|
throw new TypeError("Cannot call a class as a function");
|
|
}
|
|
}
|
|
function n(e, o) {
|
|
for (var t = 0; t < o.length; t++) {
|
|
var i = o[t];
|
|
i.enumerable = i.enumerable || false;
|
|
i.configurable = true;
|
|
"value" in i && (i.writable = true);
|
|
Object.defineProperty(e, i.key, i);
|
|
}
|
|
}
|
|
function a(e, o, t) {
|
|
o && n(e.prototype, o);
|
|
t && n(e, t);
|
|
return e;
|
|
}
|
|
var c = function () {
|
|
function e() {
|
|
i(this, e);
|
|
this.video = null;
|
|
this.mediaRecorder = null;
|
|
this.appID = "ks661466196836111912";
|
|
this.chapingPos = "2300002040_02";
|
|
this.spVideo = "2300002040_01";
|
|
}
|
|
a(e, [{
|
|
key: "doInitialize",
|
|
value: function () {
|
|
console.log("快手初始化!!!!");
|
|
kwaigame.init({
|
|
appId: this.appID
|
|
});
|
|
this.createRecorder();
|
|
if (this.GaiLv(window.GameConfig.randomkaiping)) {
|
|
console.log("快手开屏====");
|
|
this.executeShowAwardVideo(null, null);
|
|
}
|
|
}
|
|
}, {
|
|
key: "GaiLv",
|
|
value: function (e) {
|
|
return 1 + Math.floor(100 * Math.random()) <= e;
|
|
}
|
|
}, {
|
|
key: "executeShowAwardVideo",
|
|
value: function (e, o) {
|
|
var t = this;
|
|
this.successCallBack = e;
|
|
this.failureCallBack = o;
|
|
var i = {};
|
|
i.adUnitId = this.spVideo;
|
|
var n = kwaigame.createRewardedVideoAd(i);
|
|
if (n) {
|
|
console.log("激励广告组件获取成功");
|
|
n.show({
|
|
success: function () {
|
|
console.log("激励视频播放成功");
|
|
},
|
|
fail: function (e) {
|
|
t.executeFailureHandle();
|
|
console.log("激励视频播放失败: " + JSON.stringify(e));
|
|
}
|
|
});
|
|
n.onClose(function (e) {
|
|
console.log("激励视频关闭回调: " + JSON.stringify(e));
|
|
t.executeFailureHandle();
|
|
});
|
|
n.onReward(function (e) {
|
|
console.log("激励视频奖励回调: " + JSON.stringify(e));
|
|
t.executeSuccessHandle();
|
|
});
|
|
} else {
|
|
this.executeFailureHandle();
|
|
console.log("激励广告组件获取失败");
|
|
}
|
|
}
|
|
}, {
|
|
key: "executeSuccessHandle",
|
|
value: function () {
|
|
cc.audioEngine.resumeAll();
|
|
cc.director.resume();
|
|
this.successCallBack && this.successCallBack();
|
|
this.successCallBack = null;
|
|
}
|
|
}, {
|
|
key: "executeFailureHandle",
|
|
value: function () {
|
|
cc.audioEngine.resumeAll();
|
|
cc.director.resume();
|
|
this.failureCallBack && this.failureCallBack();
|
|
this.failureCallBack = null;
|
|
}
|
|
}, {
|
|
key: "createRecorder",
|
|
value: function () {
|
|
this.mediaRecorder = kwaigame.createMediaRecorder();
|
|
if (null !== this.mediaRecorder) {
|
|
var e = this;
|
|
this.mediaRecorder.onStart(function () {
|
|
console.log("录频开始成功");
|
|
});
|
|
this.mediaRecorder.onStop(function (o) {
|
|
if (o && o.videoID) {
|
|
e.video = o.videoID;
|
|
window.KSshareCall(2);
|
|
console.log("录屏停止,录制成功");
|
|
} else {
|
|
window.KSshareCall(1);
|
|
console.log("录屏停止,录制失败");
|
|
}
|
|
});
|
|
this.mediaRecorder.onError(function (e) {
|
|
console.log("录频过程中发生错误 ".concat(JSON.stringify(e), " "));
|
|
});
|
|
} else {
|
|
console.log("当前 APP 版本不支持录屏");
|
|
}
|
|
}
|
|
}, {
|
|
key: "executeRecorder",
|
|
value: function () {
|
|
console.log("录屏开始========");
|
|
this.mediaRecorder && this.mediaRecorder.start();
|
|
}
|
|
}, {
|
|
key: "stopRecorder",
|
|
value: function () {
|
|
console.log("录屏结束========");
|
|
this.mediaRecorder && this.mediaRecorder.stop();
|
|
}
|
|
}, {
|
|
key: "executeShareRecorder",
|
|
value: function () {
|
|
console.log("录屏分享========");
|
|
if (this.mediaRecorder) {
|
|
if (null === this.video) {
|
|
return;
|
|
}
|
|
this.mediaRecorder.publishVideo({
|
|
video: this.video,
|
|
callback: function (e) {
|
|
if (e) {
|
|
console.log("发布录屏失败: ".concat(JSON.stringify(e)));
|
|
} else {
|
|
window.KSshareCall(1);
|
|
console.log("发布录屏成功");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}, {
|
|
key: "executeShowBanner1",
|
|
value: function () {
|
|
this.executeJieSuanChaPing();
|
|
}
|
|
}, {
|
|
key: "executeJieSuanChaPing",
|
|
value: function () {
|
|
console.log("快手插屏");
|
|
var e = ks.createInterstitialAd({
|
|
adUnitId: this.chapingPos
|
|
});
|
|
e.show().then(function () {
|
|
return console.log("插屏\xA0广告显示");
|
|
});
|
|
e.onClose(function (e) {});
|
|
e.onError(function (e) {
|
|
console.log(e);
|
|
});
|
|
}
|
|
}, {
|
|
key: "Suijivideo",
|
|
value: function () {
|
|
this.GaiLv(GameConfig.randomShowvideo) && this.executeShowAwardVideo(null, null);
|
|
}
|
|
}, {
|
|
key: "executeHideBanner",
|
|
value: function () {}
|
|
}, {
|
|
key: "executeShowPushBox",
|
|
value: function () {}
|
|
}, {
|
|
key: "isInstalledShortcut",
|
|
value: function () {}
|
|
}, {
|
|
key: "sendDesktopShortcut",
|
|
value: function (e) {}
|
|
}, {
|
|
key: "executeBlockAdShow",
|
|
value: function (e, o) {}
|
|
}]);
|
|
return e;
|
|
}();
|
|
module.exports = c; |