@react-native-ohos/react-native-audio-recorder-player 3.6.14-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +14 -0
  4. package/RNAudioRecorderPlayer.podspec +21 -0
  5. package/harmony/audio_recorder_player/BuildProfile.ets +17 -0
  6. package/harmony/audio_recorder_player/LICENSE +21 -0
  7. package/harmony/audio_recorder_player/build-profile.json5 +28 -0
  8. package/harmony/audio_recorder_player/hvigorfile.ts +1 -0
  9. package/harmony/audio_recorder_player/index.ets +25 -0
  10. package/harmony/audio_recorder_player/oh-package-lock.json5 +18 -0
  11. package/harmony/audio_recorder_player/oh-package.json5 +20 -0
  12. package/harmony/audio_recorder_player/src/main/cpp/CMakeLists.txt +7 -0
  13. package/harmony/audio_recorder_player/src/main/cpp/RNAudioRecorderPlayerPackage.h +48 -0
  14. package/harmony/audio_recorder_player/src/main/cpp/RNAudioRecorderPlayerTurboModule.cpp +91 -0
  15. package/harmony/audio_recorder_player/src/main/cpp/RNAudioRecorderPlayerTurboModule.h +36 -0
  16. package/harmony/audio_recorder_player/src/main/ets/RNAudioRecorderPlayerPackage.ts +47 -0
  17. package/harmony/audio_recorder_player/src/main/ets/RNAudioRecorderPlayerTurboModule.ts +315 -0
  18. package/harmony/audio_recorder_player/src/main/ets/audioPlayer/AudioPlayer.ts +464 -0
  19. package/harmony/audio_recorder_player/src/main/ets/audioPlayer/types.ts +45 -0
  20. package/harmony/audio_recorder_player/src/main/ets/index.d.ts +209 -0
  21. package/harmony/audio_recorder_player/src/main/ets/recorder/Recorder.ts +299 -0
  22. package/harmony/audio_recorder_player/src/main/ets/recorder/types.ts +61 -0
  23. package/harmony/audio_recorder_player/src/main/ets/utils/DateTimeUtils.ts +88 -0
  24. package/harmony/audio_recorder_player/src/main/ets/utils/Logger.ts +45 -0
  25. package/harmony/audio_recorder_player/src/main/ets/utils/SaveAudioAsset.ts +105 -0
  26. package/harmony/audio_recorder_player/src/main/module.json5 +9 -0
  27. package/harmony/audio_recorder_player/src/main/resources/base/element/string.json +8 -0
  28. package/harmony/audio_recorder_player/src/main/resources/base/media/ic_public_error.svg +10 -0
  29. package/harmony/audio_recorder_player/src/main/resources/en_US/element/string.json +8 -0
  30. package/harmony/audio_recorder_player/src/main/resources/zh_CN/element/string.json +8 -0
  31. package/harmony/audio_recorder_player/ts.ts +27 -0
  32. package/harmony/audio_recorder_player.har +0 -0
  33. package/index.d.ts +226 -0
  34. package/index.ts +538 -0
  35. package/package.json +59 -0
  36. package/src/NativeAudioRecorderPlayerModule.ts +43 -0
package/index.d.ts ADDED
@@ -0,0 +1,226 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ export enum AudioSourceHarmonyType {
26
+ DEFAULT = 0,
27
+ MIC,
28
+ VOICE_RECOGNITION,
29
+ VOICE_COMMUNICATION = 7,
30
+ VOICE_MESSAGE = 10,
31
+ CAMCORDER = 12,
32
+ }
33
+
34
+ export enum AudioFormatHarmonyType {
35
+ MPEG_4 = 'mp4',
36
+ MPEG_4A = 'm4a',
37
+ MP3 = 'mp3',
38
+ WAV = 'wav'
39
+ }
40
+
41
+ export enum AudioMimeHarmonyType {
42
+ AUDIO_AAC = 'audio/mp4a-latm', // 表示音频/mp4a-latm类型。
43
+
44
+ AUDIO_VORBIS = 'audio/vorbis', // 表示音频/vorbis类型。
45
+ AUDIO_FLAC = 'audio/flac', // 表示音频/flac类型。
46
+ AUDIO_MP3 = 'audio/mpeg', // 表示音频/mpeg类型。
47
+ AUDIO_G711MU = 'audio/g711mu', // 表示音频/G711-mulaw类型。
48
+ }
49
+
50
+ export enum AudioSourceAndroidType {
51
+ DEFAULT = 0,
52
+ MIC,
53
+ }
54
+
55
+ export enum OutputFormatAndroidType {
56
+ DEFAULT = 0,
57
+ THREE_GPP,
58
+ MPEG_4,
59
+ AMR_NB,
60
+ AMR_WB,
61
+ AAC_ADIF,
62
+ AAC_ADTS,
63
+ OUTPUT_FORMAT_RTP_AVP,
64
+ MPEG_2_TS,
65
+ WEBM,
66
+ UNUSED,
67
+ OGG,
68
+ }
69
+
70
+ export enum AudioEncoderAndroidType {
71
+ DEFAULT = 0,
72
+ AMR_NB,
73
+ AMR_WB,
74
+ AAC,
75
+ HE_AAC,
76
+ AAC_ELD,
77
+ VORBIS,
78
+ OPUS,
79
+ }
80
+
81
+ export enum AVEncodingOption {
82
+ lpcm = 'lpcm',
83
+ ima4 = 'ima4',
84
+ aac = 'aac',
85
+ MAC3 = 'MAC3',
86
+ MAC6 = 'MAC6',
87
+ ulaw = 'ulaw',
88
+ alaw = 'alaw',
89
+ mp1 = 'mp1',
90
+ mp2 = 'mp2',
91
+ mp4 = 'mp4',
92
+ alac = 'alac',
93
+ amr = 'amr',
94
+ flac = 'flac',
95
+ opus = 'opus',
96
+ wav = 'wav',
97
+ }
98
+
99
+ export type AVEncodingType =
100
+ | AVEncodingOption.lpcm
101
+ | AVEncodingOption.ima4
102
+ | AVEncodingOption.aac
103
+ | AVEncodingOption.MAC3
104
+ | AVEncodingOption.MAC6
105
+ | AVEncodingOption.ulaw
106
+ | AVEncodingOption.alaw
107
+ | AVEncodingOption.mp1
108
+ | AVEncodingOption.mp2
109
+ | AVEncodingOption.mp4
110
+ | AVEncodingOption.alac
111
+ | AVEncodingOption.amr
112
+ | AVEncodingOption.flac
113
+ | AVEncodingOption.opus
114
+ | AVEncodingOption.wav;
115
+
116
+ export enum AVModeIOSOption {
117
+ gamechat = 'gamechat',
118
+ measurement = 'measurement',
119
+ movieplayback = 'movieplayback',
120
+ spokenaudio = 'spokenaudio',
121
+ videochat = 'videochat',
122
+ videorecording = 'videorecording',
123
+ voicechat = 'voicechat',
124
+ voiceprompt = 'voiceprompt',
125
+ }
126
+
127
+ export type AVModeIOSType =
128
+ | AVModeIOSOption.gamechat
129
+ | AVModeIOSOption.measurement
130
+ | AVModeIOSOption.movieplayback
131
+ | AVModeIOSOption.spokenaudio
132
+ | AVModeIOSOption.videochat
133
+ | AVModeIOSOption.videorecording
134
+ | AVModeIOSOption.voicechat
135
+ | AVModeIOSOption.voiceprompt;
136
+
137
+ export enum AVEncoderAudioQualityIOSType {
138
+ min = 0,
139
+ low = 32,
140
+ medium = 64,
141
+ high = 96,
142
+ max = 127,
143
+ }
144
+
145
+ export enum AVLinearPCMBitDepthKeyIOSType {
146
+ 'bit8' = 8,
147
+ 'bit16' = 16,
148
+ 'bit24' = 24,
149
+ 'bit32' = 32,
150
+ }
151
+
152
+ export interface AudioSet {
153
+ AVSampleRateKeyIOS?: number;
154
+ AVFormatIDKeyIOS?: AVEncodingType;
155
+ AVModeIOS?: AVModeIOSType;
156
+ AVNumberOfChannelsKeyIOS?: number;
157
+ AVEncoderAudioQualityKeyIOS?: AVEncoderAudioQualityIOSType;
158
+ AVLinearPCMBitDepthKeyIOS?: AVLinearPCMBitDepthKeyIOSType;
159
+ AVLinearPCMIsBigEndianKeyIOS?: boolean;
160
+ AVLinearPCMIsFloatKeyIOS?: boolean;
161
+ AVLinearPCMIsNonInterleavedIOS?: boolean;
162
+ AVEncoderBitRateKeyIOS?: number;
163
+ OutputFormatAndroid?: OutputFormatAndroidType;
164
+ AudioEncoderAndroid?: AudioEncoderAndroidType;
165
+ AudioEncodingBitRateAndroid?: number;
166
+ AudioSamplingRateAndroid?: number;
167
+ AudioChannelsAndroid?: number;
168
+ AudioSourceAndroid?: AudioSourceAndroidType;
169
+ AudioSourceHarmony?: AudioSourceHarmonyType;
170
+ AudioMimeHarmony?: AudioMimeHarmonyType;
171
+ AudioFileFormatHarmony?: AudioFormatHarmonyType;
172
+ /**
173
+ * 音频编码比特率,选择音频录制时必填。
174
+
175
+ 支持范围:
176
+
177
+ - AAC编码格式支持比特率范围[32000 - 500000]。
178
+
179
+ - G711-mulaw编码格式支持比特率范围[64000 - 64000]。
180
+
181
+ - MP3编码格式支持范围[8000, 16000, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000]。
182
+
183
+ 当使用MP3编码格式时,采样率和比特率的映射关系:
184
+
185
+ - 采样率使用16K以下时,对应比特率范围为[8kbps - 64kbps]。
186
+
187
+ - 采样率使用16K~32K时对应的比特率范围为[8kbps - 160kbps]。
188
+
189
+ - 采样率使用32K以上时对应的比特率范围为[32kbps - 320kbps]。
190
+ */
191
+ AudioEncodingBitRateHarmony?: number;
192
+ /**
193
+ * 支持范围:
194
+
195
+ - AAC编码支持采样率范围[8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000]。
196
+
197
+ - G711-mulaw编码支持采样率范围[8000 - 8000]。
198
+
199
+ - MP3编码支持采样率范围[8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000]。
200
+ */
201
+ AudioSamplingRateHarmony?: number;
202
+ /**
203
+ * 音频采集声道数
204
+
205
+ - AAC编码格式支持范围[1 - 8]。
206
+
207
+ - G711-mulaw编码格式支持范围[1 - 1]。
208
+
209
+ - MP3编码格式支持范围[1 - 2]
210
+ */
211
+ AudioChannelsHarmony?: number;
212
+ }
213
+
214
+ export type RecordBackType = {
215
+ isRecording?: boolean;
216
+ currentPosition: number;
217
+ currentMetering?: number;
218
+ };
219
+
220
+ export type PlayBackType = {
221
+ isMuted?: boolean;
222
+ currentPosition: number;
223
+ duration: number;
224
+ isFinished: boolean;
225
+ };
226
+