GameRecorderManager.recordClip
基础库版本 1.6.1 开始支持。
记录精彩的视频片段,调用时必须是正在录屏,以调用时的录屏时刻为基准,指定前 x 秒,后 y 秒为将要裁剪的片段,可以多次调用,记录不同时刻。在结束录屏时,可以调用 clipVideo 接口剪辑并合成记录的片段。
语法
GameRecorderManager.recordClip(options)
参数说明
options
为 object 类型,属性如下:
属性名 | 类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
---|---|---|---|---|---|
timeRange | Array | [3, 3] | 否 | 数组的值表示记录这一时刻的前后时间段内的视频,单位是 s | 1.6.1 |
success | function | 否 | 接口调用成功的回调函数 | 1.20.0 | |
fail | function | 否 | 接口调用失败的回调函数 | 1.20.0 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | 1.20.0 |
回调成功
object 类型,属性如下:
属性 | 类型 | 说明 | 最低支持版本 |
---|---|---|---|
index | number | 裁剪片段的唯一索引,用于 tt.clipVideo 接口调用时指定裁剪拼接顺序。 | 1.20.0 |
代码示例
const recorder = tt.getGameRecorderManager();
const clipIndexList = []; // 剪辑索引列表
recorder.start({
duration: 30,
});
recorder.onStop((res) => {
recorder.clipVideo({
path: res.videoPath,
success(r) {
console.log(r.videoPath);
},
});
});
// 假设录制第15秒时,执行第一次 recordClip
recorder.recordClip({
timeRange: [5, 3],
success(r) {
console.log(r.index); // 裁剪唯一索引
clipIndexList.push(r.index);
},
});
// 录制到第20秒时,再次执行recordClip
recorder.recordClip({
timeRange: [3, 5],
success(r) {
console.log(r.index); // 裁剪唯一索引
clipIndexList.push(r.index);
},
});
以上示例代码最终得到的录屏文件将是一段包含了第 10 秒到第 25 秒内容的视频。
点击纠错
该文档是否对你的开发有所帮助?
有帮助
没帮助
该文档是否对你的开发有所帮助?
有帮助
没帮助