From aaf9b40c5f9138a9ab6302892cac31115a39b8e8 Mon Sep 17 00:00:00 2001
From: "kangyouwei111@gmail.com"
Date: Mon, 29 Apr 2024 11:42:08 +0800
Subject: [PATCH 1/2] =?UTF-8?q?[Issues:=20#I9EX1Z]=20=E6=B7=BB=E5=8A=A0=20?=
=?UTF-8?q?react-native-audio=20=E6=93=8D=E4=BD=9C=E6=96=87=E6=A1=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 1 +
zh-cn/README.md | 1 +
zh-cn/react-native-audio.md | 272 ++++++++++++++++++++++++++++++++++++
3 files changed, 274 insertions(+)
create mode 100644 zh-cn/react-native-audio.md
diff --git a/README.md b/README.md
index d1423e28..2e1d765d 100644
--- a/README.md
+++ b/README.md
@@ -146,6 +146,7 @@
| 124 | [react-native-easy-toast](https://github.com/crazycodeboy/react-native-easy-toast "https://github.com/crazycodeboy/react-native-easy-toast") | 2.3.0 | - | - | [链接](https://react-native-oh-library.gitee.io/usage-docs/#/zh-cn/react-native-easy-toast) | |
| 125 | [react-native-image-sequence-2](https://github.com/bwindsor/react-native-image-sequence) | 0.9.1 | 否 | [@react-native-oh-tpl/react-native-image-sequence-2](https://github.com/react-native-oh-library/react-native-image-sequence/releases) | [链接](https://react-native-oh-library.gitee.io/usage-docs/#/zh-cn/react-native-sequence-2) |
| 126 | [react-native-feather](https://github.com/yigithanyucedag/react-native-feather "https://github.com/yigithanyucedag/react-native-feather") | 1.1.2 | \- | \- | [链接](https://react-native-oh-library.gitee.io/usage-docs/#/zh-cn/react-native-feather) |
+| 127 | [react-native-audio](https://github.com/jsierles/react-native-audio "https://github.com/jsierles/react-native-audio") | 4.3.0 | \- | \- | [链接](https://react-native-oh-library.gitee.io/usage-docs/#/zh-cn/react-native-audio) |
## 社区
diff --git a/zh-cn/README.md b/zh-cn/README.md
index 0c5661cf..2f23a933 100644
--- a/zh-cn/README.md
+++ b/zh-cn/README.md
@@ -146,6 +146,7 @@
| 124 | [react-native-easy-toast](https://github.com/crazycodeboy/react-native-easy-toast "https://github.com/crazycodeboy/react-native-easy-toast") | 2.3.0 | \- | \- | [链接](https://react-native-oh-library.gitee.io/usage-docs/#/zh-cn/react-native-easy-toast) | |
| 125 | [react-native-image-sequence-2](https://github.com/bwindsor/react-native-image-sequence "https://github.com/bwindsor/react-native-image-sequence") | 0.9.1 | 否 | [@react-native-oh-tpl/react-native-image-sequence-2](https://github.com/react-native-oh-library/react-native-image-sequence/releases) | [链接](https://react-native-oh-library.gitee.io/usage-docs/#/zh-cn/react-native-sequence-2) |
| 126 | [react-native-feather](https://github.com/yigithanyucedag/react-native-feather "https://github.com/yigithanyucedag/react-native-feather") | 1.1.2 | \- | \- | [链接](https://react-native-oh-library.gitee.io/usage-docs/#/zh-cn/react-native-feather) |
+| 127 | [react-native-audio](https://github.com/jsierles/react-native-audio "https://github.com/jsierles/react-native-audio") | 4.3.0 | \- | \- | [链接](https://react-native-oh-library.gitee.io/usage-docs/#/zh-cn/react-native-audio) |
## 社区
diff --git a/zh-cn/react-native-audio.md b/zh-cn/react-native-audio.md
new file mode 100644
index 00000000..4409c987
--- /dev/null
+++ b/zh-cn/react-native-audio.md
@@ -0,0 +1,272 @@
+
+> 模板版本:v0.1.3
+
+
+
react-native-audio
+
+
+
+
+
+
+
+
+
+
+
+> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-audio/)
+
+
+## 安装与使用
+
+请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-audio Releases](https://github.com/react-native-oh-library/react-native-audio/releases),并下载适用版本的 tgz 包。
+
+进入到工程目录并输入以下命令:
+
+
+
+#### **npm**
+
+```bash
+npm install @react-native-oh-tpl/react-native-audio
+```
+
+#### **yarn**
+
+```bash
+yarn add @react-native-oh-tpl/react-native-audio
+```
+
+
+
+下面的代码展示了这个库的基本使用场景:
+
+>[!WARNING] 使用时 import 的库名不变。
+
+```js
+import { AudioRecorder, AudioUtils } from "react-native-audio";
+
+// request microphone premission
+AudioRecorder.requestAuthorization().then((isAuthorised)=>{
+ console.log(`isAuthorised: ${isAuthorised}`)
+})
+
+// you check premission any time
+AudioRecorder.checkAuthorizationStatus().then((hasPermission)=>{
+ console.log(`hasPermission: ${hasPermission}`)
+})
+
+// Initialize recording parameters
+const path = `${AudioUtils.FilesDirectoryPath}/demo.m4a`
+AudioRecorder.prepareRecordingAtPath(path,{
+ SampleRate: 48000,
+ Channels: 2,
+ AudioQuality:'High',//only ios
+ AudioEncoding: 'aac',
+ AudioEncodingBitRate: 32000,
+ AudioSource: 1,
+ OutputFormat: 'm4a',
+ MeteringEnabled:false,//only ios
+ MeasurementMode:false,//only ios
+ IncludeBase64:false//ios and Android
+})
+
+// start recording
+AudioRecorder.start();
+
+// pause recording
+AudioRecorder.pause();
+
+// resume recording
+AudioRecorder.resume();
+
+// stop recording
+AudioRecorder.stop();
+
+// add function onProgress
+AudioRecorder.onProgress = (data) => {
+ console.log(data.currentTime)
+}
+
+// add function onFinished
+AudioRecorder.onFinished = (data) => {
+ console.log(data.currentTime)
+}
+```
+
+## Link
+
+目前鸿蒙暂不支持 AutoLink,所以 Link 步骤需要手动配置。
+
+首先需要使用 DevEco Studio 打开项目里的鸿蒙工程 `harmony`
+
+### 引入原生端代码
+
+目前有两种方法:
+
+1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
+2. 直接链接源码。
+
+方法一:通过 har 包引入
+
+> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。
+
+打开 `entry/oh-package.json5`,添加以下依赖
+
+```json
+"dependencies": {
+ "rnoh": "file:../rnoh",
+ "rnoh-audio": "file:../../node_modules/@react-native-oh-tpl/react-native-audio/harmony/audio.har"
+ }
+```
+
+点击右上角的 `sync` 按钮
+
+或者在终端执行:
+
+```bash
+cd entry
+ohpm install
+```
+
+方法二:直接链接源码
+
+> [!TIP] 源码位于三方库安装路径的 `harmony` 文件夹下。
+
+打开 `entry/oh-package.json5`,添加以下依赖
+
+```json
+"dependencies": {
+ "rnoh": "file:../rnoh",
+ "rnoh-audio": "file:../../node_modules/@react-native-oh-tpl/react-native-audio/harmony/audio"
+ }
+```
+
+打开终端,执行:
+
+```bash
+cd entry
+ohpm install --no-link
+```
+
+### 配置 CMakeLists 和引入 AudioPackge
+
+打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
+
+```diff
+project(rnapp)
+cmake_minimum_required(VERSION 3.4.1)
+set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
+set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
+
+add_subdirectory("${RNOH_CPP_DIR}" ./rn)
+
+# RNOH_BEGIN: add_package_subdirectories
+add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
++ add_subdirectory("${OH_MODULE_DIR}/rnoh-linear-gradient/src/main/cpp" ./audio)
+# RNOH_END: add_package_subdirectories
+
+add_library(rnoh_app SHARED
+ "./PackageProvider.cpp"
+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
+)
+
+target_link_libraries(rnoh_app PUBLIC rnoh)
+
+# RNOH_BEGIN: link_packages
+target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
++ target_link_libraries(rnoh_app PUBLIC rnoh_audio)
+# RNOH_END: link_packages
+```
+
+打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
+
+```diff
+#include "RNOH/PackageProvider.h"
+#include "SamplePackage.h"
++ #include "AudioPackage.h"
+
+using namespace rnoh;
+
+std::vector> PackageProvider::getPackages(Package::Context ctx) {
+ return {
+ std::make_shared(ctx),
++ std::make_shared(ctx)
+ };
+}
+```
+
+### 在 ArkTs 侧引入 AudioPackage
+
+打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加:
+
+```diff
+...
++ import {AudioPackage} from 'rnoh-async-storage/ts';
+
+export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
+ return [
+ new SamplePackage(ctx),
++ new AudioPackage(ctx)
+ ];
+}
+```
+
+### 运行
+
+点击右上角的 `sync` 按钮
+
+或者在终端执行:
+
+```bash
+cd entry
+ohpm install
+```
+
+然后编译、运行即可。
+
+## 约束与限制
+
+### 兼容性
+
+本文档内容基于以下版本验证通过:
+
+react-native-harmony:0.72.20; SDK:HarmonyOS NEXT Developer Beta1; IDE:DevEco Studio 5.0.3.200; ROM:3.0.0.18;
+
+请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[react-native-audio Releases](https://github.com/react-native-oh-library/react-native-audio/releases)
+
+### 权限要求
+
+Encodings supported on iOS: lpcm, ima4, aac, MAC3, MAC6, ulaw, alaw, mp1, mp2, alac, amr Encodings supported on Android: aac, aac_eld, amr_nb, amr_wb, he_aac, vorbis
+Encodings supported on Harmony: aac.
+
+AudioQuality、MeteringEnabled、MeasurementMode is only for ios; IncludeBase64 is for ios and Android, not support on Harmony.
+
+## API
+
+> [!tip] "Platform"列表示该属性在原三方库上支持的平台。
+
+> [!tip] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| ---- | ----------- | ---- | -------- | -------- | ------------------ |
+| requestAuthorization | 请求麦克风权限 | function | yes | phone | yes |
+| checkAuthorizationStatus | 检查授权状态 | function | yes | phone | yes |
+| prepareRecordingAtPath | 初始化录制实例参数 | function | yes | phone | yes |
+| startRecording | 开始录制 | function | yes | phone | yes |
+| pauseRecording | 暂停录制 | function | yes | phone | yes |
+| resumeRecording | 重新开始录制 | function | yes | phone | yes |
+| stopRecording | 结束录制 | function | yes | phone | yes |
+
+## 遗留问题
+
+
+
+
+## 其他
+
+## 开源协议
+
+本项目基于 [The MIT License (MIT)](https://github.com/jsierles/react-native-audio/blob/master/README.md) ,请自由地享受和参与开源。
+
--
Gitee
From 438ec95ae3bbc2ceb81ae5ac3c6e298fa6fabf87 Mon Sep 17 00:00:00 2001
From: "kangyouwei111@gmail.com"
Date: Mon, 13 May 2024 20:05:03 +0800
Subject: [PATCH 2/2] =?UTF-8?q?[Issues:=20#I9EX1Z]=20=E6=B7=BB=E5=8A=A0=20?=
=?UTF-8?q?react-native-audio=20=E6=93=8D=E4=BD=9C=E6=96=87=E6=A1=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
zh-cn/react-native-audio.md | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/zh-cn/react-native-audio.md b/zh-cn/react-native-audio.md
index 4409c987..bc309e31 100644
--- a/zh-cn/react-native-audio.md
+++ b/zh-cn/react-native-audio.md
@@ -1,5 +1,5 @@
-> 模板版本:v0.1.3
+> 模板版本:v0.2.0
react-native-audio
@@ -23,18 +23,20 @@
进入到工程目录并输入以下命令:
+> [!TIP] # 处替换为 tgz 包的路径
+
#### **npm**
```bash
-npm install @react-native-oh-tpl/react-native-audio
+npm install @react-native-oh-tpl/react-native-audio@file:#
```
#### **yarn**
```bash
-yarn add @react-native-oh-tpl/react-native-audio
+yarn add @react-native-oh-tpl/react-native-audio@file:#
```
@@ -63,12 +65,12 @@ AudioRecorder.prepareRecordingAtPath(path,{
Channels: 2,
AudioQuality:'High',//only ios
AudioEncoding: 'aac',
- AudioEncodingBitRate: 32000,
+ AudioEncodingBitRate: 100000,
AudioSource: 1,
OutputFormat: 'm4a',
MeteringEnabled:false,//only ios
MeasurementMode:false,//only ios
- IncludeBase64:false//ios and Android
+ IncludeBase64:false
})
// start recording
@@ -90,7 +92,11 @@ AudioRecorder.onProgress = (data) => {
// add function onFinished
AudioRecorder.onFinished = (data) => {
- console.log(data.currentTime)
+ console.log(data.base64);//base64
+ console.log(data.duration);//audio duration
+ console.log(data.status);//OK/REEOR
+ console.log(data.audioFileSize);//audioFileSize
+ console.log(data.audioFileURL);//audio file url
}
```
@@ -115,8 +121,8 @@ AudioRecorder.onFinished = (data) => {
```json
"dependencies": {
- "rnoh": "file:../rnoh",
- "rnoh-audio": "file:../../node_modules/@react-native-oh-tpl/react-native-audio/harmony/audio.har"
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
+ "@react-native-oh-tpl/react-native-audio": "file:../../node_modules/@react-native-oh-tpl/react-native-audio/harmony/audio.har"
}
```
@@ -137,8 +143,8 @@ ohpm install
```json
"dependencies": {
- "rnoh": "file:../rnoh",
- "rnoh-audio": "file:../../node_modules/@react-native-oh-tpl/react-native-audio/harmony/audio"
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
+ "@react-native-oh-tpl/react-native-audio": "file:../../node_modules/@react-native-oh-tpl/react-native-audio/harmony/audio"
}
```
@@ -268,5 +274,5 @@ AudioQuality、MeteringEnabled、MeasurementMode is only for ios; IncludeBase64
## 开源协议
-本项目基于 [The MIT License (MIT)](https://github.com/jsierles/react-native-audio/blob/master/README.md) ,请自由地享受和参与开源。
+本项目基于 [The MIT License (MIT)](https://github.com/jsierles/react-native-audio/blob/master/LICENSE) ,请自由地享受和参与开源。
--
Gitee