在基础库版本v3.1.1之后,分享系统提供了如下方式来录制:
// 录制配置,以下是默认值
// 这里建议根据实际情况,等比缩放`width`和`height`,防止丢帧
const options: XrFrame.IShareRecordOptions = {
fps: 30,
width: scene.width,
height: scene.height,
videoBitsPerSecond: 1000
};
// 启动录制
await scene.share.recordStart(options);
// 暂停录制
await scene.share.recordPause(options);
// 唤醒录制
await scene.share.recordResume(options);
// 停止录制,并保存到临时文件
const tempFilePath = await scene.share.recordFinishToTempFile(options);
// 停止录制,直接保存到相册
await scene.share.recordFinishToAlbum(options);
// 可以获取录制状态,来做用户提示
if (scene.share.recordState === xrFrameSystem.EShareRecordState.Recording) {
......
}