@react-native-ohos/audio-toolkit 2.0.4-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/CHANGELOG.md +136 -0
- package/LICENSE +22 -0
- package/README.md +17 -0
- package/ReactNativeAudioToolkit.podspec +18 -0
- package/banner.png +0 -0
- package/harmony/audio_toolkit/BuildProfile.ets +17 -0
- package/harmony/audio_toolkit/LICENSE +21 -0
- package/harmony/audio_toolkit/NOTICE +33 -0
- package/harmony/audio_toolkit/OAT.xml +38 -0
- package/harmony/audio_toolkit/README.OpenSource +11 -0
- package/harmony/audio_toolkit/README.md +230 -0
- package/harmony/audio_toolkit/build-profile.json5 +8 -0
- package/harmony/audio_toolkit/hvigorfile.ts +1 -0
- package/harmony/audio_toolkit/index.ets +25 -0
- package/harmony/audio_toolkit/oh-package.json5 +12 -0
- package/harmony/audio_toolkit/src/main/ets/AudioToolkitPackage.ts +51 -0
- package/harmony/audio_toolkit/src/main/ets/Logger.ts +64 -0
- package/harmony/audio_toolkit/src/main/ets/RNCAudioPlayerTurboModule.ts +433 -0
- package/harmony/audio_toolkit/src/main/ets/RNCAudioRecorderTurboModule.ts +261 -0
- package/harmony/audio_toolkit/src/main/module.json5 +7 -0
- package/harmony/audio_toolkit/src/main/resources/base/element/string.json +8 -0
- package/harmony/audio_toolkit/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/audio_toolkit/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/audio_toolkit/ts.ts +26 -0
- package/harmony/audio_toolkit.har +0 -0
- package/icon.png +0 -0
- package/package.json +47 -0
- package/src/Player.js +329 -0
- package/src/PlayerModule.ts +51 -0
- package/src/Recorder.js +183 -0
- package/src/RecorderModule.ts +83 -0
- package/src/index.ts +5 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
5
|
+
|
|
6
|
+
## Unreleased
|
|
7
|
+
### Added
|
|
8
|
+
- Add inline base64 audio URL support
|
|
9
|
+
- Add ability to generate metering events while recording, which measure sound input levels
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- Android: Fixed a compatibility issue on Android where on some Android models (e.g. HUAWEI) a -38 error is generated
|
|
13
|
+
- iOS: Fixed duration not being provided until getCurrentTime is called
|
|
14
|
+
|
|
15
|
+
## [2.0.3] - 2020-03-23
|
|
16
|
+
### Added
|
|
17
|
+
- Add Player option mixWithOthers
|
|
18
|
+
- iOS: Add ability to override audio session category
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- Android: Remove unneeded references to Android support library, improving Android X support
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
- iOS: Made linking to RCTBridgeModule.h more robust
|
|
25
|
+
- iOS: Fixed podspec not using right Git tag string
|
|
26
|
+
|
|
27
|
+
## [2.0.2] - 2019-07-09
|
|
28
|
+
### Added
|
|
29
|
+
- Cocoapods support
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
- Add more specific error strings to TypeScript error types
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
- Android: Fix Gradle warning related to defining the targetSdk within the AndroidManifest.xml
|
|
36
|
+
|
|
37
|
+
## [2.0.1] - 2019-06-26
|
|
38
|
+
### Fixed
|
|
39
|
+
- Fixed iOS linking errors caused by change of folder structure
|
|
40
|
+
|
|
41
|
+
## [2.0.0] - 2019-06-26
|
|
42
|
+
### BREAKING CHANGES
|
|
43
|
+
- Changed npm package name from `react-native-audio-toolkit` to `@react-native-community/audio-toolkit` and changed Android namespace from `com.futurice.rctaudiotoolkit` to `com.reactnativecommunity.rctaudiotoolkit`. These changes require users to reinstall and re-link the library to update to this version. This can be done manually or automatically during the update process via:
|
|
44
|
+
```
|
|
45
|
+
react-native unlink react-native-audio-toolkit
|
|
46
|
+
npm uninstall --save react-native-audio-toolkit
|
|
47
|
+
npm install --save @react-native-community/audio-toolkit
|
|
48
|
+
react-native link @react-native-community/audio-toolkit
|
|
49
|
+
```
|
|
50
|
+
- Android: Remove permissions from library AndroidManifest and instead require users to add them. See [SETUP.md](https://github.com/react-native-community/react-native-audio-toolkit/blob/master/docs/SETUP.md) and PR [#148](https://github.com/react-native-community/react-native-audio-toolkit/pull/148) for more details
|
|
51
|
+
|
|
52
|
+
### Added
|
|
53
|
+
- Add Typescript typings
|
|
54
|
+
- Add ability to set playback speed for audio player
|
|
55
|
+
- Add ability to pause a Recorder
|
|
56
|
+
- Android: Add ability to record to AAC
|
|
57
|
+
- iOS: Added possibility to record from Bluetooth microphone
|
|
58
|
+
|
|
59
|
+
### Changed
|
|
60
|
+
- Specify exactly which files to include in npm package
|
|
61
|
+
- Only import specific items from lodash to keep build size down
|
|
62
|
+
- Android: `build.gradle` will use SDK version settings of the root project, if available
|
|
63
|
+
- iOS: Buffer up to 10 seconds of audio before beginning playback
|
|
64
|
+
|
|
65
|
+
### Fixed
|
|
66
|
+
- Fixed some incorrect examples in the documentation
|
|
67
|
+
- Android: Guard against possible exceptions while parsing stack trace
|
|
68
|
+
- Android: Guard against exceptions that can appear in onHostPause
|
|
69
|
+
- Android: Fix build error related to defining `android:minSdkVersion` in the library's AndroidManifest
|
|
70
|
+
- Android: Fix crash on devices running API level 22 or earlier
|
|
71
|
+
- iOS: Fix `Player.pause()` not setting `PAUSED` state
|
|
72
|
+
|
|
73
|
+
## [1.0.6] - 2017-11-01
|
|
74
|
+
### Changed
|
|
75
|
+
- Android: Changed prepare to prepareAsync
|
|
76
|
+
|
|
77
|
+
### Fixed
|
|
78
|
+
- Fix compatibility with React Native 0.47
|
|
79
|
+
- Fix compatibility with React Native 0.48
|
|
80
|
+
- Fix compatibility with React Native 0.49
|
|
81
|
+
- Android: Fix updating playerContinueInBackground
|
|
82
|
+
- Android: Fix a bug when finding audio file
|
|
83
|
+
- Android: Fix compatibility with API level 16 by removing usage of `java.util.Objects`
|
|
84
|
+
|
|
85
|
+
## [1.0.5] - 2016-09-22
|
|
86
|
+
### Changed
|
|
87
|
+
- Android: By default pause playback if app is sent to background
|
|
88
|
+
|
|
89
|
+
## [1.0.4] - 2016-08-26
|
|
90
|
+
### Fixed
|
|
91
|
+
- iOS: Fix audio events
|
|
92
|
+
|
|
93
|
+
## [1.0.3] - 2016-08-17
|
|
94
|
+
### Added
|
|
95
|
+
- Add Player state diagram to documentation
|
|
96
|
+
- Add recording example to README.md
|
|
97
|
+
- Record `prepare()` returns filesystem path of file being recorded to
|
|
98
|
+
|
|
99
|
+
### Fixed
|
|
100
|
+
- Missing `this` in setup example
|
|
101
|
+
|
|
102
|
+
## [1.0.2] - 2016-06-25
|
|
103
|
+
### Added
|
|
104
|
+
- Add description to package.json
|
|
105
|
+
|
|
106
|
+
## [1.0.1] - 2016-06-25
|
|
107
|
+
### Added
|
|
108
|
+
- Add repository to package.json
|
|
109
|
+
- Add error handling to Example App
|
|
110
|
+
- iOS: Send current position at pause
|
|
111
|
+
|
|
112
|
+
### Changed
|
|
113
|
+
- Move documentation from README.md to separate files within docs directory
|
|
114
|
+
- Improve documentation
|
|
115
|
+
- Restructure Player and Recorder into own source files
|
|
116
|
+
|
|
117
|
+
### Fixed
|
|
118
|
+
- Android: Fix seeking, hide debug prints
|
|
119
|
+
- Android: Fix stop bug
|
|
120
|
+
- iOS: Fixed parsing of quality strings
|
|
121
|
+
|
|
122
|
+
## 1.0.0 - 2016-06-25
|
|
123
|
+
|
|
124
|
+
Initial release.
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
[2.0.3]: https://github.com/react-native-community/react-native-audio-toolkit/compare/f51bac3ee751e72f916abb657c2f594e870a36ac...HEAD
|
|
128
|
+
[2.0.2]: https://github.com/react-native-community/react-native-audio-toolkit/compare/caa399431afdcb70a2aa73fe436cdf00e3ea92d0...f51bac3ee751e72f916abb657c2f594e870a36ac
|
|
129
|
+
[2.0.1]: https://github.com/react-native-community/react-native-audio-toolkit/commit/caa399431afdcb70a2aa73fe436cdf00e3ea92d0
|
|
130
|
+
[2.0.0]: https://github.com/react-native-community/react-native-audio-toolkit/compare/dc2f04a35f388016aa294bcc80e7f553d1988037...ed89597b2e319c9073f2156c81c48c7ff8a7993f
|
|
131
|
+
[1.0.6]: https://github.com/react-native-community/react-native-audio-toolkit/compare/4746870166fe4beb9fbf075d45fab952de4558d6...dc2f04a35f388016aa294bcc80e7f553d1988037
|
|
132
|
+
[1.0.5]: https://github.com/react-native-community/react-native-audio-toolkit/compare/6a2641ebc6b6177fa29ac81b694ea2dd64d5a2cd...4746870166fe4beb9fbf075d45fab952de4558d6
|
|
133
|
+
[1.0.4]: https://github.com/react-native-community/react-native-audio-toolkit/compare/eba2326941e9b2f4405e832ce5af0a85bf6817ef...6a2641ebc6b6177fa29ac81b694ea2dd64d5a2cd
|
|
134
|
+
[1.0.3]: https://github.com/react-native-community/react-native-audio-toolkit/compare/24dc361c950c2f4a919d557c4b2c7abecb28c6e8...eba2326941e9b2f4405e832ce5af0a85bf6817ef
|
|
135
|
+
[1.0.2]: https://github.com/react-native-community/react-native-audio-toolkit/compare/3384ceff8bdf34904b09abb34602f8f4120bcb9e...24dc361c950c2f4a919d557c4b2c7abecb28c6e8
|
|
136
|
+
[1.0.1]: https://github.com/react-native-community/react-native-audio-toolkit/compare/05523e1181ee0a8d41d0e4db9f192d2d48be2bb4...3384ceff8bdf34904b09abb34602f8f4120bcb9e
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016-2019 Futurice
|
|
4
|
+
Copyright (c) 2019+ React Native Community.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +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
|
+
|
|
17
|
+
本项目基于 [The MIT License (MIT)](hhttps://github.com/react-native-audio-toolkit/react-native-audio-toolkit/blob/master/LICENSE) ,请自由地享受和参与开源。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
# NPM package specification
|
|
4
|
+
package = JSON.parse(File.read(File.join(File.dirname(__FILE__), "package.json")))
|
|
5
|
+
|
|
6
|
+
Pod::Spec.new do |s|
|
|
7
|
+
s.name = "ReactNativeAudioToolkit"
|
|
8
|
+
s.version = package["version"]
|
|
9
|
+
s.summary = package["description"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = "MIT"
|
|
12
|
+
s.author = { "Rasmus Eskola" => "fruitiex@gmail.com" }
|
|
13
|
+
s.platforms = { :ios => "9.0", :tvos => "9.0" }
|
|
14
|
+
s.source = { :git => package["repository"]["url"], :tag => "v#{s.version}" }
|
|
15
|
+
s.source_files = "ios/**/*.{h,m}"
|
|
16
|
+
|
|
17
|
+
s.dependency "React"
|
|
18
|
+
end
|
package/banner.png
ADDED
|
Binary file
|
|
@@ -0,0 +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.3-0.0.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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-present, Facebook, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
OPEN SOURCE SOFTWARE NOTICE
|
|
2
|
+
|
|
3
|
+
Please note we provide an open source software notice for the third party open source software along with this software and/or this software component (in the following just “this SOFTWARE”). The open source software licenses are granted by the respective right holders.
|
|
4
|
+
|
|
5
|
+
Warranty Disclaimer
|
|
6
|
+
THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
|
|
7
|
+
|
|
8
|
+
Copyright Notice and License Texts
|
|
9
|
+
|
|
10
|
+
----------------------------------------------------------------------
|
|
11
|
+
Software: @react-native-clipboard/clipboard V1.12.1
|
|
12
|
+
|
|
13
|
+
MIT License
|
|
14
|
+
|
|
15
|
+
Copyright (c) 2015-present, Facebook, Inc.
|
|
16
|
+
|
|
17
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
in the Software without restriction, including without limitation the rights
|
|
20
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
furnished to do so, subject to the following conditions:
|
|
23
|
+
|
|
24
|
+
The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
copies or substantial portions of the Software.
|
|
26
|
+
|
|
27
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
SOFTWARE.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<configuration>
|
|
3
|
+
<oatconfig>
|
|
4
|
+
<licensefile>LICENSE</licensefile>
|
|
5
|
+
<filefilterlist>
|
|
6
|
+
<filefilter name="copyrightPolicyFilter" desc="Filters for compatibility,license header policies">
|
|
7
|
+
<filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加版权头"/>
|
|
8
|
+
<filteritem type="filename" name="*.json5" desc="hvigor工程配置文件,DevEco Studio自动生成,不需要添加版权头"/>
|
|
9
|
+
<filteritem type="filename" name="*.proto" desc="资源文件,不需要添加版权头"/>
|
|
10
|
+
<filteritem type="filename" name="*.json" desc="资源文件,不需要添加版权头"/>
|
|
11
|
+
<filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
12
|
+
<filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
13
|
+
<filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
14
|
+
<filteritem type="filename" name="LICENSE" desc="工程文件,不修改版权头"/>
|
|
15
|
+
</filefilter>
|
|
16
|
+
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
|
17
|
+
<filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加许可证头"/>
|
|
18
|
+
<filteritem type="filename" name="*.json5" desc="hvigor工程配置文件,DevEco Studio自动生成,不需要添加许可证头"/>
|
|
19
|
+
<filteritem type="filename" name="LICENSE" desc="原三方库证书文件无需更改,因此添加过滤"/>
|
|
20
|
+
<filteritem type="filename" name="*.proto" desc="资源文件,不需要添加许可证头"/>
|
|
21
|
+
<filteritem type="filename" name="*.json" desc="资源文件,不需要添加许可证头"/>
|
|
22
|
+
<filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
23
|
+
<filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
24
|
+
<filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
25
|
+
</filefilter>
|
|
26
|
+
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for resources files policies">
|
|
27
|
+
<filteritem type="filename" name="icon.png" desc="应用图标"/>
|
|
28
|
+
<filteritem type="filename" name="app_icon.png" desc="应用图标"/>
|
|
29
|
+
<filteritem type="filename" name="warn.png" desc="页面展示图标"/>
|
|
30
|
+
</filefilter>
|
|
31
|
+
</filefilterlist>
|
|
32
|
+
<policylist>
|
|
33
|
+
<policy name="projectPolicy" desc="">
|
|
34
|
+
<policyitem type="license" name="MIT" path="*.*" desc="license under the MIT"/>
|
|
35
|
+
</policy>
|
|
36
|
+
</policylist>
|
|
37
|
+
</oatconfig>
|
|
38
|
+
</configuration>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"Name": "@react-native-clipboard/clipboard",
|
|
4
|
+
"License": "MIT License",
|
|
5
|
+
"License File": "https://github.com/react-native-clipboard/clipboard/blob/master/LICENSE",
|
|
6
|
+
"Version Number": "1.12.1",
|
|
7
|
+
"Owner" : "M.Haris Baig <harisbaig100@gmail.com>"
|
|
8
|
+
"Upstream URL": "https://github.com/react-native-clipboard/clipboard",
|
|
9
|
+
"Description": "React Native Clipboard API for macOS, iOS, Android, and Windows."
|
|
10
|
+
}
|
|
11
|
+
]
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
> 模板版本:v0.0.2
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
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>
|
|
14
|
+
|
|
15
|
+
## 安装与使用
|
|
16
|
+
|
|
17
|
+
> [!tip] 目前部分 React-Native-OpenHarmony(RNOH) 三方库的 npm 包部署在私仓,需要通过 github token 来获取访问权限。
|
|
18
|
+
|
|
19
|
+
在与 `package.json` 文件相同的目录中,创建或编辑 `.npmrc` 文件以包含指定 GitHub Packages URL 和托管包的命名空间的行。 将 TOKEN 替换为 RNOH 三方库指定的 token。
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
@react-native-oh-library:registry=https://npm.pkg.github.com
|
|
23
|
+
//npm.pkg.github.com/:_authToken=TOKEN
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
进入到工程目录并输入以下命令:
|
|
27
|
+
|
|
28
|
+
<!-- tabs:start -->
|
|
29
|
+
|
|
30
|
+
#### **yarn**
|
|
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) ,请自由地享受和参与开源。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { harTasks } from '@ohos/hvigor-ohos-plugin';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export * from './ts'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"license": "ISC",
|
|
3
|
+
"types": "",
|
|
4
|
+
"devDependencies": {},
|
|
5
|
+
"name": "@react-native-ohos/audio-toolkit",
|
|
6
|
+
"version": "2.0.4-rc.1",
|
|
7
|
+
"description": "",
|
|
8
|
+
"main": "index.ets",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@rnoh/react-native-openharmony": "file:../libs/react_native_openharmony-5.0.0.490.har"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
|
|
26
|
+
import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
|
27
|
+
import { RCTAudioPlayerTurboModule } from './RNCAudioPlayerTurboModule';
|
|
28
|
+
import { RCTAudioRecorderTurboModule } from './RNCAudioRecorderTurboModule';
|
|
29
|
+
export const AUDIO_TYPE: string = 'RCTAudioPlayer1';
|
|
30
|
+
|
|
31
|
+
class AudioPlayer1TurboModulesFactory extends TurboModulesFactory {
|
|
32
|
+
createTurboModule(name: string): TurboModule | null {
|
|
33
|
+
if (name === 'RCTAudioPlayer') {
|
|
34
|
+
return new RCTAudioPlayerTurboModule(this.ctx);
|
|
35
|
+
}
|
|
36
|
+
if (name === 'RCTAudioRecorder') {
|
|
37
|
+
return new RCTAudioRecorderTurboModule(this.ctx);
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
hasTurboModule(name: string): boolean {
|
|
43
|
+
return name === 'RCTAudioPlayer' || name === 'RCTAudioRecorder';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class AudioModulesPackage extends RNPackage {
|
|
48
|
+
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
|
|
49
|
+
return new AudioPlayer1TurboModulesFactory(ctx);
|
|
50
|
+
}
|
|
51
|
+
}
|