@react-native-ohos/react-native-audio-recorder-player 3.7.1-beta.1 → 3.7.2

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 (34) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +20 -20
  3. package/README.OpenSource +10 -10
  4. package/README.md +899 -753
  5. package/harmony/audio_recorder_player/BuildProfile.ets +16 -16
  6. package/harmony/audio_recorder_player/LICENSE +21 -21
  7. package/harmony/audio_recorder_player/build-profile.json5 +28 -28
  8. package/harmony/audio_recorder_player/index.ets +27 -25
  9. package/harmony/audio_recorder_player/oh-package-lock.json5 +18 -0
  10. package/harmony/audio_recorder_player/oh-package.json5 +20 -20
  11. package/harmony/audio_recorder_player/src/main/cpp/CMakeLists.txt +7 -7
  12. package/harmony/audio_recorder_player/src/main/cpp/RNAudioRecorderPlayerPackage.h +48 -48
  13. package/harmony/audio_recorder_player/src/main/cpp/RNAudioRecorderPlayerTurboModule.cpp +90 -90
  14. package/harmony/audio_recorder_player/src/main/cpp/RNAudioRecorderPlayerTurboModule.h +35 -35
  15. package/harmony/audio_recorder_player/src/main/ets/{RNAudioRecorderPlayerPackage.ts → RNAudioRecorderPlayerPackage.ets} +48 -47
  16. package/harmony/audio_recorder_player/src/main/ets/RNAudioRecorderPlayerTurboModule.ts +330 -323
  17. package/harmony/audio_recorder_player/src/main/ets/audioPlayer/AudioPlayer.ts +469 -464
  18. package/harmony/audio_recorder_player/src/main/ets/audioPlayer/types.ts +45 -45
  19. package/harmony/audio_recorder_player/src/main/ets/index.ts +209 -209
  20. package/harmony/audio_recorder_player/src/main/ets/recorder/Recorder.ts +305 -299
  21. package/harmony/audio_recorder_player/src/main/ets/recorder/types.ts +61 -61
  22. package/harmony/audio_recorder_player/src/main/ets/utils/DateTimeUtils.ts +88 -88
  23. package/harmony/audio_recorder_player/src/main/ets/utils/Logger.ts +45 -45
  24. package/harmony/audio_recorder_player/src/main/ets/utils/SaveAudioAsset.ts +101 -105
  25. package/harmony/audio_recorder_player/src/main/module.json5 +9 -9
  26. package/harmony/audio_recorder_player/src/main/resources/base/element/string.json +8 -8
  27. package/harmony/audio_recorder_player/src/main/resources/base/media/ic_public_error.svg +9 -9
  28. package/harmony/audio_recorder_player/src/main/resources/en_US/element/string.json +8 -8
  29. package/harmony/audio_recorder_player/src/main/resources/zh_CN/element/string.json +8 -8
  30. package/harmony/audio_recorder_player/{ts.ts → ts.ets} +26 -26
  31. package/harmony/audio_recorder_player.har +0 -0
  32. package/index.ts +539 -539
  33. package/package.json +77 -60
  34. package/src/NativeAudioRecorderPlayerModule.ts +42 -42
package/README.md CHANGED
@@ -1,753 +1,899 @@
1
- > 模板版本:v0.2.2
2
-
3
- <p align="center">
4
- <h1 align="center"> <code>react-native-audio-recorder-player</code> </h1>
5
- </p>
6
- <p align="center">
7
- <a href="https://github.com/hyochan/react-native-audio-recorder-player">
8
- <img src="https://img.shields.io/badge/platforms-android%20|%20ios%20|%20harmony%20-lightgrey.svg" alt="Supported platforms" />
9
- </a>
10
- <a href="https://github.com/hyochan/react-native-audio-recorder-player/blob/main/LICENSE">
11
- <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License" />
12
- </a>
13
- </p>
14
-
15
- > [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-audio-recorder-player)
16
-
17
- ## 安装与使用
18
-
19
- 请到三方库的 Releases 发布地址查看配套的版本信息:
20
-
21
- | 三方库版本 | 发布信息 | 支持RN版本 |
22
- | ---------- | ------------------------------------------------------------ | ---------- |
23
- | <= 3.6.10-0.0.2@deprecated | [@react-native-oh-tpl/react-native-audio-recorder-player Releases(deprecated)](https://github.com/react-native-oh-library/react-native-audio-recorder-player/releases) | 0.72 |
24
- | 3.6.11 | [@react-native-ohos/react-native-audio-recorder-player Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-audio-recorder-player/releases) | 0.72 |
25
- | 3.7.0 | [@react-native-ohos/react-native-audio-recorder-player Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-audio-recorder-player/releases) | 0.77 |
26
-
27
- 对于未发布到npm的旧版本,请参考[安装指南](/tgz-usage.md)安装tgz包。
28
-
29
- 进入到工程目录并输入以下命令:
30
-
31
- #### **npm**
32
-
33
- ```bash
34
- npm install @react-native-ohos/react-native-audio-recorder-player
35
- ```
36
-
37
- #### **yarn**
38
-
39
- ```bash
40
- yarn add @react-native-ohos/react-native-audio-recorder-player
41
- ```
42
-
43
- 下面的代码展示了这个库的基本使用场景:
44
-
45
- > [!WARNING] 使用时 import 的库名不变。
46
-
47
- ```js
48
- import AudioRecorderPlayer, {
49
- AVEncoderAudioQualityIOSType,
50
- AVEncodingOption,
51
- AudioEncoderAndroidType,
52
- AudioSourceAndroidType,
53
- OutputFormatAndroidType,
54
- AudioMimeHarmonyType,
55
- AudioFormatHarmonyType,
56
- AudioSourceHarmonyType,
57
- AudioSet
58
- } from 'react-native-audio-recorder-player'; import type {
59
- PlayBackType,
60
- RecordBackType,
61
- } from 'react-native-audio-recorder-player';
62
-
63
- import {
64
- Dimensions,
65
- Platform,
66
- ActivityIndicator,
67
- Image,
68
- SafeAreaView,
69
- StyleSheet,
70
- Text,
71
- TouchableOpacity,
72
- View,
73
- } from 'react-native';
74
- import React, { Component } from 'react';
75
-
76
- import type { ReactElement, ReactNode } from 'react';
77
-
78
- const stylesButton: any = StyleSheet.create({
79
- btn: {
80
- backgroundColor: 'transparent',
81
- alignSelf: 'center',
82
- borderRadius: 4,
83
- borderWidth: 2,
84
- width: 320,
85
- height: 52,
86
- borderColor: 'white',
87
-
88
- alignItems: 'center',
89
- justifyContent: 'center',
90
- },
91
- btnDisabled: {
92
- backgroundColor: 'rgb(243,243,243)',
93
- alignSelf: 'center',
94
- borderRadius: 4,
95
- borderWidth: 2,
96
- width: 320,
97
- height: 52,
98
- borderColor: '#333',
99
-
100
- alignItems: 'center',
101
- justifyContent: 'center',
102
- },
103
- txt: {
104
- fontSize: 14,
105
- color: 'white',
106
- },
107
- imgLeft: {
108
- width: 24,
109
- height: 24,
110
- position: 'absolute',
111
- left: 16,
112
- },
113
- });
114
-
115
- interface ItemProps {
116
- children?: ReactNode;
117
- isLoading?: boolean;
118
- isDisabled?: boolean;
119
- onPress?: () => void;
120
- style?: any;
121
- disabledStyle?: any;
122
- textStyle?: any;
123
- imgLeftSrc?: any;
124
- imgLeftStyle?: any;
125
- indicatorColor?: string;
126
- activeOpacity?: number;
127
- }
128
-
129
- class Button extends Component<ItemProps, any> {
130
- private static defaultProps: Partial<ItemProps> = {
131
- isLoading: false,
132
- isDisabled: false,
133
- style: stylesButton.btn,
134
- textStyle: stylesButton.txt,
135
- imgLeftStyle: stylesButton.imgLeft,
136
- indicatorColor: 'white',
137
- activeOpacity: 0.5,
138
- };
139
-
140
- constructor(props: ItemProps) {
141
- super(props);
142
- this.state = {};
143
- }
144
-
145
- public render(): ReactElement {
146
- if (this.props.isDisabled) {
147
- return (
148
- <View style={this.props.disabledStyle}>
149
- <Text style={this.props.textStyle}>{this.props.children}</Text>
150
- </View>
151
- );
152
- }
153
-
154
- if (this.props.isLoading) {
155
- return (
156
- <View style={this.props.style}>
157
- <ActivityIndicator size="small" color={this.props.indicatorColor} />
158
- </View>
159
- );
160
- }
161
-
162
- return (
163
- <TouchableOpacity
164
- activeOpacity={this.props.activeOpacity}
165
- onPress={this.props.onPress}>
166
- <View style={this.props.style}>
167
- {this.props.imgLeftSrc ? (
168
- <Image
169
- style={this.props.imgLeftStyle}
170
- source={this.props.imgLeftSrc}
171
- />
172
- ) : null}
173
- <Text style={this.props.textStyle}>{this.props.children}</Text>
174
- </View>
175
- </TouchableOpacity>
176
- );
177
- }
178
- }
179
-
180
- const styles: any = StyleSheet.create({
181
- container: {
182
- flex: 1,
183
- backgroundColor: '#455A64',
184
- flexDirection: 'column',
185
- alignItems: 'center',
186
- height: Dimensions.get('screen').height
187
- },
188
- titleTxt: {
189
- marginTop: 100,
190
- color: 'white',
191
- fontSize: 28,
192
- },
193
- viewRecorder: {
194
- marginTop: 40,
195
- width: '100%',
196
- alignItems: 'center',
197
- },
198
- recordBtnWrapper: {
199
- flexDirection: 'row',
200
- },
201
- viewPlayer: {
202
- marginTop: 60,
203
- alignSelf: 'stretch',
204
- alignItems: 'center',
205
- },
206
- viewBarWrapper: {
207
- marginTop: 28,
208
- marginHorizontal: 28,
209
- alignSelf: 'stretch',
210
- },
211
- viewBar: {
212
- backgroundColor: '#ccc',
213
- height: 4,
214
- alignSelf: 'stretch',
215
- },
216
- viewBarPlay: {
217
- backgroundColor: 'white',
218
- height: 4,
219
- width: 0,
220
- },
221
- playStatusTxt: {
222
- marginTop: 8,
223
- color: '#ccc',
224
- },
225
- playBtnWrapper: {
226
- flexDirection: 'row',
227
- marginTop: 40,
228
- },
229
- btn: {
230
- borderColor: 'white',
231
- borderWidth: 1,
232
- },
233
- txt: {
234
- color: 'white',
235
- fontSize: 14,
236
- marginHorizontal: 8,
237
- marginVertical: 4,
238
- },
239
- txtRecordCounter: {
240
- marginTop: 32,
241
- color: 'white',
242
- fontSize: 20,
243
- textAlignVertical: 'center',
244
- fontWeight: '200',
245
- fontFamily: 'Helvetica Neue',
246
- letterSpacing: 3,
247
- width: 300
248
- },
249
- txtCounter: {
250
- marginTop: 12,
251
- color: 'white',
252
- fontSize: 20,
253
- textAlignVertical: 'center',
254
- fontWeight: '200',
255
- fontFamily: 'Helvetica Neue',
256
- letterSpacing: 3,
257
- width: 300
258
- },
259
- });
260
-
261
- interface State {
262
- isLoggingIn: boolean;
263
- recordSecs: number;
264
- recordTime: string;
265
- currentPositionSec: number;
266
- currentDurationSec: number;
267
- playTime: string;
268
- duration: string;
269
- }
270
-
271
- const screenWidth = Dimensions.get('screen').width;
272
-
273
- class Page extends Component<any, State> {
274
- private audioRecorderPlayer
275
-
276
- constructor(props: any) {
277
- super(props);
278
- this.state = {
279
- isLoggingIn: false,
280
- recordSecs: 0,
281
- recordTime: '00:00:00',
282
- currentPositionSec: 0,
283
- currentDurationSec: 0,
284
- playTime: '00:00:00',
285
- duration: '00:00:00',
286
- };
287
-
288
- this.audioRecorderPlayer = new AudioRecorderPlayer()
289
- this.audioRecorderPlayer.setSubscriptionDuration(0.5); // optional. Default is 0.5
290
- }
291
-
292
- public render(): ReactElement {
293
- let playWidth =
294
- (this.state.currentPositionSec / this.state.currentDurationSec) *
295
- (screenWidth - 56);
296
-
297
- if (!playWidth) {
298
- playWidth = 0;
299
- }
300
-
301
- return (
302
- <SafeAreaView style={styles.container}>
303
- <Text style={styles.titleTxt}>Audio Recorder Player</Text>
304
- <Text style={styles.txtRecordCounter}>{this.state.recordTime}</Text>
305
- <View style={styles.viewRecorder}>
306
- <View style={styles.recordBtnWrapper}>
307
- <Button
308
- style={styles.btn}
309
- onPress={this.onStartRecord}
310
- textStyle={styles.txt}>
311
- startRecord
312
- </Button>
313
- <Button
314
- style={[
315
- styles.btn,
316
- {
317
- marginLeft: 12,
318
- },
319
- ]}
320
- onPress={this.onPauseRecord}
321
- textStyle={styles.txt}>
322
- Pause
323
- </Button>
324
- <Button
325
- style={[
326
- styles.btn,
327
- {
328
- marginLeft: 12,
329
- },
330
- ]}
331
- onPress={this.onResumeRecord}
332
- textStyle={styles.txt}>
333
- Resume
334
- </Button>
335
- <Button
336
- style={[styles.btn, { marginLeft: 12 }]}
337
- onPress={this.onStopRecord}
338
- textStyle={styles.txt}>
339
- Stop
340
- </Button>
341
- </View>
342
- </View>
343
- <View style={styles.viewPlayer}>
344
- <TouchableOpacity
345
- style={styles.viewBarWrapper}
346
- onPress={this.onStatusPress}>
347
- <View style={styles.viewBar}>
348
- <View style={[styles.viewBarPlay, { width: playWidth }]} />
349
- </View>
350
- </TouchableOpacity>
351
- <Text style={styles.txtCounter}>
352
- {this.state.playTime} / {this.state.duration}
353
- </Text>
354
- <View style={styles.playBtnWrapper}>
355
- <Button
356
- style={styles.btn}
357
- onPress={this.onStartPlay}
358
- textStyle={styles.txt}>
359
- Play
360
- </Button>
361
- <Button
362
- style={[
363
- styles.btn,
364
- {
365
- marginLeft: 12,
366
- },
367
- ]}
368
- onPress={this.onPausePlay}
369
- textStyle={styles.txt}>
370
- Pause
371
- </Button>
372
- <Button
373
- style={[
374
- styles.btn,
375
- {
376
- marginLeft: 12,
377
- },
378
- ]}
379
- onPress={this.onResumePlay}
380
- textStyle={styles.txt}>
381
- Resume
382
- </Button>
383
- <Button
384
- style={[
385
- styles.btn,
386
- {
387
- marginLeft: 12,
388
- },
389
- ]}
390
- onPress={this.onStopPlay}
391
- textStyle={styles.txt}>
392
- Stop
393
- </Button>
394
- </View>
395
- </View>
396
- </SafeAreaView>
397
- );
398
- }
399
-
400
- private onStatusPress = (e: any): void => {
401
- const touchX = e.nativeEvent.locationX;
402
- console.log(`touchX: ${touchX}`);
403
-
404
- const playWidth =
405
- (this.state.currentPositionSec / this.state.currentDurationSec) *
406
- (screenWidth - 56);
407
- console.log(`currentPlayWidth: ${playWidth}`);
408
-
409
- const currentPosition = Math.round(this.state.currentPositionSec);
410
-
411
- if (playWidth && playWidth < touchX) {
412
- const addSecs = Math.round(currentPosition + 1000);
413
- this.audioRecorderPlayer.seekToPlayer(addSecs);
414
- console.log(`addSecs: ${addSecs}`);
415
- } else {
416
- const subSecs = Math.round(currentPosition - 1000);
417
- this.audioRecorderPlayer.seekToPlayer(subSecs);
418
- console.log(`subSecs: ${subSecs}`);
419
- }
420
- };
421
-
422
- private onStartRecord = async (): Promise<void> => {
423
-
424
- const audioSet: AudioSet = {
425
- AudioEncoderAndroid: AudioEncoderAndroidType.AAC,
426
- AudioSourceAndroid: AudioSourceAndroidType.MIC,
427
- AVEncoderAudioQualityKeyIOS: AVEncoderAudioQualityIOSType.high,
428
- AVNumberOfChannelsKeyIOS: 2,
429
- AVFormatIDKeyIOS: AVEncodingOption.aac,
430
- OutputFormatAndroid: OutputFormatAndroidType.AAC_ADTS,
431
- AudioSourceHarmony: AudioSourceHarmonyType.MIC,
432
- AudioMimeHarmony: AudioMimeHarmonyType.AUDIO_AAC,
433
- AudioFileFormatHarmony: AudioFormatHarmonyType.MPEG_4A,
434
- AudioEncodingBitRateHarmony: 3200,
435
- AudioSamplingRateHarmony: 44100,
436
- AudioChannelsHarmony: 2,
437
- };
438
-
439
- console.log('audioSet', audioSet);
440
-
441
- const uri = await this.audioRecorderPlayer.startRecorder(
442
- 'audio.m4a',
443
- audioSet,
444
- );
445
-
446
- this.audioRecorderPlayer.addRecordBackListener((e: RecordBackType) => {
447
- console.log('record-back', e);
448
- this.setState({
449
- recordSecs: e.currentPosition,
450
- recordTime: this.audioRecorderPlayer.mmssss(
451
- Math.floor(e.currentPosition),
452
- ),
453
- });
454
- });
455
-
456
- console.log(`uri: ${uri}`);
457
- };
458
-
459
- private onPauseRecord = async (): Promise<void> => {
460
- try {
461
- const r = await this.audioRecorderPlayer.pauseRecorder();
462
- console.log(r);
463
- } catch (err) {
464
- console.log('pauseRecord', err);
465
- }
466
- };
467
-
468
- private onResumeRecord = async (): Promise<void> => {
469
- await this.audioRecorderPlayer.resumeRecorder();
470
- };
471
-
472
- private onStopRecord = async (): Promise<void> => {
473
- const result = await this.audioRecorderPlayer.stopRecorder();
474
- this.audioRecorderPlayer.removeRecordBackListener();
475
- this.setState({
476
- recordSecs: 0,
477
- });
478
- console.log(result, '>>>>>>>stopRecorder');
479
- };
480
-
481
- private onStartPlay = async (): Promise<void> => {
482
- console.log('onStartPlay');
483
-
484
- try {
485
- const msg = await this.audioRecorderPlayer.startPlayer('https://sis-sample-audio.obs.cn-north-1.myhuaweicloud.com/16k16bit.mp3', { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/21.0' });
486
- const volume = await this.audioRecorderPlayer.setVolume(1);
487
- this.audioRecorderPlayer.addPlayBackListener((e: PlayBackType) => {
488
- console.log('playBackListener', e);
489
- this.setState({
490
- currentPositionSec: e.currentPosition,
491
- currentDurationSec: e.duration,
492
- playTime: this.audioRecorderPlayer.mmssss(e.currentPosition),
493
- duration: this.audioRecorderPlayer.mmssss(Math.floor(e.duration)),
494
- });
495
- });
496
-
497
- } catch (err) {
498
- console.log('startPlayer error', err);
499
- }
500
- };
501
-
502
- private onPausePlay = async (): Promise<void> => {
503
- await this.audioRecorderPlayer.pausePlayer();
504
- };
505
-
506
- private onResumePlay = async (): Promise<void> => {
507
- await this.audioRecorderPlayer.resumePlayer();
508
- };
509
-
510
- private onStopPlay = async (): Promise<void> => {
511
- console.log('onStopPlay');
512
- this.audioRecorderPlayer.stopPlayer();
513
- this.audioRecorderPlayer.removePlayBackListener();
514
- };
515
- }
516
-
517
- export default Page;
518
-
519
- ```
520
-
521
- ## Link
522
-
523
- | | 是否支持autolink | RN框架版本 |
524
- |--------------------------------------|-----------------|------------|
525
- | ~3.7.0 | No | 0.77 |
526
- | ~3.6.11 | Yes | 0.72 |
527
- | <= 3.6.10-0.0.2@deprecated | No | 0.72 |
528
-
529
- 使用AutoLink的工程需要根据该文档配置,Autolink框架指导文档:https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md
530
-
531
- 如您使用的版本支持 Autolink,并且工程已接入 Autolink,可跳过ManualLink配置。
532
- <details>
533
- <summary>ManualLink: 此步骤为手动配置原生依赖项的指导</summary>
534
-
535
- 首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony`。
536
-
537
- ### 在工程根目录的 `oh-package.json5` 添加 overrides 字段
538
-
539
- ```json
540
- {
541
- ...
542
- "overrides": {
543
- "@rnoh/react-native-openharmony" : "./react_native_openharmony"
544
- }
545
- }
546
- ```
547
-
548
- ### 引入原生端代码
549
-
550
- 目前有两种方法:
551
-
552
- 1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
553
- 2. 直接链接源码。
554
-
555
- 方法一:通过 har 包引入(推荐)
556
-
557
- > [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。
558
-
559
- 打开 `entry/oh-package.json5`,添加以下依赖
560
-
561
- ```json
562
- "dependencies": {
563
- "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
564
-
565
- "@react-native-ohos/react-native-audio-recorder-player": "file:../../node_modules/@react-native-ohos/react-native-audio-recorder-player/harmony/audio_recorder_player.har"
566
- }
567
- ```
568
- 点击右上角的 `sync` 按钮
569
-
570
- 或者在终端执行:
571
-
572
- ```bash
573
- cd entry
574
- ohpm install
575
- ```
576
- 方法二:直接链接源码
577
-
578
- > [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/link-source-code.md)
579
-
580
- ### 配置 CMakeLists 和引入 RNAudioRecorderPlayerPackage
581
-
582
- > 若使用的是 <= 3.6.10-0.0.2 版本,请跳过本章。
583
-
584
- 打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
585
-
586
- ```diff
587
- project(rnapp)
588
- cmake_minimum_required(VERSION 3.4.1)
589
- set(CMAKE_SKIP_BUILD_RPATH TRUE)
590
- set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
591
- set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
592
- + set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
593
- set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
594
- set(LOG_VERBOSITY_LEVEL 1)
595
- set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
596
- set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
597
- set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
598
- add_compile_definitions(WITH_HITRACE_SYSTRACE)
599
-
600
- add_subdirectory("${RNOH_CPP_DIR}" ./rn)
601
-
602
- # RNOH_BEGIN: manual_package_linking_1
603
- add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
604
- + add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-audio-recorder-player/src/main/cpp" ./audio_recorder_player)
605
-
606
- # RNOH_END: manual_package_linking_1
607
-
608
- file(GLOB GENERATED_CPP_FILES "./generated/*.cpp")
609
-
610
- add_library(rnoh_app SHARED
611
- ${GENERATED_CPP_FILES}
612
- "./PackageProvider.cpp"
613
- "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
614
- )
615
- target_link_libraries(rnoh_app PUBLIC rnoh)
616
-
617
- # RNOH_BEGIN: manual_package_linking_2
618
- target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
619
- + target_link_libraries(rnoh_app PUBLIC rnoh_audio_recorder_player)
620
- # RNOH_END: manual_package_linking_2
621
- ```
622
- 打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
623
-
624
- ```diff
625
- #include "RNOH/PackageProvider.h"
626
- #include "generated/RNOHGeneratedPackage.h"
627
- #include "SamplePackage.h"
628
- + #include "RNAudioRecorderPlayerPackage.h"
629
-
630
- using namespace rnoh;
631
-
632
- std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
633
- return {
634
- std::make_shared<RNOHGeneratedPackage>(ctx),
635
- std::make_shared<SamplePackage>(ctx),
636
- + std::make_shared<RNAudioRecorderPlayerPackage>(ctx)
637
- };
638
- }
639
- ```
640
-
641
- ### 在 ArkTs 侧引入 RNAudioRecorderPlayerPackage
642
-
643
- 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加:
644
-
645
- ```diff
646
- + import {RNAudioRecorderPlayerPackage} from '@react-native-ohos/react-native-audio-recorder-player/ts';
647
-
648
- export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
649
- return [
650
- new SamplePackage(ctx),
651
- + new RNAudioRecorderPlayerPackage(ctx)
652
- ];
653
- }
654
- ```
655
- </details>
656
-
657
- ## 运行
658
-
659
- 点击右上角的 `sync` 按钮
660
-
661
- 或者在终端执行:
662
-
663
- ```bash
664
- cd entry
665
- ohpm install
666
- ```
667
- 然后编译、运行即可。
668
-
669
- ## 约束与限制
670
-
671
- ### 兼容性
672
-
673
- 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
674
-
675
- 在以下版本验证通过:
676
-
677
- 1. RNOH: 0.72.96; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
678
- 2. RNOH: 0.72.33; SDK: HarmonyOS NEXT B1; IDE: DevEco Studio: 5.0.3.900; ROM: Next.0.0.71;
679
- 3. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
680
-
681
- ### 权限要求
682
-
683
- #### 在 entry 目录下的module.json5中添加权限
684
-
685
- 打开 `entry/src/main/module.json5`,添加:
686
-
687
- ```diff
688
- ...
689
- "requestPermissions": [
690
- + {"name": "ohos.permission.INTERNET"},//网络播放音频需添加
691
- + {
692
- + "name": "ohos.permission.MICROPHONE",
693
- + "reason": "$string:Access_Create_Audio",
694
- + "usedScene": {
695
- + "abilities": [
696
- + "EntryAbility"
697
- + ],
698
- + "when": "always"
699
- + }
700
- + },
701
- ]
702
- ]
703
- ```
704
- #### 在 entry 目录下添加申请权限的原因
705
-
706
- 打开 `entry/src/main/resources/base/element/string.json`,添加:
707
-
708
- ```diff
709
- ...
710
- {
711
- "string": [
712
- + {
713
- + "name": "Access_Create_Audio",
714
- + "value": "access create Audio"
715
- + },
716
- ]
717
- }
718
- ```
719
- ## API
720
-
721
- > [!TIP] "Platform"列表示该属性在原三方库上支持的平台。
722
-
723
- > [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
724
-
725
- | Name | Description | Type | Required | Platform | HarmonyOS Support |
726
- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | -------- | ------------- | ----------------- |
727
- | `mmss` | 将毫秒转换为 分:秒 格式字符串 | function(milliseconds:number): string | No | Android,iOS | yes |
728
- | `mmssss` | 将毫秒转换为 分:秒:毫秒 格式字符串 | function(milliseconds:number): string | No | Android,iOS | yes |
729
- | `setSubscriptionDuration` | 设置录音/播放器启动后的默认回调间隔,默认值0.5即500毫秒 | function(seconds:float):void | No | Android,iOS | yes |
730
- | `addRecordBackListener` | 注册录音原生回调,回调数据包含当前录制时长、音量分贝(开启录音音量采集时返回) | function(callBack:(value:RecordBackType)=>void): void | No | Android,iOS | yes |
731
- | `removeRecordBackListener` | 移除录音监听回调 | function(): void | No | Android,iOS | yes |
732
- | `addPlayBackListener` | 注册播放器原生回调,回调数据包含音频总时长、当前播放进度 | function(callBack:(value: PlayBackType)=>void): void | No | Android,iOS | yes |
733
- | `removePlayBackListener` | 移除播放监听回调 | function(): void | No | Android,iOS | yes |
734
- | `startRecorder` | 开始录音;不传文件路径uri则音频保存至系统默认目录,audioSets中的AudioFileFormatHarmony可传参数包含AudioFormatHarmonyType.AAC、AudioFormatHarmonyType.MPEG_4、AudioFormatHarmonyType.MPEG_4A、AudioFormatHarmonyType.MP3、AudioFormatHarmonyType.WAV | function(uri?:string,audioSets?: AudioSet,meteringEnabled?: boolean): Promise< string > | No | Android,iOS | yes |
735
- | `pauseRecorder` | 暂停录音 | function() : Promise< string > | No | Android,iOS | yes |
736
- | `resumeRecorder` | 恢复录音 | function() : Promise< string > | No | Android,iOS | yes |
737
- | `stopRecorder` | 停止录音 | function() : Promise< string > | No | Android,iOS | yes |
738
- | `startPlayer` | 开始播放音频;不传参数则播放默认目录音频文件,支持传入网络请求头用于在线音频加载 | function(uri?:string,httpHeaders?:Record<string,string>) : Promise< string > | No | Android,iOS | yes |
739
- | `stopPlayer` | 停止播放 | function() : Promise< string > | No | Android,iOS | yes |
740
- | `pausePlayer` | 暂停播放 | function() : Promise< string > | No | Android,iOS | yes |
741
- | `resumePlayer` | 恢复播放 | function() : Promise< string > | No | Android,iOS | yes |
742
- | `seekToPlayer` | 跳转到指定毫秒播放位置 | function(milliseconds:number) : Promise< string > | No | Android,iOS | yes |
743
- | `setVolume` | 设置播放器音量,默认1.0,取值范围 0.0 ~ 1.0 | function(volume:float) : Promise< string > | No | Android,iOS | yes |
744
- | `setPlaybackSpeed`<sup>3.6.14+</sup> | 设置播放倍速<br/>鸿蒙适配后仅支持 0.125、0.25、0.5、0.75、1、1.25、1.5、1.75、2、3 倍速;其中3倍速仅支持API 13及以上版本 | function(playbackSpeed: number): Promise< string > | No | Android,iOS | partially |
745
-
746
-
747
- ## 遗留问题
748
-
749
- ## 其他
750
-
751
- ## 开源协议
752
-
753
- 本项目基于 [The MIT License (MIT)](https://github.com/hyochan/react-native-audio-recorder-player/blob/main/LICENSE) ,请自由地享受和参与开源。
1
+ > 文档模板:v0.4.2
2
+
3
+ <p align="center">
4
+ <h1 align="center"> <code>react-native-audio-recorder-player</code> </h1>
5
+ </p>
6
+
7
+ 本项目基于 [react-native-audio-recorder-player](https://github.com/hyochan/react-native-audio-recorder-player) 开发。
8
+
9
+ 该第三方库的仓库已迁移至 Gitcode,且支持直接从 npm 下载,新的包名为:`@react-native-ohos/react-native-audio-recorder-player` 版本所属关系如下:
10
+ | 三方库名称 | 三方库版本(npm地址) | 发布信息 | 支持RN版本 | Autolink | 编译API版本 | 社区基线版本 | 源码地址 |
11
+ | ------------ | ------------ | ------------------------------ | ------------- | ------------- |------------------------ | ------------- | ------------- |
12
+ | @react-native-ohos/react-native-audio-recorder-player | [~ 3.7.0(开发中)](https://www.npmjs.com/package/@react-native-ohos/react-native-audio-recorder-player) | [Gitcode Releases](https://gitcode.com/CPF-RN/rntpc_react-native-audio-recorder-player/releases) | 0.77.* /0.82.* /0.84.* | partially(0.82/0.84) | API12+ | 3.6.13 | [master](https://gitcode.com/CPF-RN/rntpc_react-native-audio-recorder-player/tree/master) |
13
+ | @react-native-ohos/react-native-audio-recorder-player | [~ 3.6.11](https://www.npmjs.com/package/@react-native-ohos/react-native-audio-recorder-player) | [Gitcode Releases](https://gitcode.com/CPF-RN/rntpc_react-native-audio-recorder-player/releases) | 0.72.* | 是 | API12+ | 3.6.10 | [br_rnoh0.72](https://gitcode.com/CPF-RN/rntpc_react-native-audio-recorder-player/tree/br_rnoh0.72) |
14
+ | @react-native-oh-tpl/react-native-audio-recorder-player | [<= 3.6.10-0.0.2@deprecated](https://www.npmjs.com/package/@react-native-oh-tpl/react-native-audio-recorder-player) | [Github Releases(deprecated)](https://github.com/react-native-oh-library/react-native-audio-recorder-player/releases) | 0.72.* | 否 | API12+ |3.6.10 | [sig](https://github.com/react-native-oh-library/react-native-audio-recorder-player/tree/sig) |
15
+
16
+
17
+ ## 简介
18
+
19
+ react-native-audio-recorder-player组件用于 React Native。是一个录音与播放组件,支持音频录制、音频播放等功能。
20
+
21
+ ## 下载安装
22
+
23
+ 进入到工程目录并输入以下命令:
24
+
25
+ **npm**
26
+
27
+ ```bash
28
+ npm install @react-native-ohos/react-native-audio-recorder-player
29
+ ```
30
+
31
+ **yarn**
32
+
33
+ ```bash
34
+ yarn add @react-native-ohos/react-native-audio-recorder-player
35
+ ```
36
+
37
+ ## Link
38
+
39
+ | | 是否支持autolink | RN框架版本 |
40
+ |--------------------------------------|-----------------|------------|
41
+ | ~3.7.0 | partially(0.82/0.84) | 0.77/0.82/0.84 |
42
+
43
+ 使用AutoLink的工程需要根据该文档配置,Autolink框架指导文档:https://gitcode.com/CPF-RN/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md
44
+
45
+ 如您使用的版本支持 Autolink,并且工程已接入 Autolink,可跳过ManualLink配置。
46
+ <details>
47
+ <summary>ManualLink: 此步骤为手动配置原生依赖项的指导</summary>
48
+
49
+ 首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony`。
50
+
51
+ ### 1. Overrides RN SDK
52
+
53
+ 为了让工程依赖同一个版本的 RN SDK,需要在工程根目录的 `oh-package.json5` 添加 overrides 字段,指向工程需要使用的 RN SDK 版本。替换的版本既可以是一个具体的版本号,也可以是一个模糊版本,还可以是本地存在的 HAR 包或源码目录。
54
+
55
+ 关于该字段的作用请阅读[官方说明](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/ide-oh-package-json5-V5#zh-cn_topic_0000001792256137_overrides)
56
+
57
+ ```json
58
+ {
59
+ "overrides": {
60
+ "@rnoh/react-native-openharmony": "^0.72.38" // ohpm 在线版本
61
+ // "@rnoh/react-native-openharmony" : "./react_native_openharmony.har" // 指向本地 har 包的路径
62
+ // "@rnoh/react-native-openharmony" : "./react_native_openharmony" // 指向源码路径
63
+ }
64
+ }
65
+ ```
66
+
67
+ ### 2. 引入原生端代码
68
+
69
+ 目前有两种方法:
70
+
71
+ 1. 通过 har 包引入;
72
+ 2. 直接链接源码。
73
+
74
+ 方法一:通过 har 包引入(推荐)
75
+
76
+ > [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。
77
+
78
+ 打开 `entry/oh-package.json5`,添加以下依赖
79
+
80
+ ```json
81
+ "dependencies": {
82
+ "@react-native-ohos/react-native-audio-recorder-player": "file:../../node_modules/@react-native-ohos/react-native-audio-recorder-player/harmony/audio_recorder_player.har"
83
+ }
84
+ ```
85
+ 点击右上角的 `sync` 按钮
86
+
87
+ 或者在命令行终端执行:
88
+
89
+ ```bash
90
+ cd entry
91
+ ohpm install
92
+ ```
93
+
94
+ 方法二:直接链接源码
95
+
96
+ > [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](https://gitcode.com/CPF-RN/usage-docs/blob/master/zh-cn/link-source-code.md)
97
+
98
+ ### 3. 配置 CMakeLists 和引入 RNAudioRecorderPlayerPackage
99
+
100
+ 打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
101
+
102
+ ```diff
103
+ project(rnapp)
104
+ cmake_minimum_required(VERSION 3.4.1)
105
+ set(CMAKE_SKIP_BUILD_RPATH TRUE)
106
+ set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
107
+ set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
108
+ + set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
109
+ set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
110
+ set(LOG_VERBOSITY_LEVEL 1)
111
+ set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
112
+ set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
113
+ set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
114
+ add_compile_definitions(WITH_HITRACE_SYSTRACE)
115
+
116
+ add_subdirectory("${RNOH_CPP_DIR}" ./rn)
117
+
118
+ # RNOH_BEGIN: manual_package_linking_1
119
+ + add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-audio-recorder-player/src/main/cpp" ./audio_recorder_player)
120
+ # RNOH_END: manual_package_linking_1
121
+
122
+ file(GLOB GENERATED_CPP_FILES "./generated/*.cpp")
123
+
124
+ add_library(rnoh_app SHARED
125
+ ${GENERATED_CPP_FILES}
126
+ "./PackageProvider.cpp"
127
+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
128
+ )
129
+ target_link_libraries(rnoh_app PUBLIC rnoh)
130
+
131
+ # RNOH_BEGIN: manual_package_linking_2
132
+ + target_link_libraries(rnoh_app PUBLIC rnoh_audio_recorder_player)
133
+ # RNOH_END: manual_package_linking_2
134
+ ```
135
+
136
+ 打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
137
+
138
+ ```diff
139
+ #include "RNOH/PackageProvider.h"
140
+ #include "SamplePackage.h"
141
+ + #include "RNAudioRecorderPlayerPackage.h"
142
+
143
+ using namespace rnoh;
144
+
145
+ std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
146
+ return {
147
+ std::make_shared<SamplePackage>(ctx),
148
+ + std::make_shared<RNAudioRecorderPlayerPackage>(ctx)
149
+ };
150
+ }
151
+ ```
152
+
153
+ ### 4. 在 ArkTs 侧引入 RNAudioRecorderPlayerPackage
154
+
155
+ 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加:
156
+
157
+ ```diff
158
+ + import {RNAudioRecorderPlayerPackage} from '@react-native-ohos/react-native-audio-recorder-player/ts';
159
+
160
+ export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
161
+ return [
162
+ + new RNAudioRecorderPlayerPackage(ctx)
163
+ ];
164
+ }
165
+ ```
166
+
167
+ </details>
168
+
169
+ ### 运行
170
+
171
+ 点击右上角的 `sync` 按钮
172
+
173
+ 或者在命令行终端执行:
174
+
175
+ ```bash
176
+ cd entry
177
+ ohpm install
178
+ ```
179
+ 然后编译、运行即可。
180
+
181
+ ## 约束与限制
182
+
183
+ ### 兼容性
184
+
185
+ 本文档内容基于以下版本验证通过:
186
+
187
+ 1. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
188
+ 2. RNOH: 0.82.30; SDK: HarmonyOS 6.0.2 Release SDK; IDE: DevEco Studio 6.0.2.650; ROM: 7.0.0;
189
+ 3. RNOH: 0.84.1; SDK: HarmonyOS SDK 26.0.0 Beta2; IDE: DevEco Studio 26.0.0.621; ROM: 7.0.0;
190
+
191
+ ### 权限要求
192
+
193
+ #### 在 entry 目录下的module.json5中添加权限
194
+
195
+ 在`entry/src/main/module.json5`,添加:
196
+
197
+ ```json
198
+ "requestPermissions": [
199
+ {"name": "ohos.permission.INTERNET"},//网络播放音频需添加
200
+ {
201
+ "name": "ohos.permission.MICROPHONE",
202
+ "reason": "$string:Access_Create_Audio",
203
+ "usedScene": {
204
+ "abilities": [
205
+ "EntryAbility"
206
+ ],
207
+ "when": "always"
208
+ }
209
+ },
210
+ ]
211
+ ```
212
+ #### 在 entry 目录下添加申请权限的原因
213
+
214
+ 打开 `entry/src/main/resources/base/element/string.json`,添加:
215
+
216
+ ```json
217
+ {
218
+ "string": [
219
+ {
220
+ "name": "Access_Create_Audio",
221
+ "value": "access create Audio"
222
+ }
223
+ ]
224
+ }
225
+ ```
226
+
227
+ ## 使用示例
228
+
229
+ 下面的代码展示了这个库的基本使用场景:
230
+
231
+ > [!WARNING] 使用时 import 的库名不变。
232
+
233
+ ```javascript
234
+ import AudioRecorderPlayer, {
235
+ AVEncoderAudioQualityIOSType,
236
+ AVEncodingOption,
237
+ AudioEncoderAndroidType,
238
+ AudioSourceAndroidType,
239
+ OutputFormatAndroidType,
240
+ AudioMimeHarmonyType,
241
+ AudioFormatHarmonyType,
242
+ AudioSourceHarmonyType,
243
+ AudioSet
244
+ } from 'react-native-audio-recorder-player'; import type {
245
+ PlayBackType,
246
+ RecordBackType,
247
+ } from 'react-native-audio-recorder-player';
248
+
249
+ import {
250
+ Dimensions,
251
+ Platform,
252
+ ActivityIndicator,
253
+ Image,
254
+ SafeAreaView,
255
+ StyleSheet,
256
+ Text,
257
+ TouchableOpacity,
258
+ View,
259
+ } from 'react-native';
260
+ import React, { Component } from 'react';
261
+
262
+ import type { ReactElement, ReactNode } from 'react';
263
+
264
+ const stylesButton: any = StyleSheet.create({
265
+ btn: {
266
+ backgroundColor: 'transparent',
267
+ alignSelf: 'center',
268
+ borderRadius: 4,
269
+ borderWidth: 2,
270
+ width: 320,
271
+ height: 52,
272
+ borderColor: 'white',
273
+
274
+ alignItems: 'center',
275
+ justifyContent: 'center',
276
+ },
277
+ btnDisabled: {
278
+ backgroundColor: 'rgb(243,243,243)',
279
+ alignSelf: 'center',
280
+ borderRadius: 4,
281
+ borderWidth: 2,
282
+ width: 320,
283
+ height: 52,
284
+ borderColor: '#333',
285
+
286
+ alignItems: 'center',
287
+ justifyContent: 'center',
288
+ },
289
+ txt: {
290
+ fontSize: 14,
291
+ color: 'white',
292
+ },
293
+ imgLeft: {
294
+ width: 24,
295
+ height: 24,
296
+ position: 'absolute',
297
+ left: 16,
298
+ },
299
+ });
300
+
301
+ interface ItemProps {
302
+ children?: ReactNode;
303
+ isLoading?: boolean;
304
+ isDisabled?: boolean;
305
+ onPress?: () => void;
306
+ style?: any;
307
+ disabledStyle?: any;
308
+ textStyle?: any;
309
+ imgLeftSrc?: any;
310
+ imgLeftStyle?: any;
311
+ indicatorColor?: string;
312
+ activeOpacity?: number;
313
+ }
314
+
315
+ class Button extends Component<ItemProps, any> {
316
+ private static defaultProps: Partial<ItemProps> = {
317
+ isLoading: false,
318
+ isDisabled: false,
319
+ style: stylesButton.btn,
320
+ textStyle: stylesButton.txt,
321
+ imgLeftStyle: stylesButton.imgLeft,
322
+ indicatorColor: 'white',
323
+ activeOpacity: 0.5,
324
+ };
325
+
326
+ constructor(props: ItemProps) {
327
+ super(props);
328
+ this.state = {};
329
+ }
330
+
331
+ public render(): ReactElement {
332
+ if (this.props.isDisabled) {
333
+ return (
334
+ <View style={this.props.disabledStyle}>
335
+ <Text style={this.props.textStyle}>{this.props.children}</Text>
336
+ </View>
337
+ );
338
+ }
339
+
340
+ if (this.props.isLoading) {
341
+ return (
342
+ <View style={this.props.style}>
343
+ <ActivityIndicator size="small" color={this.props.indicatorColor} />
344
+ </View>
345
+ );
346
+ }
347
+
348
+ return (
349
+ <TouchableOpacity
350
+ activeOpacity={this.props.activeOpacity}
351
+ onPress={this.props.onPress}>
352
+ <View style={this.props.style}>
353
+ {this.props.imgLeftSrc ? (
354
+ <Image
355
+ style={this.props.imgLeftStyle}
356
+ source={this.props.imgLeftSrc}
357
+ />
358
+ ) : null}
359
+ <Text style={this.props.textStyle}>{this.props.children}</Text>
360
+ </View>
361
+ </TouchableOpacity>
362
+ );
363
+ }
364
+ }
365
+
366
+ const styles: any = StyleSheet.create({
367
+ container: {
368
+ flex: 1,
369
+ backgroundColor: '#455A64',
370
+ flexDirection: 'column',
371
+ alignItems: 'center',
372
+ height: Dimensions.get('screen').height
373
+ },
374
+ titleTxt: {
375
+ marginTop: 100,
376
+ color: 'white',
377
+ fontSize: 28,
378
+ },
379
+ viewRecorder: {
380
+ marginTop: 40,
381
+ width: '100%',
382
+ alignItems: 'center',
383
+ },
384
+ recordBtnWrapper: {
385
+ flexDirection: 'row',
386
+ },
387
+ viewPlayer: {
388
+ marginTop: 60,
389
+ alignSelf: 'stretch',
390
+ alignItems: 'center',
391
+ },
392
+ viewBarWrapper: {
393
+ marginTop: 28,
394
+ marginHorizontal: 28,
395
+ alignSelf: 'stretch',
396
+ },
397
+ viewBar: {
398
+ backgroundColor: '#ccc',
399
+ height: 4,
400
+ alignSelf: 'stretch',
401
+ },
402
+ viewBarPlay: {
403
+ backgroundColor: 'white',
404
+ height: 4,
405
+ width: 0,
406
+ },
407
+ playStatusTxt: {
408
+ marginTop: 8,
409
+ color: '#ccc',
410
+ },
411
+ playBtnWrapper: {
412
+ flexDirection: 'row',
413
+ marginTop: 40,
414
+ },
415
+ btn: {
416
+ borderColor: 'white',
417
+ borderWidth: 1,
418
+ },
419
+ txt: {
420
+ color: 'white',
421
+ fontSize: 14,
422
+ marginHorizontal: 8,
423
+ marginVertical: 4,
424
+ },
425
+ txtRecordCounter: {
426
+ marginTop: 32,
427
+ color: 'white',
428
+ fontSize: 20,
429
+ textAlignVertical: 'center',
430
+ fontWeight: '200',
431
+ fontFamily: 'Helvetica Neue',
432
+ letterSpacing: 3,
433
+ width: 300
434
+ },
435
+ txtCounter: {
436
+ marginTop: 12,
437
+ color: 'white',
438
+ fontSize: 20,
439
+ textAlignVertical: 'center',
440
+ fontWeight: '200',
441
+ fontFamily: 'Helvetica Neue',
442
+ letterSpacing: 3,
443
+ width: 300
444
+ },
445
+ });
446
+
447
+ interface State {
448
+ isLoggingIn: boolean;
449
+ recordSecs: number;
450
+ recordTime: string;
451
+ currentPositionSec: number;
452
+ currentDurationSec: number;
453
+ playTime: string;
454
+ duration: string;
455
+ }
456
+
457
+ const screenWidth = Dimensions.get('screen').width;
458
+
459
+ class Page extends Component<any, State> {
460
+ private audioRecorderPlayer
461
+
462
+ constructor(props: any) {
463
+ super(props);
464
+ this.state = {
465
+ isLoggingIn: false,
466
+ recordSecs: 0,
467
+ recordTime: '00:00:00',
468
+ currentPositionSec: 0,
469
+ currentDurationSec: 0,
470
+ playTime: '00:00:00',
471
+ duration: '00:00:00',
472
+ };
473
+
474
+ this.audioRecorderPlayer = new AudioRecorderPlayer()
475
+ this.audioRecorderPlayer.setSubscriptionDuration(0.5); // optional. Default is 0.5
476
+ }
477
+
478
+ public render(): ReactElement {
479
+ let playWidth =
480
+ (this.state.currentPositionSec / this.state.currentDurationSec) *
481
+ (screenWidth - 56);
482
+
483
+ if (!playWidth) {
484
+ playWidth = 0;
485
+ }
486
+
487
+ return (
488
+ <SafeAreaView style={styles.container}>
489
+ <Text style={styles.titleTxt}>Audio Recorder Player</Text>
490
+ <Text style={styles.txtRecordCounter}>{this.state.recordTime}</Text>
491
+ <View style={styles.viewRecorder}>
492
+ <View style={styles.recordBtnWrapper}>
493
+ <Button
494
+ style={styles.btn}
495
+ onPress={this.onStartRecord}
496
+ textStyle={styles.txt}>
497
+ startRecord
498
+ </Button>
499
+ <Button
500
+ style={[
501
+ styles.btn,
502
+ {
503
+ marginLeft: 12,
504
+ },
505
+ ]}
506
+ onPress={this.onPauseRecord}
507
+ textStyle={styles.txt}>
508
+ Pause
509
+ </Button>
510
+ <Button
511
+ style={[
512
+ styles.btn,
513
+ {
514
+ marginLeft: 12,
515
+ },
516
+ ]}
517
+ onPress={this.onResumeRecord}
518
+ textStyle={styles.txt}>
519
+ Resume
520
+ </Button>
521
+ <Button
522
+ style={[styles.btn, { marginLeft: 12 }]}
523
+ onPress={this.onStopRecord}
524
+ textStyle={styles.txt}>
525
+ Stop
526
+ </Button>
527
+ </View>
528
+ </View>
529
+ <View style={styles.viewPlayer}>
530
+ <TouchableOpacity
531
+ style={styles.viewBarWrapper}
532
+ onPress={this.onStatusPress}>
533
+ <View style={styles.viewBar}>
534
+ <View style={[styles.viewBarPlay, { width: playWidth }]} />
535
+ </View>
536
+ </TouchableOpacity>
537
+ <Text style={styles.txtCounter}>
538
+ {this.state.playTime} / {this.state.duration}
539
+ </Text>
540
+ <View style={styles.playBtnWrapper}>
541
+ <Button
542
+ style={styles.btn}
543
+ onPress={this.onStartPlay}
544
+ textStyle={styles.txt}>
545
+ Play
546
+ </Button>
547
+ <Button
548
+ style={[
549
+ styles.btn,
550
+ {
551
+ marginLeft: 12,
552
+ },
553
+ ]}
554
+ onPress={this.onPausePlay}
555
+ textStyle={styles.txt}>
556
+ Pause
557
+ </Button>
558
+ <Button
559
+ style={[
560
+ styles.btn,
561
+ {
562
+ marginLeft: 12,
563
+ },
564
+ ]}
565
+ onPress={this.onResumePlay}
566
+ textStyle={styles.txt}>
567
+ Resume
568
+ </Button>
569
+ <Button
570
+ style={[
571
+ styles.btn,
572
+ {
573
+ marginLeft: 12,
574
+ },
575
+ ]}
576
+ onPress={this.onStopPlay}
577
+ textStyle={styles.txt}>
578
+ Stop
579
+ </Button>
580
+ </View>
581
+ </View>
582
+ </SafeAreaView>
583
+ );
584
+ }
585
+
586
+ private onStatusPress = (e: any): void => {
587
+ const touchX = e.nativeEvent.locationX;
588
+ console.log(`touchX: ${touchX}`);
589
+
590
+ const playWidth =
591
+ (this.state.currentPositionSec / this.state.currentDurationSec) *
592
+ (screenWidth - 56);
593
+ console.log(`currentPlayWidth: ${playWidth}`);
594
+
595
+ const currentPosition = Math.round(this.state.currentPositionSec);
596
+
597
+ if (playWidth && playWidth < touchX) {
598
+ const addSecs = Math.round(currentPosition + 1000);
599
+ this.audioRecorderPlayer.seekToPlayer(addSecs);
600
+ console.log(`addSecs: ${addSecs}`);
601
+ } else {
602
+ const subSecs = Math.round(currentPosition - 1000);
603
+ this.audioRecorderPlayer.seekToPlayer(subSecs);
604
+ console.log(`subSecs: ${subSecs}`);
605
+ }
606
+ };
607
+
608
+ private onStartRecord = async (): Promise<void> => {
609
+
610
+ const audioSet: AudioSet = {
611
+ AudioEncoderAndroid: AudioEncoderAndroidType.AAC,
612
+ AudioSourceAndroid: AudioSourceAndroidType.MIC,
613
+ AVEncoderAudioQualityKeyIOS: AVEncoderAudioQualityIOSType.high,
614
+ AVNumberOfChannelsKeyIOS: 2,
615
+ AVFormatIDKeyIOS: AVEncodingOption.aac,
616
+ OutputFormatAndroid: OutputFormatAndroidType.AAC_ADTS,
617
+ AudioSourceHarmony: AudioSourceHarmonyType.MIC,
618
+ AudioMimeHarmony: AudioMimeHarmonyType.AUDIO_AAC,
619
+ AudioFileFormatHarmony: AudioFormatHarmonyType.MPEG_4A,
620
+ AudioEncodingBitRateHarmony: 128000,
621
+ AudioSamplingRateHarmony: 44100,
622
+ AudioChannelsHarmony: 2,
623
+ };
624
+
625
+ console.log('audioSet', audioSet);
626
+
627
+ const uri = await this.audioRecorderPlayer.startRecorder(
628
+ 'audio.m4a',
629
+ audioSet,
630
+ );
631
+
632
+ this.audioRecorderPlayer.addRecordBackListener((e: RecordBackType) => {
633
+ console.log('record-back', e);
634
+ this.setState({
635
+ recordSecs: e.currentPosition,
636
+ recordTime: this.audioRecorderPlayer.mmssss(
637
+ Math.floor(e.currentPosition),
638
+ ),
639
+ });
640
+ });
641
+
642
+ console.log(`uri: ${uri}`);
643
+ };
644
+
645
+ private onPauseRecord = async (): Promise<void> => {
646
+ try {
647
+ const r = await this.audioRecorderPlayer.pauseRecorder();
648
+ console.log(r);
649
+ } catch (err) {
650
+ console.log('pauseRecord', err);
651
+ }
652
+ };
653
+
654
+ private onResumeRecord = async (): Promise<void> => {
655
+ await this.audioRecorderPlayer.resumeRecorder();
656
+ };
657
+
658
+ private onStopRecord = async (): Promise<void> => {
659
+ const result = await this.audioRecorderPlayer.stopRecorder();
660
+ this.audioRecorderPlayer.removeRecordBackListener();
661
+ this.setState({
662
+ recordSecs: 0,
663
+ });
664
+ console.log(result, '>>>>>>>stopRecorder');
665
+ };
666
+
667
+ private onStartPlay = async (): Promise<void> => {
668
+ console.log('onStartPlay');
669
+
670
+ try {
671
+ const msg = await this.audioRecorderPlayer.startPlayer('https://sis-sample-audio.obs.cn-north-1.myhuaweicloud.com/16k16bit.mp3', { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/21.0' });
672
+ const volume = await this.audioRecorderPlayer.setVolume(1);
673
+ this.audioRecorderPlayer.addPlayBackListener((e: PlayBackType) => {
674
+ console.log('playBackListener', e);
675
+ this.setState({
676
+ currentPositionSec: e.currentPosition,
677
+ currentDurationSec: e.duration,
678
+ playTime: this.audioRecorderPlayer.mmssss(e.currentPosition),
679
+ duration: this.audioRecorderPlayer.mmssss(Math.floor(e.duration)),
680
+ });
681
+ });
682
+
683
+ } catch (err) {
684
+ console.log('startPlayer error', err);
685
+ }
686
+ };
687
+
688
+ private onPausePlay = async (): Promise<void> => {
689
+ await this.audioRecorderPlayer.pausePlayer();
690
+ };
691
+
692
+ private onResumePlay = async (): Promise<void> => {
693
+ await this.audioRecorderPlayer.resumePlayer();
694
+ };
695
+
696
+ private onStopPlay = async (): Promise<void> => {
697
+ console.log('onStopPlay');
698
+ this.audioRecorderPlayer.stopPlayer();
699
+ this.audioRecorderPlayer.removePlayBackListener();
700
+ };
701
+ }
702
+
703
+ export default Page;
704
+ ```
705
+
706
+ ## 使用说明
707
+
708
+ **事件监听**
709
+ ```javascript
710
+ this.audioRecorderPlayer = new AudioRecorderPlayer()
711
+ // 添加播放回调
712
+ this.audioRecorderPlayer.addPlayBackListener((e: PlayBackType) => {
713
+ // 播放中触发
714
+ });
715
+ // 移除播放回调
716
+ this.audioRecorderPlayer.removePlayBackListener();
717
+ // 添加录制回调
718
+ this.audioRecorderPlayer.addRecordBackListener((e: RecordBackType) => {
719
+ // 录制中触发
720
+ });
721
+ // 移除录制回调
722
+ this.audioRecorderPlayer.removeRecordBackListener();
723
+ ```
724
+
725
+ **录制控制**
726
+ ```javascript
727
+ this.audioRecorderPlayer = new AudioRecorderPlayer()
728
+ // 开始录制
729
+ this.audioRecorderPlayer.startRecorder(
730
+ 'audio.m4a',
731
+ audioSet,
732
+ );
733
+ // 暂停录制
734
+ this.audioRecorderPlayer.pauseRecorder();
735
+ // 恢复录制
736
+ this.audioRecorderPlayer.resumeRecorder();
737
+ // 停止录制
738
+ this.audioRecorderPlayer.stopRecorder();
739
+ ```
740
+
741
+ **播放控制**
742
+ ```javascript
743
+ this.audioRecorderPlayer = new AudioRecorderPlayer()
744
+ // 设置订阅间隔时长
745
+ this.audioRecorderPlayer.setSubscriptionDuration(0.5);
746
+ // 定位到XX播放位置
747
+ this.audioRecorderPlayer.seekToPlayer(addSecs);
748
+ // 暂停播放
749
+ this.audioRecorderPlayer.pausePlayer();
750
+ // 恢复播放
751
+ this.audioRecorderPlayer.resumePlayer();
752
+ // 停止播放
753
+ this.audioRecorderPlayer.stopPlayer();
754
+ // 设置音量
755
+ this.audioRecorderPlayer.setVolume(1);
756
+ // 将毫秒转换为“分钟:秒:毫秒”格式的字符串
757
+ this.audioRecorderPlayer.mmssss(e.currentPosition),
758
+ // 将毫秒转换为“分:秒”格式的字符串
759
+ this.audioRecorderPlayer.mmss(
760
+ Math.floor(e.currentPosition),
761
+ ),
762
+ ```
763
+
764
+ ## 接口说明
765
+
766
+ > [!TIP] "Platform"列表示该属性在原三方库上支持的平台。
767
+
768
+ > [!TIP] "HarmonyOS Support"列为 yes 表示 OpenHarmony 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
769
+
770
+ | Name | Description | Type | Required | Platform | HarmonyOS Support |
771
+ | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | -------- | -------- | ----------------- |
772
+ | `mmss` | 将秒转换为“分:秒”格式的字符串 | function(seconds:number): string | No | Android,iOS | yes |
773
+ | `mmssss` | 将毫秒转换为“分钟:秒:毫秒”格式的字符串 | function(milisecs:number): string | No | Android,iOS | yes |
774
+ | `setSubscriptionDuration` | 设置录音器或播放器启动时的默认回调时间间隔。默认为 0.5,即 500 毫秒。| function(sec:number):Promise<string> | No | Android,iOS | yes |
775
+ | `addRecordBackListener` |从原生模块获取回调。将接收 currentPosition、currentMetering(如果在 startRecorder 中进行了配置)。 | function(callBack:(value:RecordBackType)=>void): void | No | Android,iOS | yes |
776
+ | `removeRecordBackListener` |移除 recordBack 监听器。 | function(): void | No | Android,iOS | yes |
777
+ | `addPlayBackListener` | 从原生模块获取回调,将收到 duration 和 currentPosition。 | function(callBack:(value: PlayBackType)=>void): void | No | Android,iOS | yes |
778
+ | `removePlayBackListener` | 移除 playback 监听器。 | function(): void | No | Android,iOS | yes |
779
+ | `startRecorder` |开始录音。不传递 uri 参数时,音频将保存在默认位置。 | function(uri?:string,audioSets?: AudioSet,meteringEnabled?: boolean): Promise< string > | No | Android,iOS | yes |
780
+ | `pauseRecorder` | 暂停录音。 | function() : Promise< string > | No | Android,iOS | yes |
781
+ | `resumeRecorder` | 恢复录音。 | function() : Promise< string > | No | Android,iOS | yes |
782
+ | `stopRecorder` | 停止录音。 | function() : Promise< string > | No | Android,iOS | yes |
783
+ | `startPlayer` | 开始播放。不传递参数时,将播放默认位置的音频。 | function(uri?:string,httpHeaders?:Record<string,string>) : Promise< string > | No | Android,iOS | yes |
784
+ | `stopPlayer` | 停止播放。 | function() : Promise< string > | No | Android,iOS | yes |
785
+ | `pausePlayer` | 暂停播放。 | function() : Promise< string > | No | Android,iOS | yes |
786
+ | `resumePlayer` | 恢复播放。 | function() : Promise< string > | No | Android,iOS | yes |
787
+ | `seekToPlayer` | 音频跳转。 | function(time:number) : Promise< string > | No | Android,iOS | yes |
788
+ | `setVolume` | 设置音频播放器的音量(默认值为 1.0,取值范围:0.0 ~ 1.0)。 | function(volume:float) : Promise< string > | No | Android,iOS | yes |
789
+ | `setPlaybackSpeed` | 设置播放速度。<br/>鸿蒙化后仅支持0.125、0.25、0.5、0.75、1、1.25、1.5、1.75、2和3倍速设置,其中3倍速仅在API version 13开始支持。 | function(playbackSpeed: number): Promise< string > | No | Android,iOS | partially (3倍速仅在API version 13开始支持) |
790
+
791
+ ## 鸿蒙平台 AudioSet 属性说明
792
+
793
+ 在 `startRecorder` 方法中使用的 `AudioSet` 对象包含多个平台的配置属性,其中以 `Harmony` 后缀结尾的属性为鸿蒙平台专属配置。以下对鸿蒙平台相关的枚举类型和属性进行详细说明。
794
+
795
+ ### AudioSourceHarmonyType(音频输入源类型)
796
+
797
+ 用于设置录音时的音频输入源,通过 `AudioSet.AudioSourceHarmony` 属性配置。
798
+
799
+ | 枚举值 | 对应数值 | 说明 |
800
+ | --------------------- | -------- | ----------------------------------- |
801
+ | `DEFAULT` | 0 | 默认音频源 |
802
+ | `MIC` | 1 | 麦克风输入 |
803
+ | `VOICE_RECOGNITION` | 2 | 语音识别,适用于语音转文字等场景 |
804
+ | `VOICE_COMMUNICATION` | 7 | 语音通信,适用于 VoIP 等实时通话场景 |
805
+ | `VOICE_MESSAGE` | 10 | 语音消息,适用于录制语音短消息 |
806
+ | `CAMCORDER` | 12 | 摄像头录音,与视频同步录制音频 |
807
+
808
+ ### AudioMimeHarmonyType(音频 MIME 类型)
809
+
810
+ 用于设置录音的音频编码格式 MIME 类型,通过 `AudioSet.AudioMimeHarmony` 属性配置。
811
+
812
+ | 枚举值 | 对应值 | 说明 |
813
+ | --------------- | ----------------- | ----------------------------- |
814
+ | `AUDIO_AAC` | `audio/mp4a-latm` | AAC 编码格式(音频/mp4a-latm) |
815
+ | `AUDIO_VORBIS` | `audio/vorbis` | Vorbis 编码格式 |
816
+ | `AUDIO_FLAC` | `audio/flac` | FLAC 无损编码格式 |
817
+ | `AUDIO_MP3` | `audio/mpeg` | MP3 编码格式 |
818
+ | `AUDIO_G711MU` | `audio/g711mu` | G711-mulaw 编码格式 |
819
+
820
+ ### AudioFormatHarmonyType(音频文件格式类型)
821
+
822
+ 用于设置录音输出的音频文件格式(后缀名),通过 `AudioSet.AudioFileFormatHarmony` 属性配置。
823
+
824
+ | 枚举值 | 对应值 | 说明 |
825
+ | --------- | ------ | ----------------------------- |
826
+ | `MPEG_4` | `mp4` | MPEG-4 容器格式(.mp4 文件) |
827
+ | `MPEG_4A` | `m4a` | MPEG-4 音频格式(.m4a 文件) |
828
+ | `MP3` | `mp3` | MP3 格式(.mp3 文件) |
829
+ | `WAV` | `wav` | WAV 格式(.wav 文件) |
830
+ | `AAC` | `aac` | AAC 格式(.aac 文件) |
831
+
832
+ ### AudioSet 鸿蒙专属属性说明
833
+
834
+ | 属性名 | 类型 | 说明 |
835
+ | ----------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
836
+ | `AudioSourceHarmony` | `AudioSourceHarmonyType` | 音频输入源类型。用于指定录音时的音频来源,默认为 `MIC`(麦克风)。 |
837
+ | `AudioMimeHarmony` | `AudioMimeHarmonyType` | 音频编码格式(MIME 类型)。用于指定录音的音频编码方式,如 AAC、MP3、FLAC 等。需与对应的采样率、比特率、声道数范围匹配。 |
838
+ | `AudioFileFormatHarmony` | `AudioFormatHarmonyType` | 音频文件输出格式。用于指定录音文件的容器格式及后缀名,如 `m4a`、`mp3`、`wav` 等。 |
839
+ | `AudioEncodingBitRateHarmony` | `number` | 音频编码比特率(单位:bps)。选择音频录制时必填。支持范围:<br>- AAC 编码格式支持比特率范围 `[32000 - 500000]`<br>- G711-mulaw 编码格式支持比特率范围 `[64000 - 64000]`<br>- MP3 编码格式支持 `[8000, 16000, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000]` |
840
+ | `AudioSamplingRateHarmony` | `number` | 音频采样率(单位:Hz)。支持范围:<br>- AAC 编码支持采样率范围 `[8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000]`<br>- G711-mulaw 编码支持采样率范围 `[8000 - 8000]`<br>- MP3 编码支持采样率范围 `[8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000]` |
841
+ | `AudioChannelsHarmony` | `number` | 音频采集声道数。支持范围:<br>- AAC 编码格式支持范围 `[1 - 8]`<br>- G711-mulaw 编码格式支持范围 `[1 - 1]`<br>- MP3 编码格式支持范围 `[1 - 2]` |
842
+
843
+ > [!TIP] 在使用 MP3 编码格式时,采样率和比特率存在映射关系:采样率 16K 以下时对应比特率范围为 `[8kbps - 64kbps]`;采样率 16K~32K 时对应比特率范围为 `[8kbps - 160kbps]`;采样率 32K 以上时对应比特率范围为 `[32kbps - 320kbps]`。
844
+
845
+ ### 使用示例
846
+
847
+ ```javascript
848
+ import {
849
+ AudioMimeHarmonyType,
850
+ AudioFormatHarmonyType,
851
+ AudioSourceHarmonyType,
852
+ AudioSet
853
+ } from 'react-native-audio-recorder-player';
854
+
855
+ const audioSet: AudioSet = {
856
+ // 鸿蒙平台录音配置
857
+ AudioSourceHarmony: AudioSourceHarmonyType.MIC, // 使用麦克风作为音频输入源
858
+ AudioMimeHarmony: AudioMimeHarmonyType.AUDIO_AAC, // 使用 AAC 编码格式
859
+ AudioFileFormatHarmony: AudioFormatHarmonyType.MPEG_4A, // 输出为 m4a 格式文件
860
+ AudioEncodingBitRateHarmony: 128000, // 设置编码比特率为 128000 bps
861
+ AudioSamplingRateHarmony: 44100, // 设置采样率为 44100 Hz
862
+ AudioChannelsHarmony: 2, // 设置双声道录制
863
+ };
864
+
865
+ const uri = await this.audioRecorderPlayer.startRecorder('audio.m4a', audioSet);
866
+ ```
867
+
868
+ ## 遗留问题
869
+ 无
870
+
871
+ ## 其他
872
+ 无
873
+
874
+ ## 目录结构
875
+ ````
876
+ /rntpc_react-native-audio-recorder-player # 项目根目录
877
+ ├── harmony # 鸿蒙适配代码
878
+ │ ├─ audio_recorder_player.har # har包
879
+ │ └─ audio_recorder_player # 鸿蒙适配核心代码
880
+ │ └─ index.ets # 鸿蒙适配代码入口
881
+ │ └─ src/main/ets
882
+ │ ├─ audioPlayer
883
+ │ └─ AudioPlayer.ts # 音频播放文件
884
+ │ └─ recorder
885
+ │ └─ Recorder.ts # 音频录制文件
886
+ ├── src # RN代码
887
+ │ └─ NativeAudioRecorderPlayerModule.ts # TurboModule文件
888
+ ├── index.ts # 入口文件
889
+ ├── README_en.md # 英文安装使用方法
890
+ ├── README.md # 中文安装使用方法
891
+ ````
892
+
893
+ ## 贡献代码
894
+
895
+ 使用过程中发现任何问题都可以提交 [Issue](https://gitcode.com/CPF-RN/rntpc_react-native-audio-recorder-player/issues),当然,也非常欢迎提交 [PR](https://gitcode.com/CPF-RN/rntpc_react-native-audio-recorder-player/pulls) 。
896
+
897
+ ## 开源协议
898
+
899
+ 本项目基于 [The MIT License (MIT)](https://github.com/hyochan/react-native-audio-recorder-player/blob/main/LICENSE) ,请自由地享受和参与开源。