@react-native-ohos/audio-toolkit 2.0.4-rc.3 → 2.1.0-rc.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.
- package/CHANGELOG.md +6 -2
- package/COMMITTERS.md +7 -0
- package/README.md +13 -7
- package/harmony/audio_toolkit/BuildProfile.ets +17 -0
- package/harmony/audio_toolkit/LICENSE +21 -0
- package/harmony/audio_toolkit/NOTICE +33 -0
- package/{OAT.xml → harmony/audio_toolkit/OAT.xml} +0 -10
- package/harmony/audio_toolkit/README.OpenSource +11 -0
- package/harmony/audio_toolkit/README.md +17 -0
- package/harmony/audio_toolkit/index.ets +2 -3
- package/harmony/audio_toolkit/oh-package.json5 +1 -1
- package/harmony/audio_toolkit/src/main/cpp/AudioToolkitPackage.h +13 -9
- package/harmony/audio_toolkit/src/main/cpp/CMakeLists.txt +2 -3
- package/harmony/audio_toolkit/src/main/cpp/generated/RNOH/generated/{BaseReactNativeAudioToolkitPackage.h → BaseAudioToolkitPackage.h} +14 -7
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/{react_native_audio_toolkit → audio_toolkit}/ComponentDescriptors.h +7 -5
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/{react_native_audio_toolkit → audio_toolkit}/EventEmitters.cpp +3 -5
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/{react_native_audio_toolkit → audio_toolkit}/EventEmitters.h +2 -4
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/{react_native_audio_toolkit → audio_toolkit}/Props.cpp +3 -5
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/{react_native_audio_toolkit → audio_toolkit}/Props.h +2 -4
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/{react_native_audio_toolkit → audio_toolkit}/ShadowNodes.cpp +3 -5
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/{react_native_audio_toolkit → audio_toolkit}/ShadowNodes.h +5 -7
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/{react_native_audio_toolkit → audio_toolkit}/States.cpp +3 -5
- package/harmony/audio_toolkit/src/main/cpp/generated/react/renderer/components/{react_native_audio_toolkit → audio_toolkit}/States.h +2 -6
- package/harmony/audio_toolkit/src/main/ets/{AudioToolkitPackage.ets → AudioToolkitPackage.ts} +1 -2
- package/harmony/audio_toolkit/src/main/ets/RNCAudioPlayerTurboModule.ts +91 -5
- package/harmony/audio_toolkit/src/main/ets/generated/turboModules/RCTAudioPlayer.ts +2 -2
- package/harmony/audio_toolkit.har +0 -0
- package/package.json +10 -11
- /package/harmony/audio_toolkit/{ts.ets → ts.ts} +0 -0
package/CHANGELOG.md
CHANGED
package/COMMITTERS.md
ADDED
package/README.md
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
# @react-native-ohos/audio-toolkit
|
|
1
|
+
# @react-native-ohos/react-native-audio-toolkit
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
## Documentation
|
|
3
|
+
本项目基于 [react-native-audio-toolkit@2.0.3](https://github.com/react-native-audio-toolkit/react-native-audio-toolkit/tree/v2.0.3)
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
[English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-audio-toolkit.md)
|
|
5
|
+
## 文档地址 / Documentation URL
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
[中文 / Chinese](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-audio-toolkit.md)
|
|
10
8
|
|
|
11
|
-
|
|
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,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.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
|
+
}
|
|
@@ -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.
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
<filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
13
13
|
<filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
14
14
|
<filteritem type="filename" name="LICENSE" desc="工程文件,不修改版权头"/>
|
|
15
|
-
<filteritem type="filepath" name="src/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
|
|
16
15
|
</filefilter>
|
|
17
16
|
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
|
18
17
|
<filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加许可证头"/>
|
|
@@ -23,26 +22,17 @@
|
|
|
23
22
|
<filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
24
23
|
<filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
25
24
|
<filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
26
|
-
<filteritem type="filepath" name="src/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
|
|
27
25
|
</filefilter>
|
|
28
26
|
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for resources files policies">
|
|
29
27
|
<filteritem type="filename" name="icon.png" desc="应用图标"/>
|
|
30
28
|
<filteritem type="filename" name="app_icon.png" desc="应用图标"/>
|
|
31
29
|
<filteritem type="filename" name="warn.png" desc="页面展示图标"/>
|
|
32
|
-
<filteritem type="filepath" name="harmony/audio_toolkit.har" desc="项目打包文件"/>
|
|
33
30
|
</filefilter>
|
|
34
31
|
</filefilterlist>
|
|
35
32
|
<policylist>
|
|
36
33
|
<policy name="projectPolicy" desc="">
|
|
37
34
|
<policyitem type="license" name="MIT" path="*.*" desc="license under the MIT"/>
|
|
38
35
|
</policy>
|
|
39
|
-
<policy name="projectPolicy" desc="">
|
|
40
|
-
<policyitem type="compatibility" name="GPL-2.0+" path=".*" desc="Process that runs independently, invoked by the X process."/>
|
|
41
|
-
<policyitem type="compatibility" name="Apache-2.0" path=".*" desc="不影响兼容性"/>
|
|
42
|
-
<policyitem type="compatibility" name="BSDStyleLicense" path=".*" desc="不影响兼容性" />
|
|
43
|
-
<policyitem type="compatibility" name="MIT" path=".*" desc="不影响兼容性" />
|
|
44
|
-
<policyitem type="compatibility" name="GPLStyleLicense" path=".*" desc="不影响兼容性" />
|
|
45
|
-
</policy>
|
|
46
36
|
</policylist>
|
|
47
37
|
</oatconfig>
|
|
48
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,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) ,请自由地享受和参与开源。
|
|
@@ -21,6 +21,5 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
export * from './ts'
|
|
26
|
-
export default AudioToolkitPackage;
|
|
24
|
+
|
|
25
|
+
export * from './ts'
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* found in the LICENSE file
|
|
5
|
-
*/
|
|
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.
|
|
6
4
|
|
|
7
|
-
#
|
|
5
|
+
#ifndef AUDIOTOOLKITPACKAGE_H
|
|
6
|
+
#define AUDIOTOOLKITPACKAGE_H
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#include "generated/RNOH/generated/BaseAudioToolkitPackage.h"
|
|
8
10
|
#pragma once
|
|
9
11
|
|
|
12
|
+
|
|
10
13
|
namespace rnoh {
|
|
11
|
-
class AudioToolkitPackage : public
|
|
12
|
-
using Super =
|
|
14
|
+
class AudioToolkitPackage : public BaseAudioToolkitPackage {
|
|
15
|
+
using Super = BaseAudioToolkitPackage;
|
|
13
16
|
using Super::Super;
|
|
14
17
|
};
|
|
15
|
-
} // namespace rnoh
|
|
18
|
+
} // namespace rnoh
|
|
19
|
+
#endif //AUDIOTOOLKITPACKAGE_H
|
|
@@ -2,9 +2,8 @@ cmake_minimum_required(VERSION 3.13)
|
|
|
2
2
|
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
3
3
|
|
|
4
4
|
set(rnoh_audio_toolkit_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated")
|
|
5
|
-
|
|
6
5
|
file(GLOB_RECURSE rnoh_audio_toolkit_generated_SRC "${rnoh_audio_toolkit_generated_dir}/**/*.cpp")
|
|
7
6
|
file(GLOB rnoh_audio_toolkit_SRC CONFIGURE_DEPENDS *.cpp)
|
|
8
7
|
add_library(rnoh_audio_toolkit SHARED ${rnoh_audio_toolkit_SRC} ${rnoh_audio_toolkit_generated_SRC})
|
|
9
|
-
target_include_directories(rnoh_audio_toolkit PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_audio_toolkit_generated_dir})
|
|
10
|
-
target_link_libraries(rnoh_audio_toolkit PUBLIC rnoh)
|
|
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)
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
namespace rnoh {
|
|
13
13
|
|
|
14
|
-
class
|
|
14
|
+
class BaseAudioToolkitPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
|
|
15
15
|
public:
|
|
16
16
|
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
|
|
17
17
|
if (name == "RCTAudioPlayer") {
|
|
@@ -24,29 +24,36 @@ class BaseReactNativeAudioToolkitPackageTurboModuleFactoryDelegate : public Turb
|
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
class
|
|
27
|
+
class BaseAudioToolkitPackageEventEmitRequestHandler : public EventEmitRequestHandler {
|
|
28
28
|
public:
|
|
29
29
|
void handleEvent(Context const &ctx) override {
|
|
30
30
|
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
|
|
31
|
+
auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
|
|
32
|
+
|
|
31
33
|
if (eventEmitter == nullptr) {
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
std::vector<std::string> supportedComponentNames = {
|
|
38
|
+
};
|
|
39
|
+
|
|
35
40
|
std::vector<std::string> supportedEventNames = {
|
|
36
41
|
};
|
|
37
|
-
|
|
42
|
+
|
|
43
|
+
if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
|
|
44
|
+
std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
|
|
38
45
|
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
};
|
|
42
49
|
|
|
43
50
|
|
|
44
|
-
class
|
|
51
|
+
class BaseAudioToolkitPackage : public Package {
|
|
45
52
|
public:
|
|
46
|
-
|
|
53
|
+
BaseAudioToolkitPackage(Package::Context ctx) : Package(ctx){};
|
|
47
54
|
|
|
48
55
|
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
|
|
49
|
-
return std::make_unique<
|
|
56
|
+
return std::make_unique<BaseAudioToolkitPackageTurboModuleFactoryDelegate>();
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
|
|
@@ -61,7 +68,7 @@ class BaseReactNativeAudioToolkitPackage : public Package {
|
|
|
61
68
|
|
|
62
69
|
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
|
|
63
70
|
return {
|
|
64
|
-
std::make_shared<
|
|
71
|
+
std::make_shared<BaseAudioToolkitPackageEventEmitRequestHandler>(),
|
|
65
72
|
};
|
|
66
73
|
}
|
|
67
74
|
};
|
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
|
|
11
11
|
#pragma once
|
|
12
12
|
|
|
13
|
-
#include
|
|
13
|
+
#include "ShadowNodes.h"
|
|
14
14
|
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
15
16
|
|
|
16
|
-
namespace facebook {
|
|
17
|
-
namespace react {
|
|
17
|
+
namespace facebook::react {
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
void audio_toolkit_registerComponentDescriptorsFromCodegen(
|
|
22
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
|
|
23
|
+
|
|
24
|
+
} // namespace facebook::react
|
|
@@ -8,11 +8,9 @@
|
|
|
8
8
|
* @generated by codegen project: GenerateEventEmitterCpp.js
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
#include
|
|
11
|
+
#include "EventEmitters.h"
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
namespace facebook {
|
|
15
|
-
namespace react {
|
|
14
|
+
namespace facebook::react {
|
|
16
15
|
|
|
17
|
-
} // namespace react
|
|
18
|
-
} // namespace facebook
|
|
16
|
+
} // namespace facebook::react
|
|
@@ -8,14 +8,12 @@
|
|
|
8
8
|
* @generated by codegen project: GeneratePropsCpp.js
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
#include
|
|
11
|
+
#include "Props.h"
|
|
12
12
|
#include <react/renderer/core/PropsParserContext.h>
|
|
13
13
|
#include <react/renderer/core/propsConversions.h>
|
|
14
14
|
|
|
15
|
-
namespace facebook {
|
|
16
|
-
namespace react {
|
|
15
|
+
namespace facebook::react {
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
|
|
20
|
-
} // namespace react
|
|
21
|
-
} // namespace facebook
|
|
19
|
+
} // namespace facebook::react
|
|
@@ -8,12 +8,10 @@
|
|
|
8
8
|
* @generated by codegen project: GenerateShadowNodeCpp.js
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
#include
|
|
11
|
+
#include "ShadowNodes.h"
|
|
12
12
|
|
|
13
|
-
namespace facebook {
|
|
14
|
-
namespace react {
|
|
13
|
+
namespace facebook::react {
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
|
|
18
|
-
} // namespace react
|
|
19
|
-
} // namespace facebook
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -10,16 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
#pragma once
|
|
12
12
|
|
|
13
|
-
#include
|
|
14
|
-
#include
|
|
15
|
-
#include
|
|
13
|
+
#include "EventEmitters.h"
|
|
14
|
+
#include "Props.h"
|
|
15
|
+
#include "States.h"
|
|
16
16
|
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
17
|
#include <jsi/jsi.h>
|
|
18
18
|
|
|
19
|
-
namespace facebook {
|
|
20
|
-
namespace react {
|
|
19
|
+
namespace facebook::react {
|
|
21
20
|
|
|
22
21
|
|
|
23
22
|
|
|
24
|
-
} // namespace react
|
|
25
|
-
} // namespace facebook
|
|
23
|
+
} // namespace facebook::react
|
|
@@ -7,12 +7,10 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @generated by codegen project: GenerateStateCpp.js
|
|
9
9
|
*/
|
|
10
|
-
#include
|
|
10
|
+
#include "States.h"
|
|
11
11
|
|
|
12
|
-
namespace facebook {
|
|
13
|
-
namespace react {
|
|
12
|
+
namespace facebook::react {
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
|
|
17
|
-
} // namespace react
|
|
18
|
-
} // namespace facebook
|
|
16
|
+
} // namespace facebook::react
|
|
@@ -10,14 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
#ifdef ANDROID
|
|
12
12
|
#include <folly/dynamic.h>
|
|
13
|
-
#include <react/renderer/mapbuffer/MapBuffer.h>
|
|
14
|
-
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
|
|
15
13
|
#endif
|
|
16
14
|
|
|
17
|
-
namespace facebook {
|
|
18
|
-
namespace react {
|
|
15
|
+
namespace facebook::react {
|
|
19
16
|
|
|
20
17
|
|
|
21
18
|
|
|
22
|
-
} // namespace react
|
|
23
|
-
} // namespace facebook
|
|
19
|
+
} // namespace facebook::react
|
package/harmony/audio_toolkit/src/main/ets/{AudioToolkitPackage.ets → AudioToolkitPackage.ts}
RENAMED
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
|
|
26
|
-
import { RNOHPackage } from '@rnoh/react-native-openharmony'
|
|
27
26
|
import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
|
28
27
|
import { RCTAudioPlayerTurboModule } from './RNCAudioPlayerTurboModule';
|
|
29
28
|
import { RCTAudioRecorderTurboModule } from './RNCAudioRecorderTurboModule';
|
|
@@ -45,7 +44,7 @@ class AudioPlayer1TurboModulesFactory extends TurboModulesFactory {
|
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
export class AudioModulesPackage extends
|
|
47
|
+
export class AudioModulesPackage extends RNPackage {
|
|
49
48
|
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
|
|
50
49
|
return new AudioPlayer1TurboModulesFactory(ctx);
|
|
51
50
|
}
|
|
@@ -27,6 +27,10 @@ import { type BusinessError } from '@ohos.base';
|
|
|
27
27
|
import media from '@ohos.multimedia.media';
|
|
28
28
|
import fs from '@ohos.file.fs';
|
|
29
29
|
import logger from './Logger';
|
|
30
|
+
import { audio } from '@kit.AudioKit';
|
|
31
|
+
|
|
32
|
+
// Continuous background audio task is managed by the app's EntryAbility.
|
|
33
|
+
import avsession from '@ohos.multimedia.avsession';
|
|
30
34
|
|
|
31
35
|
interface PlayConfig {
|
|
32
36
|
volume?: number;
|
|
@@ -67,6 +71,17 @@ enum StateChange {
|
|
|
67
71
|
RELEASED = 'released',
|
|
68
72
|
}
|
|
69
73
|
|
|
74
|
+
type BackgroundAudioTaskBridge = {
|
|
75
|
+
startAudioPlayback?: () => Promise<void>;
|
|
76
|
+
stopAudioPlayback?: () => Promise<void>;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const AUDIO_BG_BRIDGE_KEY: string = '__rnohAudioBackgroundTask';
|
|
80
|
+
|
|
81
|
+
function getBackgroundAudioTaskBridge(): BackgroundAudioTaskBridge | undefined {
|
|
82
|
+
return Reflect.get(globalThis, AUDIO_BG_BRIDGE_KEY) as BackgroundAudioTaskBridge | undefined;
|
|
83
|
+
}
|
|
84
|
+
|
|
70
85
|
export class RCTAudioPlayerTurboModule extends TurboModule {
|
|
71
86
|
private readonly SANDBOX_START = '/data/storage';
|
|
72
87
|
private readonly FILE_MANAGER_START = 'file://';
|
|
@@ -76,6 +91,8 @@ export class RCTAudioPlayerTurboModule extends TurboModule {
|
|
|
76
91
|
private playConfigMap: Map<number, PlayConfig> = new Map();
|
|
77
92
|
private playInfoMap: Map<number, PlayInfo> = new Map();
|
|
78
93
|
private playSeekCallbacks: Map<number, (err: string | Error, result?: PlayInfo) => void> = new Map();
|
|
94
|
+
private session!: avsession.AVSession;
|
|
95
|
+
private init: boolean = false;
|
|
79
96
|
|
|
80
97
|
constructor(protected ctx: TurboModuleContext) {
|
|
81
98
|
super(ctx);
|
|
@@ -135,10 +152,10 @@ export class RCTAudioPlayerTurboModule extends TurboModule {
|
|
|
135
152
|
}
|
|
136
153
|
|
|
137
154
|
onBackground(): void {
|
|
138
|
-
this.ctx.rnInstance.subscribeToLifecycleEvents('BACKGROUND', () => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
});
|
|
155
|
+
// this.ctx.rnInstance.subscribeToLifecycleEvents('BACKGROUND', () => {
|
|
156
|
+
// logger.debug(`app state is BACKGROUND`);
|
|
157
|
+
// this.pauseOnBackground();
|
|
158
|
+
// });
|
|
142
159
|
}
|
|
143
160
|
|
|
144
161
|
pauseOnBackground(): void {
|
|
@@ -213,7 +230,7 @@ export class RCTAudioPlayerTurboModule extends TurboModule {
|
|
|
213
230
|
}
|
|
214
231
|
});
|
|
215
232
|
avPlayer.on('audioInterrupt', (reason) => {
|
|
216
|
-
logger.debug(`audioInterrupt start:${JSON.stringify(reason)}`);
|
|
233
|
+
logger.debug(`MMMMM audioInterrupt start:${JSON.stringify(reason)}`);
|
|
217
234
|
this.toEmit(playerId, 'forcePause', {
|
|
218
235
|
message: 'lost audio focus, playback paused',
|
|
219
236
|
});
|
|
@@ -240,6 +257,10 @@ export class RCTAudioPlayerTurboModule extends TurboModule {
|
|
|
240
257
|
avPlayer.release(); // 调用release接口销毁实例对象
|
|
241
258
|
break;
|
|
242
259
|
case StateChange.INITIALIZED: // avplayer 设置播放源后触发该状态上报
|
|
260
|
+
avPlayer.audioRendererInfo = {
|
|
261
|
+
usage: audio.StreamUsage.STREAM_USAGE_MUSIC,
|
|
262
|
+
rendererFlags: 0,
|
|
263
|
+
}
|
|
243
264
|
avPlayer.prepare();
|
|
244
265
|
break;
|
|
245
266
|
case StateChange.PREPARED: // prepare调用成功后上报该状态机
|
|
@@ -276,8 +297,63 @@ export class RCTAudioPlayerTurboModule extends TurboModule {
|
|
|
276
297
|
});
|
|
277
298
|
}
|
|
278
299
|
|
|
300
|
+
async startContinuousTask() {
|
|
301
|
+
const bridge: BackgroundAudioTaskBridge | undefined = getBackgroundAudioTaskBridge();
|
|
302
|
+
if (!bridge?.startAudioPlayback) {
|
|
303
|
+
logger.warn('Background audio task bridge not initialized (EntryAbility)');
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
await bridge.startAudioPlayback();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
OnContinuousTaskCancel() {
|
|
310
|
+
// Kept for backward compatibility; cancellation is handled in EntryAbility.
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
OffContinuousTaskCancel() {
|
|
315
|
+
// Kept for backward compatibility.
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async stopContinuousTask(): Promise<void> {
|
|
320
|
+
const bridge: BackgroundAudioTaskBridge | undefined = getBackgroundAudioTaskBridge();
|
|
321
|
+
if (!bridge?.stopAudioPlayback) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
await bridge.stopAudioPlayback();
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async initFun() {
|
|
328
|
+
if (this.init) {
|
|
329
|
+
return
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
avsession.createAVSession(this.ctx.uiAbilityContext, 'MMMMM_SESSION_NAME', 'audio').then(async (data: avsession.AVSession) => {
|
|
333
|
+
this.session = data;
|
|
334
|
+
this.session.activate()
|
|
335
|
+
console.info(`MMMMMM CreateAVSession : SUCCESS : sessionId = ${this.session.sessionId}`);
|
|
336
|
+
|
|
337
|
+
let metadata: avsession.AVMetadata = {
|
|
338
|
+
assetId: '0', // 由应用指定,用于标识应用媒体库里的媒体。
|
|
339
|
+
title: 'TITLE',
|
|
340
|
+
mediaImage: 'IMAGE',
|
|
341
|
+
artist: 'ARTIST',
|
|
342
|
+
};
|
|
343
|
+
this.session.setAVMetadata(metadata).then(() => {
|
|
344
|
+
console.info(`MMMMMM SetAVMetadata successfully`);
|
|
345
|
+
}).catch((err: BusinessError) => {
|
|
346
|
+
console.error(`MMMMMM Failed to set AVMetadata. Code: ${err.code}, message: ${err.message}`);
|
|
347
|
+
});
|
|
348
|
+
}).catch((err: BusinessError) => {
|
|
349
|
+
console.error(`MMMMMM CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
|
|
350
|
+
});
|
|
351
|
+
this.init = true;
|
|
352
|
+
}
|
|
353
|
+
|
|
279
354
|
async createPlayer(pathStr: string, playerId: number, next: (object?) => void): Promise<void> {
|
|
280
355
|
logger.debug(`createPlayer path:${pathStr}`);
|
|
356
|
+
this.initFun();
|
|
281
357
|
try {
|
|
282
358
|
const avPlayer: media.AVPlayer = await media.createAVPlayer();
|
|
283
359
|
this.setAVPlayerCallback(avPlayer, playerId, next);
|
|
@@ -346,6 +422,13 @@ export class RCTAudioPlayerTurboModule extends TurboModule {
|
|
|
346
422
|
}
|
|
347
423
|
const player = this.getPlayer(playerId);
|
|
348
424
|
await player.play();
|
|
425
|
+
|
|
426
|
+
this.startContinuousTask();
|
|
427
|
+
let playbackState: avsession.AVPlaybackState = {
|
|
428
|
+
state: avsession.PlaybackState.PLAYBACK_STATE_PLAY,
|
|
429
|
+
};
|
|
430
|
+
await this.session.setAVPlaybackState(playbackState);
|
|
431
|
+
|
|
349
432
|
callback(null, this.getInfo(playerId));
|
|
350
433
|
} catch (e) {
|
|
351
434
|
let err: Error = {
|
|
@@ -363,6 +446,7 @@ export class RCTAudioPlayerTurboModule extends TurboModule {
|
|
|
363
446
|
}
|
|
364
447
|
const player = this.getPlayer(playerId);
|
|
365
448
|
await player.pause();
|
|
449
|
+
await this.stopContinuousTask();
|
|
366
450
|
this.toEmit(playerId, 'pause', {
|
|
367
451
|
message: 'player paused',
|
|
368
452
|
});
|
|
@@ -378,6 +462,7 @@ export class RCTAudioPlayerTurboModule extends TurboModule {
|
|
|
378
462
|
const player = this.getPlayer(playerId);
|
|
379
463
|
if (config?.autoDestroy) {
|
|
380
464
|
await player.pause();
|
|
465
|
+
await this.stopContinuousTask();
|
|
381
466
|
this.destroy(playerId);
|
|
382
467
|
callback();
|
|
383
468
|
} else {
|
|
@@ -393,6 +478,7 @@ export class RCTAudioPlayerTurboModule extends TurboModule {
|
|
|
393
478
|
this.playSeekCallbacks.set(playerId, callback);
|
|
394
479
|
player.seek(0);
|
|
395
480
|
await player.pause();
|
|
481
|
+
await this.stopContinuousTask();
|
|
396
482
|
}
|
|
397
483
|
}
|
|
398
484
|
|
|
@@ -13,12 +13,12 @@ export namespace RCTAudioPlayer {
|
|
|
13
13
|
SoloAmbient = 3,
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export type setOptions = {volume: string, pan: string, wakeLock: string, looping: boolean, speed: boolean}
|
|
17
|
-
|
|
18
16
|
export type Option = {autoDestroy: boolean, continuesToPlayInBackground: boolean, category: PlaybackCategories, mixWithOthers: boolean}
|
|
19
17
|
|
|
20
18
|
export type PlayInfo = {duration: number, position: number}
|
|
21
19
|
|
|
20
|
+
export type setOptions = {volume: string, pan: string, wakeLock: string, looping: boolean, speed: boolean}
|
|
21
|
+
|
|
22
22
|
export interface Spec {
|
|
23
23
|
set(playerId: number, option: setOptions, next: () => void): void;
|
|
24
24
|
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-ohos/audio-toolkit",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0-rc.2",
|
|
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
|
-
"autolinking": {
|
|
10
|
-
"etsPackageClassName":"AudioToolkitPackage",
|
|
11
|
-
"cppPackageClassName":"AudioToolkitPackage",
|
|
12
|
-
"cmakeLibraryTargetName": "rnoh_audio_toolkit",
|
|
13
|
-
"ohPackageName": "@react-native-ohos/audio-toolkit"
|
|
14
|
-
}
|
|
8
|
+
"alias": "@react-native-community/audio-toolkit"
|
|
15
9
|
},
|
|
16
10
|
"directories": {
|
|
17
11
|
"doc": "docs"
|
|
18
12
|
},
|
|
19
13
|
"scripts": {
|
|
20
14
|
"start": "react-native start",
|
|
21
|
-
"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
|
|
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"
|
|
22
16
|
},
|
|
23
|
-
"homepage": "https://gitcode.com/openharmony-sig/rntpc_react-native-audio-toolkit",
|
|
17
|
+
"homepage": "https://gitcode.com/openharmony-sig/rntpc_react-native-audio-toolkit#readme",
|
|
24
18
|
"license": "MIT",
|
|
25
19
|
"repository": {
|
|
26
20
|
"type": "git",
|
|
@@ -40,10 +34,15 @@
|
|
|
40
34
|
"react native",
|
|
41
35
|
"audio",
|
|
42
36
|
"audio toolkit",
|
|
43
|
-
"audio-toolkit"
|
|
37
|
+
"audio-toolkit",
|
|
38
|
+
"harmony"
|
|
44
39
|
],
|
|
45
40
|
"publishConfig": {
|
|
46
41
|
"registry": "https://registry.npmjs.org/",
|
|
47
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"
|
|
48
47
|
}
|
|
49
48
|
}
|
|
File without changes
|