From 9e3e7c8f7ec2ac8ef553a5d317370616b592104b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E5=9F=B9=E6=97=AD?= <18530815565@163.com> Date: Tue, 14 May 2019 11:53:27 +0800 Subject: [PATCH 1/3] add TypeScript type definition --- index.d.ts | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 00000000..e1cf2419 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,47 @@ +export interface IRecordingOptions { + SampleRate?: number; + Channels?: number; + AudioQuality?: string; + AudioEncoding?: string; + OutputFormat?: string; + MeteringEnabled?: boolean; + MeasurementMode?: boolean; + AudioEncodingBitRate?: number; + IncludeBase64?: boolean; + AudioSource?: number; + } + + export var AudioRecorder: { + requestAuthorization(): Promise; + prepareRecordingAtPath(path: string, options: IRecordingOptions): Promise; + startRecording(): Promise; + stopRecording(): Promise; + resumeRecording(): Promise; + pauseRecording(): Promise; + checkAuthorizationStatus(): Promise; + onProgress(res: { currentTime: number; }): void; + onFinished(res: { audioFileURL: string; base64: string; status: string; }): void; + } + + export var AudioUtils: { + CachesDirectoryPath: string; + DocumentDirectoryPath: string; + DownloadsDirectoryPath: string; + LibraryDirectoryPath: string; + MainBundlePath: string; + MusicDirectoryPath: string; + PicturesDirectoryPath: string; + }; + export var AudioSource: { + CAMCORDER: number; + DEFAULT: number; + MIC: number; + REMOTE_SUBMIX: number; + UNPROCESSED: number; + VOICE_CALL: number; + VOICE_COMMUNICATION: number; + VOICE_DOWNLINK: number; + VOICE_RECOGNITION: number; + VOICE_UPLINK: number; + }; + \ No newline at end of file From a15130aa8a4e76ce7ecf27b3a2f13af6294ef9e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E5=9F=B9=E6=97=AD?= <18530815565@163.com> Date: Tue, 14 May 2019 14:17:12 +0800 Subject: [PATCH 2/3] update TypeScript type definition --- index.d.ts | 91 +++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/index.d.ts b/index.d.ts index e1cf2419..f1169f84 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,47 +1,46 @@ export interface IRecordingOptions { - SampleRate?: number; - Channels?: number; - AudioQuality?: string; - AudioEncoding?: string; - OutputFormat?: string; - MeteringEnabled?: boolean; - MeasurementMode?: boolean; - AudioEncodingBitRate?: number; - IncludeBase64?: boolean; - AudioSource?: number; - } - - export var AudioRecorder: { - requestAuthorization(): Promise; - prepareRecordingAtPath(path: string, options: IRecordingOptions): Promise; - startRecording(): Promise; - stopRecording(): Promise; - resumeRecording(): Promise; - pauseRecording(): Promise; - checkAuthorizationStatus(): Promise; - onProgress(res: { currentTime: number; }): void; - onFinished(res: { audioFileURL: string; base64: string; status: string; }): void; - } - - export var AudioUtils: { - CachesDirectoryPath: string; - DocumentDirectoryPath: string; - DownloadsDirectoryPath: string; - LibraryDirectoryPath: string; - MainBundlePath: string; - MusicDirectoryPath: string; - PicturesDirectoryPath: string; - }; - export var AudioSource: { - CAMCORDER: number; - DEFAULT: number; - MIC: number; - REMOTE_SUBMIX: number; - UNPROCESSED: number; - VOICE_CALL: number; - VOICE_COMMUNICATION: number; - VOICE_DOWNLINK: number; - VOICE_RECOGNITION: number; - VOICE_UPLINK: number; - }; - \ No newline at end of file + SampleRate?: number; + Channels?: number; + AudioQuality?: 'Low' | 'Medium' | 'High'; + AudioEncoding?: 'lpcm' | 'ima4' | 'aac' | 'MAC3' | 'MAC6' | 'ulaw' | 'alaw' | 'mp1' | 'mp2' | 'alac' | 'amr' | 'aac' | 'aac_eld' | 'amr_nb' | 'amr_wb' | 'he_aac' | 'vorbis'; + OutputFormat?: string; + MeteringEnabled?: boolean; + MeasurementMode?: boolean; + AudioEncodingBitRate?: number; + IncludeBase64?: boolean; + AudioSource?: number; +} + +export var AudioRecorder: { + requestAuthorization(): Promise; + prepareRecordingAtPath(path: string, options: IRecordingOptions): Promise; + startRecording(): Promise; + stopRecording(): Promise; + resumeRecording(): Promise; + pauseRecording(): Promise; + checkAuthorizationStatus(): Promise; + onProgress(res: { currentTime: number; }): void; + onFinished(res: { audioFileURL: string; base64: string; status: string; }): void; +} + +export var AudioUtils: { + CachesDirectoryPath: string; + DocumentDirectoryPath: string; + DownloadsDirectoryPath: string; + LibraryDirectoryPath: string; + MainBundlePath: string; + MusicDirectoryPath: string; + PicturesDirectoryPath: string; +}; +export var AudioSource: { + CAMCORDER: number; + DEFAULT: number; + MIC: number; + REMOTE_SUBMIX: number; + UNPROCESSED: number; + VOICE_CALL: number; + VOICE_COMMUNICATION: number; + VOICE_DOWNLINK: number; + VOICE_RECOGNITION: number; + VOICE_UPLINK: number; +}; From 135cf041537fbfac5197d2e7fc26ed9b08dfc8f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E5=9F=B9=E6=97=AD?= <18530815565@163.com> Date: Tue, 14 May 2019 14:45:51 +0800 Subject: [PATCH 3/3] update TypeScript type definition --- index.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index f1169f84..031044c1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,8 +1,14 @@ +export type AudioEncodingAndroidType = 'aac_eld' | 'amr_nb' | 'amr_wb' | 'he_aac' | 'vorbis'; + +export type AudioEncodingIOSType = 'lpcm' | 'ima4' | 'MAC3' | 'MAC6' | 'ulaw' | 'alaw' | 'mp1' | 'mp2' | 'alac' | 'amr'; + +export type AudioEncodingType = 'aac' | AudioEncodingAndroidType | AudioEncodingAndroidType; + export interface IRecordingOptions { SampleRate?: number; Channels?: number; AudioQuality?: 'Low' | 'Medium' | 'High'; - AudioEncoding?: 'lpcm' | 'ima4' | 'aac' | 'MAC3' | 'MAC6' | 'ulaw' | 'alaw' | 'mp1' | 'mp2' | 'alac' | 'amr' | 'aac' | 'aac_eld' | 'amr_nb' | 'amr_wb' | 'he_aac' | 'vorbis'; + AudioEncoding?: AudioEncodingType; OutputFormat?: string; MeteringEnabled?: boolean; MeasurementMode?: boolean;