有大佬分享下头条录屏的代码参考下嘛

有大佬分享下头条录屏的代码,学习下嘛,万分感谢啦

private recorder;

/** 录屏开始 */

startRecord(fn: Function = null) {

    this.recorder = tt.getGameRecorderManager();

    this.recorder.onStart((s) => {

        if (fn)

            fn();

        console.log("ttManager录屏开始:", s);

    })

    this.recorder.onError((s) => {

        console.log("录屏错误:", s);

    })

    //添加水印并且居中处理

    this.recorder.start({

        duration: 300,

        isMarkOpen: false,

        locLeft: 0,

        locTop: 0,

    });

    this.recorder.onStop((s) => {

        // console.log("录屏结束:", s);

        // s.videoPath;

        if (!this.isShare)

            return;

        tt.shareAppMessage({

            channel: "video",

            title: "XXXX",

            desc: "XXXX",

            imageUrl: "",

            templateId: "", // 替换成通过审核的分享ID

            query: "",

            extra: {

                videoPath: s.videoPath, // 录屏得到的视频地址

                videoTopics: ["XXX", "XXXX"], //该字段已经被hashtag_list代替,为保证兼容性,建议两个都填写。

                hashtag_list: ["XXXX", "XXXX"],

                video_title: "XXXX", //生成的默认内容

            },

            success() {

                //  console.log("分享视频成功");

                cc.director.emit(GameEvents.SHARE_COMPLETE, true);

            },

            fail(e) {

                //  console.log("分享视频失败", e);

                cc.director.emit(GameEvents.SHARE_COMPLETE, false);

                tt.showToast({

                    title: "分享取消",

                    duration: 2000,

                });

            },

        });

    })

}

/** 录屏结束 */

private static isShare: boolean;
endRecord(isShare: boolean = true) {
this.isShare = isShare;
if (!this.recorder)
return;

    this.recorder.stop();
}
1赞

谢谢老哥.

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。