头条录屏相关功能"/>
头条录屏相关功能
头条录屏相关功能
//=============================================================================================//=============================================================================================//初始化录屏功能iniTape() {//录屏的保存路径this.tapePath = null;this.tapeStartTime = 0;this.tapeMaxTime = 90;this.recorder = tt.getGameRecorderManager();},//手动触发录屏onTapeButtonClick() {//开始后大于3秒才能关闭let nowTime = new Date().getTime();let tapeTime = nowTime - this.tapeStartTime;if (tapeTime < 3000) {cc.log("录屏时间小于3秒");} else {this.stopTape();};},//录屏时间控制tapeTimeControl() {let timeCount = 0;let callback = function () {timeCount++;//超过了最大时长或者录制状态为未开启if (timeCount >= this.tapeMaxTime) {this.unschedule(callback);timeCount = 0;this.stopTape();};};this.schedule(callback, 1);},//开始游戏录屏startTape() {//记录一个时间戳this.tapeStartTime = new Date().getTime();if (typeof (tt) != "undefined") {this.recorder.onStart(res => {console.log("录屏开始");this.tapeTimeControl();});this.recorder.start({duration: this.tapeMaxTime,});};},//结束游戏录屏stopTape() {if (typeof (tt) != "undefined") {this.recorder.onStop(res => {console.log(res.videoPath, "录屏结束");// do something;this.tapePath = res.videoPath;});this.recorder.stop();};},//录屏分享tapeShare() {if (typeof (tt) !== "undefined") {if (this.game_rules_js.tapePath == null) {return;};//获取分享导语tt.shareAppMessage({channel: 'video', //指定为视频分享title: '标题',extra: {videoPath: this.game_rules_js.tapePath,// 设置视频路径videoTopics: ["话题1", "话题2"]},success: () => {//分享回调console.log('录屏分享成功');//分享奖励,仅一次this.tapeShareSucces();},fail: () => {console.log('录屏分享失败', this.tapePath);this.tapeShareFail();}});};},//录屏分享成功tapeShareSucces: function () {//do something},//录屏分享失败tapeShareFail: function () {//do something;},//=============================================================================================//=============================================================================================
更多推荐
头条录屏相关功能
发布评论