@react-native-ohos/audio-toolkit 2.0.4-rc.1 → 2.1.0-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.
- package/COMMITTERS.md +7 -0
- package/README.md +16 -16
- package/harmony/audio_toolkit/BuildProfile.ets +16 -16
- package/harmony/audio_toolkit/README.md +9 -222
- package/harmony/audio_toolkit/oh-package.json5 +1 -1
- package/harmony/audio_toolkit/src/main/cpp/AudioToolkitPackage.h +19 -0
- package/harmony/audio_toolkit/src/main/cpp/CMakeLists.txt +9 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/RNOH/generated/BaseAudioToolkitPackage.h +76 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/RNOH/generated/turbo_modules/RCTAudioPlayer.cpp +23 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/RNOH/generated/turbo_modules/RCTAudioPlayer.h +16 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/RNOH/generated/turbo_modules/RCTAudioRecorder.cpp +20 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/RNOH/generated/turbo_modules/RCTAudioRecorder.h +16 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/audio_toolkit/ComponentDescriptors.h +24 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/audio_toolkit/EventEmitters.cpp +16 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/audio_toolkit/EventEmitters.h +17 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/audio_toolkit/Props.cpp +19 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/audio_toolkit/Props.h +18 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/audio_toolkit/ShadowNodes.cpp +17 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/audio_toolkit/ShadowNodes.h +23 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/audio_toolkit/States.cpp +16 -0
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/audio_toolkit/States.h +19 -0
- package/harmony/audio_toolkit/src/main/ets/RNCAudioRecorderTurboModule.ts +1 -1
- package/harmony/audio_toolkit/src/main/ets/generated/components/ts.ts +5 -0
- package/harmony/audio_toolkit/src/main/ets/generated/index.ets +5 -0
- package/harmony/audio_toolkit/src/main/ets/generated/ts.ts +6 -0
- package/harmony/audio_toolkit/src/main/ets/generated/turboModules/RCTAudioPlayer.ts +40 -0
- package/harmony/audio_toolkit/src/main/ets/generated/turboModules/RCTAudioRecorder.ts +24 -0
- package/harmony/audio_toolkit/src/main/ets/generated/turboModules/ts.ts +6 -0
- package/harmony/audio_toolkit.har +0 -0
- package/package.json +13 -12
package/COMMITTERS.md
ADDED
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# react-native-audio-toolkit
|
|
2
|
-
|
|
3
|
-
本项目基于 [react-native-audio-toolkit](https://github.com/react-native-audio-toolkit/react-native-audio-toolkit)
|
|
4
|
-
|
|
5
|
-
## 文档地址 / Documentation URL
|
|
6
|
-
|
|
7
|
-
[中文 / Chinese](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-audio-toolkit.md)
|
|
8
|
-
|
|
9
|
-
## Codegen
|
|
10
|
-
|
|
11
|
-
该库已接入 codegen,具体请查阅文档。
|
|
12
|
-
|
|
13
|
-
The library has been integrated with codegen. Please refer to the documentation for details.
|
|
14
|
-
|
|
15
|
-
## 请悉知 / Acknowledgements
|
|
16
|
-
|
|
1
|
+
# @react-native-ohos/react-native-audio-toolkit
|
|
2
|
+
|
|
3
|
+
本项目基于 [react-native-audio-toolkit@2.0.3](https://github.com/react-native-audio-toolkit/react-native-audio-toolkit/tree/v2.0.3)
|
|
4
|
+
|
|
5
|
+
## 文档地址 / Documentation URL
|
|
6
|
+
|
|
7
|
+
[中文 / Chinese](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-audio-toolkit.md)
|
|
8
|
+
|
|
9
|
+
## Codegen
|
|
10
|
+
|
|
11
|
+
该库已接入 codegen,具体请查阅文档。
|
|
12
|
+
|
|
13
|
+
The library has been integrated with codegen. Please refer to the documentation for details.
|
|
14
|
+
|
|
15
|
+
## 请悉知 / Acknowledgements
|
|
16
|
+
|
|
17
17
|
本项目基于 [The MIT License (MIT)](hhttps://github.com/react-native-audio-toolkit/react-native-audio-toolkit/blob/master/LICENSE) ,请自由地享受和参与开源。
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
|
3
|
-
*/
|
|
4
|
-
export const HAR_VERSION = '2.0.
|
|
5
|
-
export const BUILD_MODE_NAME = 'debug';
|
|
6
|
-
export const DEBUG = true;
|
|
7
|
-
export const TARGET_NAME = 'default';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* BuildProfile Class is used only for compatibility purposes.
|
|
11
|
-
*/
|
|
12
|
-
export default class BuildProfile {
|
|
13
|
-
static readonly HAR_VERSION = HAR_VERSION;
|
|
14
|
-
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
|
|
15
|
-
static readonly DEBUG = DEBUG;
|
|
16
|
-
static readonly TARGET_NAME = TARGET_NAME;
|
|
1
|
+
/**
|
|
2
|
+
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
|
3
|
+
*/
|
|
4
|
+
export const HAR_VERSION = '2.0.4-rc.2';
|
|
5
|
+
export const BUILD_MODE_NAME = 'debug';
|
|
6
|
+
export const DEBUG = true;
|
|
7
|
+
export const TARGET_NAME = 'default';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* BuildProfile Class is used only for compatibility purposes.
|
|
11
|
+
*/
|
|
12
|
+
export default class BuildProfile {
|
|
13
|
+
static readonly HAR_VERSION = HAR_VERSION;
|
|
14
|
+
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
|
|
15
|
+
static readonly DEBUG = DEBUG;
|
|
16
|
+
static readonly TARGET_NAME = TARGET_NAME;
|
|
17
17
|
}
|
|
@@ -1,230 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
# react-native-audio-toolkit
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<h1 align="center"> <code>@react-native-clipboard/clipboard</code> </h1>
|
|
5
|
-
</p>
|
|
6
|
-
<p align="center">
|
|
7
|
-
<a href="https://github.com/react-native-clipboard/clipboard">
|
|
8
|
-
<img src="https://img.shields.io/badge/platforms-android%20|%20ios%20|%20macos%20|%20windows%20|%20harmony%20-lightgrey.svg" alt="Supported platforms" />
|
|
9
|
-
</a>
|
|
10
|
-
<a href="https://github.com/react-native-clipboard/clipboard/blob/master/LICENSE">
|
|
11
|
-
<img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License" />
|
|
12
|
-
</a>
|
|
13
|
-
</p>
|
|
3
|
+
本项目基于 [react-native-audio-toolkit](https://github.com/react-native-audio-toolkit/react-native-audio-toolkit)
|
|
14
4
|
|
|
15
|
-
##
|
|
5
|
+
## 文档地址 / Documentation URL
|
|
16
6
|
|
|
17
|
-
|
|
7
|
+
[中文 / Chinese](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-audio-toolkit.md)
|
|
18
8
|
|
|
19
|
-
|
|
9
|
+
## Codegen
|
|
20
10
|
|
|
21
|
-
|
|
22
|
-
@react-native-oh-library:registry=https://npm.pkg.github.com
|
|
23
|
-
//npm.pkg.github.com/:_authToken=TOKEN
|
|
24
|
-
```
|
|
11
|
+
该库已接入 codegen,具体请查阅文档。
|
|
25
12
|
|
|
26
|
-
|
|
13
|
+
The library has been integrated with codegen. Please refer to the documentation for details.
|
|
27
14
|
|
|
28
|
-
|
|
15
|
+
## 请悉知 / Acknowledgements
|
|
29
16
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
yarn add @react-native-clipboard/clipboard@npm:@react-native-oh-library/clipboard
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
#### **npm**
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npm install @react-native-clipboard/clipboard@npm:@react-native-oh-library/clipboard
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
<!-- tabs:end -->
|
|
43
|
-
|
|
44
|
-
下面的代码展示了这个库的基本使用场景:
|
|
45
|
-
|
|
46
|
-
```js
|
|
47
|
-
import Clipboard from "@react-native-clipboard/clipboard";
|
|
48
|
-
|
|
49
|
-
const [copiedText, setCopiedText] = useState("");
|
|
50
|
-
|
|
51
|
-
const copyToClipboard = () => {
|
|
52
|
-
Clipboard.setString("hello world");
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const fetchCopiedText = async () => {
|
|
56
|
-
const text = await Clipboard.getString();
|
|
57
|
-
setCopiedText(text);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
<View style={styles.container}>
|
|
61
|
-
<TouchableOpacity onPress={copyToClipboard}>
|
|
62
|
-
<Text>Click here to copy to Clipboard</Text>
|
|
63
|
-
</TouchableOpacity>
|
|
64
|
-
<TouchableOpacity onPress={fetchCopiedText}>
|
|
65
|
-
<Text>View copied text</Text>
|
|
66
|
-
</TouchableOpacity>
|
|
67
|
-
|
|
68
|
-
<Text style={styles.copiedText}>{copiedText}</Text>
|
|
69
|
-
</View>;
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Link
|
|
73
|
-
|
|
74
|
-
目前鸿蒙暂不支持 AutoLink,所以 Link 步骤需要手动配置。
|
|
75
|
-
|
|
76
|
-
首先需要使用 DevEco Studio 打开项目里的鸿蒙工程 `harmony`
|
|
77
|
-
|
|
78
|
-
### 引入原生端代码
|
|
79
|
-
|
|
80
|
-
目前有两种方法:
|
|
81
|
-
|
|
82
|
-
1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
|
|
83
|
-
2. 直接链接源码。
|
|
84
|
-
|
|
85
|
-
方法一:通过 har 包引入
|
|
86
|
-
打开 `entry/oh-package.json5`,添加以下依赖
|
|
87
|
-
|
|
88
|
-
```json
|
|
89
|
-
"dependencies": {
|
|
90
|
-
"rnoh": "file:../rnoh",
|
|
91
|
-
"rnoh-clipboard": "file:../../node_modules/@react-native-clipboard/clipboard/harmony/clipboard.har"
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
点击右上角的 `sync` 按钮
|
|
96
|
-
|
|
97
|
-
或者在终端执行:
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
cd entry
|
|
101
|
-
ohpm install
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
方法二:直接链接源码
|
|
105
|
-
打开 `entry/oh-package.json5`,添加以下依赖
|
|
106
|
-
|
|
107
|
-
```json
|
|
108
|
-
"dependencies": {
|
|
109
|
-
"rnoh": "file:../rnoh",
|
|
110
|
-
"rnoh-clipboard": "file:../../node_modules/@react-native-clipboard/clipboard/harmony/clipboard"
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
打开终端,执行:
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
cd entry
|
|
118
|
-
ohpm install --no-link
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### 配置 CMakeLists 和引入 ClipboardPackage
|
|
122
|
-
|
|
123
|
-
打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
|
|
124
|
-
|
|
125
|
-
```diff
|
|
126
|
-
project(rnapp)
|
|
127
|
-
cmake_minimum_required(VERSION 3.4.1)
|
|
128
|
-
set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
129
|
-
set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
|
|
130
|
-
set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
|
|
131
|
-
|
|
132
|
-
add_subdirectory("${RNOH_CPP_DIR}" ./rn)
|
|
133
|
-
|
|
134
|
-
# RNOH_BEGIN: add_package_subdirectories
|
|
135
|
-
add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
|
|
136
|
-
+ add_subdirectory("${OH_MODULE_DIR}/rnoh-clipboard/src/main/cpp" ./clipboard)
|
|
137
|
-
# RNOH_END: add_package_subdirectories
|
|
138
|
-
|
|
139
|
-
add_library(rnoh_app SHARED
|
|
140
|
-
"./PackageProvider.cpp"
|
|
141
|
-
"${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
target_link_libraries(rnoh_app PUBLIC rnoh)
|
|
145
|
-
|
|
146
|
-
# RNOH_BEGIN: link_packages
|
|
147
|
-
target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
|
|
148
|
-
+ target_link_libraries(rnoh_app PUBLIC rnoh_clipboard)
|
|
149
|
-
# RNOH_END: link_packages
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
|
|
153
|
-
|
|
154
|
-
```diff
|
|
155
|
-
#include "RNOH/PackageProvider.h"
|
|
156
|
-
#include "SamplePackage.h"
|
|
157
|
-
+ #include "ClipboardPackage.h"
|
|
158
|
-
|
|
159
|
-
using namespace rnoh;
|
|
160
|
-
|
|
161
|
-
std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
|
|
162
|
-
return {
|
|
163
|
-
std::make_shared<SamplePackage>(ctx),
|
|
164
|
-
+ std::make_shared<ClipboardPackage>(ctx)
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### 在 ArkTs 侧引入 Clipboard Package
|
|
170
|
-
|
|
171
|
-
打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加:
|
|
172
|
-
|
|
173
|
-
```diff
|
|
174
|
-
import type {RNPackageContext, RNPackage} from 'rnoh/ts';
|
|
175
|
-
import {SamplePackage} from 'rnoh-sample-package/ts';
|
|
176
|
-
+ import {ClipboardPackage} from 'rnoh-clipboard/ts';
|
|
177
|
-
|
|
178
|
-
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
|
|
179
|
-
return [
|
|
180
|
-
new SamplePackage(ctx),
|
|
181
|
-
+ new ClipboardPackage(ctx)
|
|
182
|
-
];
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### 运行
|
|
188
|
-
|
|
189
|
-
点击右上角的 `sync` 按钮
|
|
190
|
-
|
|
191
|
-
或者在终端执行:
|
|
192
|
-
|
|
193
|
-
```bash
|
|
194
|
-
cd entry
|
|
195
|
-
ohpm install
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
然后编译、运行即可。
|
|
199
|
-
|
|
200
|
-
## 兼容性
|
|
201
|
-
|
|
202
|
-
要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
|
|
203
|
-
|
|
204
|
-
请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-library/clipboard Releases](https://github.com/react-native-oh-library/clipboard/releases)
|
|
205
|
-
|
|
206
|
-
## 属性
|
|
207
|
-
|
|
208
|
-
| 名称 | 说明 | 类型 | 是否必填 | 原库平台 | 鸿蒙支持 |
|
|
209
|
-
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- | ----------- | -------- |
|
|
210
|
-
| getString | Get content of string type, this method returns a Promise, so you can use following code to get clipboard content | function | NO | ios,android | yes |
|
|
211
|
-
| setString | Set content of string type. You can use following code to set clipboard content | function | NO | ios,android | yes |
|
|
212
|
-
| hasString | Returns whether the clipboard has content or is empty. | function | NO | ios,android | yes |
|
|
213
|
-
| getImage | Get content of image in base64 string type, this method returns a Promise, so you can use following code to get clipboard content (ANDROID only) | function | NO | android | no |
|
|
214
|
-
| getStrings | (iOS only) Get contents of string array type, this method returns a Promise, so you can use following code to get clipboard content | function | NO | ios | yes |
|
|
215
|
-
| setStrings | (iOS only) Set content of string array type. You can use following code to set clipboard content | function | NO | ios | yes |
|
|
216
|
-
| hasNumber | (iOS 14+ only) Returns whether the clipboard has a Number(UIPasteboardDetectionPatternNumber) content. Can check if there is a Number content in clipboard without triggering PasteBoard notification for iOS 14+ | function | NO | ios | yes |
|
|
217
|
-
| hasImage | Returns whether the clipboard has a Image | function | NO | ios | no |
|
|
218
|
-
| hasUrl | (iOS only) Returns whether the clipboard has a URL content. Can check if there is a URL content in clipboard without triggering PasteBoard notification for iOS 14+ | function | NO | ios | no |
|
|
219
|
-
| hasWebUrl | (iOS 14+ only) Returns whether the clipboard has a WebURL(UIPasteboardDetectionPatternProbableWebURL) content. Can check if there is a WebURL content in clipboard without triggering PasteBoard notification for iOS 14+ | function | NO | ios | yes |
|
|
220
|
-
| setImage | Set content of Image type.(base64 string) | function | NO | ios | no |
|
|
221
|
-
| getImageJPG | get base64 string of JPG Image | function | NO | ios | no |
|
|
222
|
-
| getImagePNG | get base64 string of PNG Image | function | NO | ios | no |
|
|
223
|
-
|
|
224
|
-
## 遗留问题
|
|
225
|
-
|
|
226
|
-
## 其他
|
|
227
|
-
|
|
228
|
-
## 开源协议
|
|
229
|
-
|
|
230
|
-
本项目基于 [The MIT License (MIT)](https://github.com/react-native-oh-library/clipboard/blob/harmony/LICENSE) ,请自由地享受和参与开源。
|
|
17
|
+
本项目基于 [The MIT License (MIT)](hhttps://github.com/react-native-audio-toolkit/react-native-audio-toolkit/blob/master/LICENSE) ,请自由地享受和参与开源。
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
2
|
+
// Use of this source code is governed by a MIT license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
#ifndef AUDIOTOOLKITPACKAGE_H
|
|
6
|
+
#define AUDIOTOOLKITPACKAGE_H
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#include "generated/RNOH/generated/BaseAudioToolkitPackage.h"
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
namespace rnoh {
|
|
14
|
+
class AudioToolkitPackage : public BaseAudioToolkitPackage {
|
|
15
|
+
using Super = BaseAudioToolkitPackage;
|
|
16
|
+
using Super::Super;
|
|
17
|
+
};
|
|
18
|
+
} // namespace rnoh
|
|
19
|
+
#endif //AUDIOTOOLKITPACKAGE_H
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.13)
|
|
2
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
3
|
+
|
|
4
|
+
set(rnoh_audio_toolkit_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated")
|
|
5
|
+
file(GLOB_RECURSE rnoh_audio_toolkit_generated_SRC "${rnoh_audio_toolkit_generated_dir}/**/*.cpp")
|
|
6
|
+
file(GLOB rnoh_audio_toolkit_SRC CONFIGURE_DEPENDS *.cpp)
|
|
7
|
+
add_library(rnoh_audio_toolkit SHARED ${rnoh_audio_toolkit_SRC} ${rnoh_audio_toolkit_generated_SRC})
|
|
8
|
+
target_include_directories(rnoh_audio_toolkit PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_audio_toolkit_generated_dir} ${CMAKE_CURRENT_SOURCE_DIR}/generated/RNOH/generated)
|
|
9
|
+
target_link_libraries(rnoh_audio_toolkit PUBLIC rnoh)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "RNOH/Package.h"
|
|
8
|
+
#include "RNOH/ArkTSTurboModule.h"
|
|
9
|
+
#include "RNOH/generated/turbo_modules/RCTAudioPlayer.h"
|
|
10
|
+
#include "RNOH/generated/turbo_modules/RCTAudioRecorder.h"
|
|
11
|
+
|
|
12
|
+
namespace rnoh {
|
|
13
|
+
|
|
14
|
+
class BaseAudioToolkitPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
|
|
15
|
+
public:
|
|
16
|
+
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
|
|
17
|
+
if (name == "RCTAudioPlayer") {
|
|
18
|
+
return std::make_shared<RCTAudioPlayer>(ctx, name);
|
|
19
|
+
}
|
|
20
|
+
if (name == "RCTAudioRecorder") {
|
|
21
|
+
return std::make_shared<RCTAudioRecorder>(ctx, name);
|
|
22
|
+
}
|
|
23
|
+
return nullptr;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
class BaseAudioToolkitPackageEventEmitRequestHandler : public EventEmitRequestHandler {
|
|
28
|
+
public:
|
|
29
|
+
void handleEvent(Context const &ctx) override {
|
|
30
|
+
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
|
|
31
|
+
auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
|
|
32
|
+
|
|
33
|
+
if (eventEmitter == nullptr) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
std::vector<std::string> supportedComponentNames = {
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
std::vector<std::string> supportedEventNames = {
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
|
|
44
|
+
std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
|
|
45
|
+
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class BaseAudioToolkitPackage : public Package {
|
|
52
|
+
public:
|
|
53
|
+
BaseAudioToolkitPackage(Package::Context ctx) : Package(ctx){};
|
|
54
|
+
|
|
55
|
+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
|
|
56
|
+
return std::make_unique<BaseAudioToolkitPackageTurboModuleFactoryDelegate>();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
|
|
60
|
+
return {
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
ComponentJSIBinderByString createComponentJSIBinderByName() override {
|
|
65
|
+
return {
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
|
|
70
|
+
return {
|
|
71
|
+
std::make_shared<BaseAudioToolkitPackageEventEmitRequestHandler>(),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace rnoh
|
package/harmony/audio_toolkit/src/main/cpp/generated/RNOH/generated/turbo_modules/RCTAudioPlayer.cpp
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#include "RCTAudioPlayer.h"
|
|
6
|
+
|
|
7
|
+
namespace rnoh {
|
|
8
|
+
using namespace facebook;
|
|
9
|
+
|
|
10
|
+
RCTAudioPlayer::RCTAudioPlayer(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
|
|
11
|
+
methodMap_ = {
|
|
12
|
+
ARK_METHOD_METADATA(set, 3),
|
|
13
|
+
ARK_METHOD_METADATA(prepare, 4),
|
|
14
|
+
ARK_METHOD_METADATA(play, 2),
|
|
15
|
+
ARK_METHOD_METADATA(pause, 0),
|
|
16
|
+
ARK_METHOD_METADATA(stop, 0),
|
|
17
|
+
ARK_METHOD_METADATA(destroy, 1),
|
|
18
|
+
ARK_METHOD_METADATA(seek, 0),
|
|
19
|
+
ARK_METHOD_METADATA(getCurrentTime, 2),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
} // namespace rnoh
|
package/harmony/audio_toolkit/src/main/cpp/generated/RNOH/generated/turbo_modules/RCTAudioPlayer.h
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "RNOH/ArkTSTurboModule.h"
|
|
8
|
+
|
|
9
|
+
namespace rnoh {
|
|
10
|
+
|
|
11
|
+
class JSI_EXPORT RCTAudioPlayer : public ArkTSTurboModule {
|
|
12
|
+
public:
|
|
13
|
+
RCTAudioPlayer(const ArkTSTurboModule::Context ctx, const std::string name);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#include "RCTAudioRecorder.h"
|
|
6
|
+
|
|
7
|
+
namespace rnoh {
|
|
8
|
+
using namespace facebook;
|
|
9
|
+
|
|
10
|
+
RCTAudioRecorder::RCTAudioRecorder(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
|
|
11
|
+
methodMap_ = {
|
|
12
|
+
ARK_METHOD_METADATA(prepare, 4),
|
|
13
|
+
ARK_METHOD_METADATA(record, 2),
|
|
14
|
+
ARK_METHOD_METADATA(stop, 2),
|
|
15
|
+
ARK_METHOD_METADATA(pause, 2),
|
|
16
|
+
ARK_METHOD_METADATA(destroy, 2),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
} // namespace rnoh
|
package/harmony/audio_toolkit/src/main/cpp/generated/RNOH/generated/turbo_modules/RCTAudioRecorder.h
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "RNOH/ArkTSTurboModule.h"
|
|
8
|
+
|
|
9
|
+
namespace rnoh {
|
|
10
|
+
|
|
11
|
+
class JSI_EXPORT RCTAudioRecorder : public ArkTSTurboModule {
|
|
12
|
+
public:
|
|
13
|
+
RCTAudioRecorder(const ArkTSTurboModule::Context ctx, const std::string name);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateComponentDescriptorH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "ShadowNodes.h"
|
|
14
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
void audio_toolkit_registerComponentDescriptorsFromCodegen(
|
|
22
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
|
|
23
|
+
|
|
24
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "EventEmitters.h"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
namespace facebook::react {
|
|
15
|
+
|
|
16
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "Props.h"
|
|
12
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
13
|
+
#include <react/renderer/core/propsConversions.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
} // namespace facebook::react
|
package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/audio_toolkit/Props.h
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
namespace facebook::react {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "ShadowNodes.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "EventEmitters.h"
|
|
14
|
+
#include "Props.h"
|
|
15
|
+
#include "States.h"
|
|
16
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
|
+
#include <jsi/jsi.h>
|
|
18
|
+
|
|
19
|
+
namespace facebook::react {
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateStateCpp.js
|
|
9
|
+
*/
|
|
10
|
+
#include "States.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateStateH.js
|
|
8
|
+
*/
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#ifdef ANDROID
|
|
12
|
+
#include <folly/dynamic.h>
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
} // namespace facebook::react
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { TurboModule, type TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
|
26
|
-
import { type TM } from '
|
|
26
|
+
import { type TM } from './generated/ts';
|
|
27
27
|
import { type BusinessError } from '@ohos.base';
|
|
28
28
|
import media from '@ohos.multimedia.media';
|
|
29
29
|
import fs from '@ohos.file.fs';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Tag } from "@rnoh/react-native-openharmony/ts"
|
|
6
|
+
|
|
7
|
+
export namespace RCTAudioPlayer {
|
|
8
|
+
export const NAME = 'RCTAudioPlayer' as const
|
|
9
|
+
|
|
10
|
+
export enum PlaybackCategories {
|
|
11
|
+
Playback = 1,
|
|
12
|
+
Ambient = 2,
|
|
13
|
+
SoloAmbient = 3,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type Option = {autoDestroy: boolean, continuesToPlayInBackground: boolean, category: PlaybackCategories, mixWithOthers: boolean}
|
|
17
|
+
|
|
18
|
+
export type PlayInfo = {duration: number, position: number}
|
|
19
|
+
|
|
20
|
+
export type setOptions = {volume: string, pan: string, wakeLock: string, looping: boolean, speed: boolean}
|
|
21
|
+
|
|
22
|
+
export interface Spec {
|
|
23
|
+
set(playerId: number, option: setOptions, next: () => void): void;
|
|
24
|
+
|
|
25
|
+
prepare(playerId: number, path: string, option: Option, next: () => void): void;
|
|
26
|
+
|
|
27
|
+
play(playerId: number, next: () => void): void;
|
|
28
|
+
|
|
29
|
+
pause(): void;
|
|
30
|
+
|
|
31
|
+
stop(): void;
|
|
32
|
+
|
|
33
|
+
destroy(content: string): void;
|
|
34
|
+
|
|
35
|
+
seek(): void;
|
|
36
|
+
|
|
37
|
+
getCurrentTime(playerId: number, callback: (err: string, result: PlayInfo) => void): void;
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Tag } from "@rnoh/react-native-openharmony/ts"
|
|
6
|
+
|
|
7
|
+
export namespace RCTAudioRecorder {
|
|
8
|
+
export const NAME = 'RCTAudioRecorder' as const
|
|
9
|
+
|
|
10
|
+
export type RecorderOptions = {bitrate: number, channels: number, sampleRate: number, format: string, encoder: string, quality: string}
|
|
11
|
+
|
|
12
|
+
export interface Spec {
|
|
13
|
+
prepare(recorderId: number, path: string, option: RecorderOptions, next: () => void): void;
|
|
14
|
+
|
|
15
|
+
record(recorderId: number, next: () => void): void;
|
|
16
|
+
|
|
17
|
+
stop(recorderId: number, next: () => void): void;
|
|
18
|
+
|
|
19
|
+
pause(recorderId: number, next: () => void): void;
|
|
20
|
+
|
|
21
|
+
destroy(recorderId: number, next: () => void): void;
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-ohos/audio-toolkit",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0-rc.1",
|
|
4
4
|
"description": "Cross-platform audio library for React Native",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "typings/index.d.ts",
|
|
7
7
|
"harmony": {
|
|
8
|
-
"alias": "@react-native-community/audio-toolkit"
|
|
9
|
-
"codegenConfig": {
|
|
10
|
-
"specPaths": [
|
|
11
|
-
"./src"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
8
|
+
"alias": "@react-native-community/audio-toolkit"
|
|
14
9
|
},
|
|
15
10
|
"directories": {
|
|
16
11
|
"doc": "docs"
|
|
17
12
|
},
|
|
18
13
|
"scripts": {
|
|
19
|
-
"start": "react-native start"
|
|
14
|
+
"start": "react-native start",
|
|
15
|
+
"codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name audio-toolkit --cpp-output-path ./harmony/audio_toolkit/src/main/cpp/generated --ets-output-path ./harmony/audio_toolkit/src/main/ets/generated --turbo-modules-spec-paths ./src"
|
|
20
16
|
},
|
|
21
|
-
"homepage": "https://
|
|
17
|
+
"homepage": "https://gitcode.com/openharmony-sig/rntpc_react-native-audio-toolkit#readme",
|
|
22
18
|
"license": "MIT",
|
|
23
19
|
"repository": {
|
|
24
20
|
"type": "git",
|
|
25
|
-
"url": "https://
|
|
21
|
+
"url": "https://gitcode.com/openharmony-sig/rntpc_react-native-audio-toolkit.git"
|
|
26
22
|
},
|
|
27
23
|
"bugs": {
|
|
28
|
-
"url": "https://
|
|
24
|
+
"url": "https://gitcode.com/openharmony-sig/rntpc_react-native-audio-toolkit/issues"
|
|
29
25
|
},
|
|
30
26
|
"dependencies": {
|
|
31
27
|
"async": "^2.6.3",
|
|
@@ -38,10 +34,15 @@
|
|
|
38
34
|
"react native",
|
|
39
35
|
"audio",
|
|
40
36
|
"audio toolkit",
|
|
41
|
-
"audio-toolkit"
|
|
37
|
+
"audio-toolkit",
|
|
38
|
+
"harmony"
|
|
42
39
|
],
|
|
43
40
|
"publishConfig": {
|
|
44
41
|
"registry": "https://registry.npmjs.org/",
|
|
45
42
|
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@rnoh/react-native-harmony-cli": "npm:@react-native-oh/react-native-harmony-cli@^0.0.27",
|
|
46
|
+
"@types/react-native": "^0.70.14"
|
|
46
47
|
}
|
|
47
48
|
}
|