Files
tra-app/src/uni_modules/ty-recording/utssdk/interface.uts
T

62 lines
2.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* interface.uts
* uts插件接口定义文件,按规范定义接口文件可以在HBuilderX中更好的做到语法提示
*/
// 成功开启录音的回调参数:返回录音基础配置
export type AudioStartRes = {
recordId : string; // 录音唯一标识(方便多录音实例管理)
sampleRate ?: number; // 采样率(如16000
startTime : number; // 开启时间戳(毫秒)
};
// 录音结束并返回文件的回调参数:核心是录音文件信息
export type AudioFileRes = {
filePath : string; // 录音文件本地路径(UTS/Uniapp 通用路径)
fileSize : number; // 文件大小(字节)
duration : number; // 录音时长(秒)
format : string; // 文件格式(如pcm/mp3
endTime : number; // 结束时间戳(毫秒)
};
/**
* 错误码
* 根据uni错误码规范要求,建议错误码以90开头,以下是错误码示例:
* - 9010001 错误信息1
* - 9010002 错误信息2
*/
export type AudioErrorCode = 9010001 | 9010002;
/**
* 录音错误的回调参数:带错误码+错误信息,方便问题定位
*/
export interface AudioErrorRes extends IUniError {
errCode : number
};
/**
* 开启录音的完整参数配置
* 所有回调职责边界清晰,无模糊命名
*/
export type StartAudioRecordOptions = {
autoStopDuration ?: number; // 自动关闭时长,单位【秒】;传正数值则超过该时间自动关闭,不传/非正数不开启
// 【实时持续回调】- 录制过程中高频触发
onFrame ?: (frameData : any) => void; // 实时音频帧回调(每帧一次)
onVolume ?: (volume : number) => void; // 实时音量回调(如每秒5次,按设备采集频率)
// 【一次性状态回调】- 特定节点仅触发一次
onStart ?: (res: AudioStartRes) => void; // 成功开启录音的回调(仅触发1次)
onError ?: (res : AudioErrorRes) => void; // 录音错误回调(任意阶段出错都触发,仅1次)
onStop ?: () => void; // 录音结束的纯状态回调(仅通知结束,无返回,1次)
onFile ?: (res : AudioFileRes) => void; // 录音结束后,返回录音文件的回调(1次,核心)
};
/* 函数定义 */
export type StartAudioRecord = (options : StartAudioRecordOptions) => void