expo-nodemediaclient 0.1.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/.eslintrc.js +5 -0
- package/CHANGELOG.md +2 -0
- package/LICENSE +201 -0
- package/README.md +106 -0
- package/android/build.gradle +46 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/nodemediaclient/ExpoNodeMediaClientModule.kt +23 -0
- package/android/src/main/java/expo/modules/nodemediaclient/ExpoNodePlayerModule.kt +60 -0
- package/android/src/main/java/expo/modules/nodemediaclient/ExpoNodePlayerView.kt +107 -0
- package/build/ExpoNodeMediaClientModule.d.ts +7 -0
- package/build/ExpoNodeMediaClientModule.d.ts.map +1 -0
- package/build/ExpoNodeMediaClientModule.js +9 -0
- package/build/ExpoNodeMediaClientModule.js.map +1 -0
- package/build/ExpoNodePlayerView.d.ts +20 -0
- package/build/ExpoNodePlayerView.d.ts.map +1 -0
- package/build/ExpoNodePlayerView.js +21 -0
- package/build/ExpoNodePlayerView.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +8 -0
- package/build/index.js.map +1 -0
- package/expo-module.config.json +15 -0
- package/ios/ExpoNodeMediaClientModule.swift +27 -0
- package/ios/ExpoNodePlayerModule.swift +58 -0
- package/ios/ExpoNodePlayerView.swift +88 -0
- package/ios/ExpoNodemediaclient.podspec +30 -0
- package/package.json +45 -0
- package/src/ExpoNodeMediaClientModule.tsx +15 -0
- package/src/ExpoNodePlayerView.tsx +45 -0
- package/src/index.ts +8 -0
- package/tsconfig.json +9 -0
package/.eslintrc.js
ADDED
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# expo-nodemediaclient
|
|
2
|
+
|
|
3
|
+
## 特性
|
|
4
|
+
- 支持iOS与Android
|
|
5
|
+
- 支持RTMP、HLS、HTTP-FLV、RTSP播放
|
|
6
|
+
- 支持H.264、H.265视频编码
|
|
7
|
+
- 支持AAC、PCM音频编码
|
|
8
|
+
- 支持硬件加速
|
|
9
|
+
- 支持低延迟播放,累积延迟消除
|
|
10
|
+
|
|
11
|
+
## 前提
|
|
12
|
+
你的Expo项目应该是使用持续的原生生成 [(CNG)](https://docs.expo.dev/workflow/continuous-native-generation/)
|
|
13
|
+
如果不是请先执行
|
|
14
|
+
```bash
|
|
15
|
+
npx expo prebuild
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install expo-nodemediaclient
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 使用
|
|
25
|
+
### 注册SDK
|
|
26
|
+
android与iOS注册码不同,需要分别注册,注册码请联系[https://www.nodemedia.cn](https://www.nodemedia.cn)获取
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { NodeMediaClient } from 'expo-nodemediaclient';
|
|
30
|
+
import { Platform } from 'react-native';
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if (Platform.OS === 'ios') {
|
|
34
|
+
NodeMediaClient.setLicense('');
|
|
35
|
+
} else if (Platform.OS === 'android') {
|
|
36
|
+
NodeMediaClient.setLicense('');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 播放
|
|
42
|
+
```js
|
|
43
|
+
import { NodePlayer, NodePlayerRef } from 'expo-nodemediaclient';
|
|
44
|
+
import { useRef, useState } from 'react';
|
|
45
|
+
|
|
46
|
+
export default function App() {
|
|
47
|
+
const [url, setUrl] = useState('rtmp://192.168.0.2/live/bbb');
|
|
48
|
+
const playerRef = useRef<NodePlayerRef>(null);
|
|
49
|
+
return (
|
|
50
|
+
<SafeAreaView style={{ flex: 1 }}>
|
|
51
|
+
<NodePlayer
|
|
52
|
+
ref={playerRef}
|
|
53
|
+
url={url}
|
|
54
|
+
bufferTime={1000}
|
|
55
|
+
scaleMode={1}
|
|
56
|
+
style={{ backgroundColor: '#000000', height: 300 }}
|
|
57
|
+
/>
|
|
58
|
+
<TextInput value={url} onChangeText={setUrl} />
|
|
59
|
+
<Button
|
|
60
|
+
title="Play"
|
|
61
|
+
onPress={() => {
|
|
62
|
+
playerRef.current?.start(url);
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
<Button
|
|
66
|
+
title="Stop"
|
|
67
|
+
onPress={() => {
|
|
68
|
+
playerRef.current?.stop();
|
|
69
|
+
}}
|
|
70
|
+
/>
|
|
71
|
+
</SafeAreaView>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 进入页面自动播放
|
|
78
|
+
```js
|
|
79
|
+
export default function App() {
|
|
80
|
+
const [url, setUrl] = useState('rtmp://192.168.0.2/live/bbb');
|
|
81
|
+
const [bufferTime, setBufferTime] = useState(0);
|
|
82
|
+
const [scaleMode, setScaleMode] = useState(2);
|
|
83
|
+
const playerRef = useRef<NodePlayerRef>(null);
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
playerRef.current?.start(url);
|
|
87
|
+
return () => {
|
|
88
|
+
playerRef.current?.stop();
|
|
89
|
+
};
|
|
90
|
+
}, []);
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<SafeAreaView style={{ flex: 1 }}>
|
|
94
|
+
<NodePlayer
|
|
95
|
+
ref={playerRef}
|
|
96
|
+
url={url}
|
|
97
|
+
bufferTime={bufferTime}
|
|
98
|
+
scaleMode={scaleMode}
|
|
99
|
+
style={{ backgroundColor: '#000000', height: 300 }}
|
|
100
|
+
/>
|
|
101
|
+
</SafeAreaView>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 推流
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
|
|
3
|
+
group = 'expo.modules.nodemediaclient'
|
|
4
|
+
version = '0.1.1'
|
|
5
|
+
|
|
6
|
+
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
|
+
apply from: expoModulesCorePlugin
|
|
8
|
+
applyKotlinExpoModulesCorePlugin()
|
|
9
|
+
useCoreDependencies()
|
|
10
|
+
useExpoPublishing()
|
|
11
|
+
|
|
12
|
+
// If you want to use the managed Android SDK versions from expo-modules-core, set this to true.
|
|
13
|
+
// The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code.
|
|
14
|
+
// Most of the time, you may like to manage the Android SDK versions yourself.
|
|
15
|
+
def useManagedAndroidSdkVersions = false
|
|
16
|
+
if (useManagedAndroidSdkVersions) {
|
|
17
|
+
useDefaultAndroidSdkVersions()
|
|
18
|
+
} else {
|
|
19
|
+
buildscript {
|
|
20
|
+
// Simple helper that allows the root project to override versions declared by this library.
|
|
21
|
+
ext.safeExtGet = { prop, fallback ->
|
|
22
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
project.android {
|
|
26
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 34)
|
|
27
|
+
defaultConfig {
|
|
28
|
+
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
29
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 34)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
android {
|
|
35
|
+
namespace "expo.modules.nodemediaclient"
|
|
36
|
+
defaultConfig {
|
|
37
|
+
versionCode 1
|
|
38
|
+
versionName "0.1.1"
|
|
39
|
+
}
|
|
40
|
+
lintOptions {
|
|
41
|
+
abortOnError false
|
|
42
|
+
}
|
|
43
|
+
dependencies {
|
|
44
|
+
implementation 'com.github.NodeMedia:NodeMediaClient-Android:3.2.12'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2025 NodeMedia Technology Co., Ltd.
|
|
3
|
+
// Created by Chen Mingliang on 2025-07-22.
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
package expo.modules.nodemediaclient
|
|
8
|
+
|
|
9
|
+
import expo.modules.kotlin.modules.Module
|
|
10
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
11
|
+
|
|
12
|
+
var LICENSE_KEY = ""
|
|
13
|
+
|
|
14
|
+
class ExpoNodeMediaClientModule : Module() {
|
|
15
|
+
override fun definition() = ModuleDefinition {
|
|
16
|
+
Name("ExpoNodeMediaClientModule")
|
|
17
|
+
|
|
18
|
+
Function("setLicense") { license: String ->
|
|
19
|
+
// Implement the logic to set
|
|
20
|
+
LICENSE_KEY = license
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2025 NodeMedia Technology Co., Ltd.
|
|
3
|
+
// Created by Chen Mingliang on 2025-07-22.
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
package expo.modules.nodemediaclient
|
|
8
|
+
|
|
9
|
+
import expo.modules.kotlin.modules.Module
|
|
10
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
11
|
+
|
|
12
|
+
class ExpoNodePlayerModule : Module() {
|
|
13
|
+
override fun definition() = ModuleDefinition {
|
|
14
|
+
Name("ExpoNodePlayerView")
|
|
15
|
+
|
|
16
|
+
View(ExpoNodePlayerView::class) {
|
|
17
|
+
Prop("url") { view: ExpoNodePlayerView, url: String ->
|
|
18
|
+
view.url = url
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Prop("volume") { view: ExpoNodePlayerView, volume: Float ->
|
|
22
|
+
view.volume = volume
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Prop("cryptoKey") { view: ExpoNodePlayerView, cryptoKey: String ->
|
|
26
|
+
view.cryptoKey = cryptoKey
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
Prop("scaleMode") { view: ExpoNodePlayerView, scaleMode: Int ->
|
|
30
|
+
view.scaleMode = scaleMode
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Prop("bufferTime") { view: ExpoNodePlayerView, bufferTime: Int ->
|
|
34
|
+
view.bufferTime = bufferTime
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Prop("HTTPReferer") { view: ExpoNodePlayerView, HTTPReferer: String ->
|
|
38
|
+
view.HTTPReferer = HTTPReferer
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
Prop("HTTPUserAgent") { view: ExpoNodePlayerView, HTTPUserAgent: String ->
|
|
42
|
+
view.HTTPUserAgent = HTTPUserAgent
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
Prop("RTSPTransport") { view: ExpoNodePlayerView, RTSPTransport: String ->
|
|
46
|
+
view.RTSPTransport = RTSPTransport
|
|
47
|
+
}
|
|
48
|
+
Prop("HWAccelEnable") { view: ExpoNodePlayerView, HWAccelEnable: Boolean ->
|
|
49
|
+
view.HWAccelEnable = HWAccelEnable
|
|
50
|
+
}
|
|
51
|
+
AsyncFunction("start") { view: ExpoNodePlayerView, url: String? ->
|
|
52
|
+
view.start(url)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
AsyncFunction("stop") { view: ExpoNodePlayerView ->
|
|
56
|
+
view.stop()
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2025 NodeMedia Technology Co., Ltd.
|
|
3
|
+
// Created by Chen Mingliang on 2025-07-22.
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
package expo.modules.nodemediaclient
|
|
8
|
+
|
|
9
|
+
import android.content.Context
|
|
10
|
+
import android.util.Log
|
|
11
|
+
import android.webkit.WebView
|
|
12
|
+
import android.webkit.WebViewClient
|
|
13
|
+
import android.widget.FrameLayout
|
|
14
|
+
import expo.modules.kotlin.AppContext
|
|
15
|
+
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
16
|
+
import expo.modules.kotlin.views.ExpoView
|
|
17
|
+
import cn.nodemedia.NodePlayer;
|
|
18
|
+
|
|
19
|
+
class ExpoNodePlayerView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
|
|
20
|
+
// Creates and initializes an event dispatcher for the `onLoad` event.
|
|
21
|
+
// The name of the event is inferred from the value and needs to match the event name defined in the module.
|
|
22
|
+
private val onLoad by EventDispatcher()
|
|
23
|
+
private val TAG = "ExpoNodePlayerView"
|
|
24
|
+
private var np: NodePlayer? = null
|
|
25
|
+
var url = ""
|
|
26
|
+
var cryptoKey = "" // Add this property
|
|
27
|
+
set(value) {
|
|
28
|
+
field = value
|
|
29
|
+
np?.setCryptoKey(value)
|
|
30
|
+
}
|
|
31
|
+
var HTTPReferer = ""
|
|
32
|
+
set(value) {
|
|
33
|
+
field = value
|
|
34
|
+
np?.setHTTPReferer(value)
|
|
35
|
+
}
|
|
36
|
+
var HTTPUserAgent = ""
|
|
37
|
+
set(value) {
|
|
38
|
+
field = value
|
|
39
|
+
np?.setHTTPUserAgent(value)
|
|
40
|
+
}
|
|
41
|
+
var volume = 1.0f
|
|
42
|
+
set(value) {
|
|
43
|
+
field = value
|
|
44
|
+
np?.setVolume(value)
|
|
45
|
+
}
|
|
46
|
+
var scaleMode = 0
|
|
47
|
+
set(value) {
|
|
48
|
+
field = value
|
|
49
|
+
np?.setScaleMode(value)
|
|
50
|
+
}
|
|
51
|
+
var bufferTime = 1000
|
|
52
|
+
set(value) {
|
|
53
|
+
field = value
|
|
54
|
+
Log.d(TAG, "bufferTime set to $value ms $np")
|
|
55
|
+
np?.setBufferTime(value)
|
|
56
|
+
}
|
|
57
|
+
var RTSPTransport = "udp"
|
|
58
|
+
set(value) {
|
|
59
|
+
field = value
|
|
60
|
+
np?.setRTSPTransport(value)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
var HWAccelEnable= true
|
|
64
|
+
set(value) {
|
|
65
|
+
field = value
|
|
66
|
+
np?.setHWAccelEnable(value)
|
|
67
|
+
}
|
|
68
|
+
private val videoView = FrameLayout(context).apply {
|
|
69
|
+
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
init {
|
|
73
|
+
addView(videoView)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
override fun onAttachedToWindow() {
|
|
77
|
+
super.onAttachedToWindow()
|
|
78
|
+
np = NodePlayer(context, LICENSE_KEY)
|
|
79
|
+
np?.attachView(videoView)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
override fun onDetachedFromWindow() {
|
|
83
|
+
np?.stop()
|
|
84
|
+
np?.detachView()
|
|
85
|
+
np = null
|
|
86
|
+
super.onDetachedFromWindow()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
fun start(url: String?){
|
|
90
|
+
if(!url.isNullOrEmpty()) {
|
|
91
|
+
this.url = url
|
|
92
|
+
}
|
|
93
|
+
np?.setVolume(this.volume)
|
|
94
|
+
np?.setCryptoKey(this.cryptoKey)
|
|
95
|
+
np?.setScaleMode(this.scaleMode)
|
|
96
|
+
np?.setBufferTime(this.bufferTime)
|
|
97
|
+
np?.setHTTPReferer(this.HTTPReferer)
|
|
98
|
+
np?.setHTTPUserAgent(this.HTTPUserAgent)
|
|
99
|
+
np?.setRTSPTransport(this.RTSPTransport)
|
|
100
|
+
np?.setHWAccelEnable(this.HWAccelEnable)
|
|
101
|
+
np?.start(this.url)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
fun stop(){
|
|
105
|
+
np?.stop()
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NativeModule } from 'expo';
|
|
2
|
+
declare class ExpoNodeMediaClientModule extends NativeModule {
|
|
3
|
+
setLicense(license: string): void;
|
|
4
|
+
}
|
|
5
|
+
declare const _default: ExpoNodeMediaClientModule;
|
|
6
|
+
export default _default;
|
|
7
|
+
//# sourceMappingURL=ExpoNodeMediaClientModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoNodeMediaClientModule.d.ts","sourceRoot":"","sources":["../src/ExpoNodeMediaClientModule.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,OAAO,yBAA0B,SAAQ,YAAY;IAC1D,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAClC;;AAGD,wBAA2F"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2025 NodeMedia Technology Co., Ltd.
|
|
3
|
+
// Created by Chen Mingliang on 2025-07-22.
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
import { requireNativeModule } from 'expo';
|
|
7
|
+
// This call loads the native module object from the JSI.
|
|
8
|
+
export default requireNativeModule('ExpoNodeMediaClientModule');
|
|
9
|
+
//# sourceMappingURL=ExpoNodeMediaClientModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoNodeMediaClientModule.js","sourceRoot":"","sources":["../src/ExpoNodeMediaClientModule.tsx"],"names":[],"mappings":"AAAA,EAAE;AACF,qDAAqD;AACrD,4CAA4C;AAC5C,wBAAwB;AACxB,EAAE;AAGF,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAMzD,yDAAyD;AACzD,eAAe,mBAAmB,CAA4B,2BAA2B,CAAC,CAAC","sourcesContent":["//\n// Copyright (c) 2025 NodeMedia Technology Co., Ltd.\n// Created by Chen Mingliang on 2025-07-22.\n// All rights reserved.\n//\n\n\nimport { NativeModule, requireNativeModule } from 'expo';\n\ndeclare class ExpoNodeMediaClientModule extends NativeModule{\n setLicense(license: string): void;\n}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<ExpoNodeMediaClientModule>('ExpoNodeMediaClientModule');\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ViewProps } from 'react-native';
|
|
2
|
+
export type NodePlayerRef = {
|
|
3
|
+
start: (url?: string) => void;
|
|
4
|
+
stop: () => void;
|
|
5
|
+
};
|
|
6
|
+
export type NodePlayerProps = {
|
|
7
|
+
ref?: React.Ref<NodePlayerRef>;
|
|
8
|
+
url?: string;
|
|
9
|
+
volume?: number;
|
|
10
|
+
cryptoKey?: string;
|
|
11
|
+
scaleMode?: number;
|
|
12
|
+
bufferTime?: number;
|
|
13
|
+
HTTPReferer?: string;
|
|
14
|
+
HTTPUserAgent?: string;
|
|
15
|
+
RTSPTransport?: string;
|
|
16
|
+
HWAccelEnable?: boolean;
|
|
17
|
+
} & ViewProps;
|
|
18
|
+
declare const _default: import("react").ForwardRefExoticComponent<Omit<NodePlayerProps, "ref"> & import("react").RefAttributes<NodePlayerRef>>;
|
|
19
|
+
export default _default;
|
|
20
|
+
//# sourceMappingURL=ExpoNodePlayerView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoNodePlayerView.d.ts","sourceRoot":"","sources":["../src/ExpoNodePlayerView.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAIxC,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,CAAC,GAAG,CAAC,EAAC,MAAM,KAAK,IAAI,CAAC;IAC7B,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,SAAS,CAAC;;AAId,wBAaG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2025 NodeMedia Technology Co., Ltd.
|
|
3
|
+
// Created by Chen Mingliang on 2025-07-22.
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
import { requireNativeViewManager } from 'expo-modules-core';
|
|
7
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
8
|
+
const NativeView = requireNativeViewManager('ExpoNodePlayerView');
|
|
9
|
+
export default forwardRef((props, ref) => {
|
|
10
|
+
const nativeRef = useRef(null);
|
|
11
|
+
useImperativeHandle(ref, () => ({
|
|
12
|
+
start: (url) => {
|
|
13
|
+
nativeRef.current?.start(url);
|
|
14
|
+
},
|
|
15
|
+
stop: () => {
|
|
16
|
+
nativeRef.current?.stop();
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
return <NativeView ref={nativeRef} {...props}/>;
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=ExpoNodePlayerView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoNodePlayerView.js","sourceRoot":"","sources":["../src/ExpoNodePlayerView.tsx"],"names":[],"mappings":"AAAA,EAAE;AACF,qDAAqD;AACrD,4CAA4C;AAC5C,wBAAwB;AACxB,EAAE;AAGF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAoBhE,MAAM,UAAU,GAAyC,wBAAwB,CAAC,oBAAoB,CAAC,CAAC;AAExG,eAAe,UAAU,CAAiC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACvE,MAAM,SAAS,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAC;IAE9C,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,KAAK,EAAE,CAAC,GAAW,EAAE,EAAE;YACrB,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,EAAE,GAAG,EAAE;YACT,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;QAC5B,CAAC;KACF,CAAC,CAAC,CAAC;IAEJ,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACnD,CAAC,CAAC,CAAC","sourcesContent":["//\n// Copyright (c) 2025 NodeMedia Technology Co., Ltd.\n// Created by Chen Mingliang on 2025-07-22.\n// All rights reserved.\n//\n\nimport { ViewProps} from 'react-native';\nimport { requireNativeViewManager } from 'expo-modules-core';\nimport { forwardRef, useImperativeHandle, useRef } from 'react';\n\nexport type NodePlayerRef = {\n start: (url?:string) => void;\n stop: () => void;\n}\n\nexport type NodePlayerProps = {\n ref?: React.Ref<NodePlayerRef>;\n url?: string;\n volume?: number;\n cryptoKey?: string;\n scaleMode?: number;\n bufferTime?: number;\n HTTPReferer?: string;\n HTTPUserAgent?: string;\n RTSPTransport?: string;\n HWAccelEnable?: boolean;\n} & ViewProps;\n\nconst NativeView: React.ComponentType<NodePlayerProps> = requireNativeViewManager('ExpoNodePlayerView');\n\nexport default forwardRef<NodePlayerRef, NodePlayerProps>((props, ref) => {\n const nativeRef = useRef<NodePlayerRef>(null);\n\n useImperativeHandle(ref, () => ({\n start: (url?:string) => {\n nativeRef.current?.start(url);\n },\n stop: () => {\n nativeRef.current?.stop();\n }\n }));\n\n return <NativeView ref={nativeRef} {...props} />;\n});\n\n"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2025 NodeMedia Technology Co., Ltd.
|
|
3
|
+
// Created by Chen Mingliang on 2025-07-22.
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
export { default as NodeMediaClient } from './ExpoNodeMediaClientModule';
|
|
7
|
+
export { default as NodePlayer } from './ExpoNodePlayerView';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,qDAAqD;AACrD,4CAA4C;AAC5C,wBAAwB;AACxB,EAAE;AAEF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAkC,MAAM,sBAAsB,CAAC","sourcesContent":["//\n// Copyright (c) 2025 NodeMedia Technology Co., Ltd.\n// Created by Chen Mingliang on 2025-07-22.\n// All rights reserved.\n//\n\nexport { default as NodeMediaClient } from './ExpoNodeMediaClientModule';\nexport { default as NodePlayer, NodePlayerRef, NodePlayerProps } from './ExpoNodePlayerView';\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"platforms": ["apple", "android"],
|
|
3
|
+
"apple": {
|
|
4
|
+
"modules": [
|
|
5
|
+
"ExpoNodeMediaClientModule",
|
|
6
|
+
"ExpoNodePlayerModule"
|
|
7
|
+
]
|
|
8
|
+
},
|
|
9
|
+
"android": {
|
|
10
|
+
"modules": [
|
|
11
|
+
"expo.modules.nodemediaclient.ExpoNodeMediaClientModule",
|
|
12
|
+
"expo.modules.nodemediaclient.ExpoNodePlayerModule"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2025 NodeMedia Technology Co., Ltd.
|
|
3
|
+
// Created by Chen Mingliang on 2025-07-23.
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import ExpoModulesCore
|
|
8
|
+
|
|
9
|
+
var LICENSE_KEY = ""
|
|
10
|
+
|
|
11
|
+
public class ExpoNodeMediaClientModule: Module {
|
|
12
|
+
// Each module class must implement the definition function. The definition consists of components
|
|
13
|
+
// that describes the module's functionality and behavior.
|
|
14
|
+
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
15
|
+
public func definition() -> ModuleDefinition {
|
|
16
|
+
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
|
17
|
+
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
18
|
+
// The module will be accessible from `requireNativeModule('ExpoNodemediaclient')` in JavaScript.
|
|
19
|
+
Name("ExpoNodeMediaClientModule")
|
|
20
|
+
|
|
21
|
+
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
|
|
22
|
+
Function("setLicense") { (license: String) in
|
|
23
|
+
LICENSE_KEY = license
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2025 NodeMedia Technology Co., Ltd.
|
|
3
|
+
// Created by Chen Mingliang on 2025-07-23.
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import ExpoModulesCore
|
|
8
|
+
|
|
9
|
+
public class ExpoNodePlayerModule: Module {
|
|
10
|
+
// Each module class must implement the definition function. The definition consists of components
|
|
11
|
+
// that describes the module's functionality and behavior.
|
|
12
|
+
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
13
|
+
public func definition() -> ModuleDefinition {
|
|
14
|
+
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
|
15
|
+
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
16
|
+
// The module will be accessible from `requireNativeModule('ExpoNodemediaclient')` in JavaScript.
|
|
17
|
+
Name("ExpoNodePlayerView")
|
|
18
|
+
|
|
19
|
+
View(ExpoNodePlayerView.self) {
|
|
20
|
+
Prop("url") { (view, url: String) in
|
|
21
|
+
view.url = url
|
|
22
|
+
}
|
|
23
|
+
Prop("volume") { (view, volume: Float) in
|
|
24
|
+
view.volume = volume
|
|
25
|
+
}
|
|
26
|
+
Prop("croptyKey") { (view, key: String) in
|
|
27
|
+
view.croptyKey = key
|
|
28
|
+
}
|
|
29
|
+
Prop("scaleMode") { (view, mode: UInt) in
|
|
30
|
+
view.scaleMode = mode
|
|
31
|
+
}
|
|
32
|
+
Prop("bufferTime") { (view, time: UInt) in
|
|
33
|
+
view.bufferTime = time
|
|
34
|
+
}
|
|
35
|
+
Prop("HTTPReferer") { (view, referer: String) in
|
|
36
|
+
view.HTTPReferer = referer
|
|
37
|
+
}
|
|
38
|
+
Prop("HTTPUserAgent") { (view, userAgent: String) in
|
|
39
|
+
view.HTTPUserAgent = userAgent
|
|
40
|
+
}
|
|
41
|
+
Prop("RTSPTransport") { (view, transport: String) in
|
|
42
|
+
view.RTSPTransport = transport
|
|
43
|
+
}
|
|
44
|
+
Prop("HWAccelEnable") { (view, enable: Bool) in
|
|
45
|
+
view.HWAccelEnable = enable
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
AsyncFunction("start") { (view: ExpoNodePlayerView, url: String?) in
|
|
49
|
+
view.start(u:url)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
AsyncFunction("stop") { (view: ExpoNodePlayerView) in
|
|
53
|
+
view.stop()
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2025 NodeMedia Technology Co., Ltd.
|
|
3
|
+
// Created by Chen Mingliang on 2025-07-23.
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import ExpoModulesCore
|
|
8
|
+
import NodeMediaClient
|
|
9
|
+
|
|
10
|
+
class ExpoNodePlayerView: ExpoView {
|
|
11
|
+
private var _np: NodePlayer?
|
|
12
|
+
var url = ""
|
|
13
|
+
var croptyKey = ""
|
|
14
|
+
var HTTPReferer = ""
|
|
15
|
+
var HTTPUserAgent = ""
|
|
16
|
+
var RTSPTransport = "udp"
|
|
17
|
+
var HWAccelEnable = true
|
|
18
|
+
private var _volume:Float = 1.0
|
|
19
|
+
private var _scaleMode: UInt = 0
|
|
20
|
+
private var _bufferTime: UInt = 1000
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var volume:Float {
|
|
24
|
+
get {
|
|
25
|
+
return _volume
|
|
26
|
+
}
|
|
27
|
+
set {
|
|
28
|
+
_volume = newValue
|
|
29
|
+
_np?.volume = newValue
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var scaleMode:UInt {
|
|
34
|
+
get {
|
|
35
|
+
return _scaleMode
|
|
36
|
+
}
|
|
37
|
+
set {
|
|
38
|
+
_scaleMode = newValue
|
|
39
|
+
_np?.scaleMode = newValue
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var bufferTime:UInt {
|
|
44
|
+
get {
|
|
45
|
+
return _bufferTime
|
|
46
|
+
}
|
|
47
|
+
set {
|
|
48
|
+
_bufferTime = newValue
|
|
49
|
+
_np?.bufferTime = newValue
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
required init(appContext: AppContext? = nil) {
|
|
54
|
+
super.init(appContext: appContext)
|
|
55
|
+
_np = NodePlayer(license: LICENSE_KEY)
|
|
56
|
+
_np?.attach(self)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
deinit {
|
|
60
|
+
_np?.stop()
|
|
61
|
+
_np?.detachView()
|
|
62
|
+
_np = nil
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
func start(u: String?) {
|
|
66
|
+
if let newUrl = u {
|
|
67
|
+
url = newUrl
|
|
68
|
+
}
|
|
69
|
+
_np?.volume = volume
|
|
70
|
+
_np?.cryptoKey = croptyKey
|
|
71
|
+
_np?.scaleMode = scaleMode
|
|
72
|
+
_np?.bufferTime = bufferTime
|
|
73
|
+
_np?.httpReferer = HTTPReferer
|
|
74
|
+
_np?.httpUserAgent = HTTPUserAgent
|
|
75
|
+
_np?.rtspTransport = RTSPTransport
|
|
76
|
+
_np?.hwAccelEnable = HWAccelEnable
|
|
77
|
+
_np?.start(url)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
func stop() {
|
|
81
|
+
_np?.stop()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
override func layoutSubviews() {
|
|
85
|
+
// webView.frame = bounds
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'ExpoNodemediaclient'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.description = package['description']
|
|
10
|
+
s.license = package['license']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.homepage = package['homepage']
|
|
13
|
+
s.platforms = {
|
|
14
|
+
:ios => '15.1',
|
|
15
|
+
:tvos => '15.1'
|
|
16
|
+
}
|
|
17
|
+
s.swift_version = '5.4'
|
|
18
|
+
s.source = { git: 'https://github.com/NodeMedia/expo-nodemediaclient' }
|
|
19
|
+
s.static_framework = true
|
|
20
|
+
|
|
21
|
+
s.dependency 'ExpoModulesCore'
|
|
22
|
+
s.dependency 'NodeMediaClient', '~> 3.2.10'
|
|
23
|
+
|
|
24
|
+
# Swift/Objective-C compatibility
|
|
25
|
+
s.pod_target_xcconfig = {
|
|
26
|
+
'DEFINES_MODULE' => 'YES',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}"
|
|
30
|
+
end
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "expo-nodemediaclient",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Expo NodeMediaClient module",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"types": "build/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "expo-module build",
|
|
9
|
+
"clean": "expo-module clean",
|
|
10
|
+
"lint": "expo-module lint",
|
|
11
|
+
"test": "expo-module test",
|
|
12
|
+
"prepare": "expo-module prepare",
|
|
13
|
+
"prepublishOnly": "expo-module prepublishOnly",
|
|
14
|
+
"expo-module": "expo-module",
|
|
15
|
+
"open:ios": "xed example/ios",
|
|
16
|
+
"open:android": "open -a \"Android Studio\" example/android"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react-native",
|
|
20
|
+
"expo",
|
|
21
|
+
"nodemediaclient",
|
|
22
|
+
"RTMP",
|
|
23
|
+
"RTSP",
|
|
24
|
+
"NodePlayer"
|
|
25
|
+
],
|
|
26
|
+
"repository": "https://github.com/NodeMedia/expo-nodemediaclient",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/NodeMedia/expo-nodemediaclient/issues"
|
|
29
|
+
},
|
|
30
|
+
"author": "Chen Mingliang <illuspas@msn.com> (illuspas)",
|
|
31
|
+
"license": "Apache-2.0",
|
|
32
|
+
"homepage": "https://github.com/NodeMedia/expo-nodemediaclient#readme",
|
|
33
|
+
"dependencies": {},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/react": "~19.0.0",
|
|
36
|
+
"expo-module-scripts": "^4.1.9",
|
|
37
|
+
"expo": "~53.0.0",
|
|
38
|
+
"react-native": "0.79.1"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"expo": "*",
|
|
42
|
+
"react": "*",
|
|
43
|
+
"react-native": "*"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2025 NodeMedia Technology Co., Ltd.
|
|
3
|
+
// Created by Chen Mingliang on 2025-07-22.
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
import { NativeModule, requireNativeModule } from 'expo';
|
|
9
|
+
|
|
10
|
+
declare class ExpoNodeMediaClientModule extends NativeModule{
|
|
11
|
+
setLicense(license: string): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// This call loads the native module object from the JSI.
|
|
15
|
+
export default requireNativeModule<ExpoNodeMediaClientModule>('ExpoNodeMediaClientModule');
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2025 NodeMedia Technology Co., Ltd.
|
|
3
|
+
// Created by Chen Mingliang on 2025-07-22.
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import { ViewProps} from 'react-native';
|
|
8
|
+
import { requireNativeViewManager } from 'expo-modules-core';
|
|
9
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
10
|
+
|
|
11
|
+
export type NodePlayerRef = {
|
|
12
|
+
start: (url?:string) => void;
|
|
13
|
+
stop: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type NodePlayerProps = {
|
|
17
|
+
ref?: React.Ref<NodePlayerRef>;
|
|
18
|
+
url?: string;
|
|
19
|
+
volume?: number;
|
|
20
|
+
cryptoKey?: string;
|
|
21
|
+
scaleMode?: number;
|
|
22
|
+
bufferTime?: number;
|
|
23
|
+
HTTPReferer?: string;
|
|
24
|
+
HTTPUserAgent?: string;
|
|
25
|
+
RTSPTransport?: string;
|
|
26
|
+
HWAccelEnable?: boolean;
|
|
27
|
+
} & ViewProps;
|
|
28
|
+
|
|
29
|
+
const NativeView: React.ComponentType<NodePlayerProps> = requireNativeViewManager('ExpoNodePlayerView');
|
|
30
|
+
|
|
31
|
+
export default forwardRef<NodePlayerRef, NodePlayerProps>((props, ref) => {
|
|
32
|
+
const nativeRef = useRef<NodePlayerRef>(null);
|
|
33
|
+
|
|
34
|
+
useImperativeHandle(ref, () => ({
|
|
35
|
+
start: (url?:string) => {
|
|
36
|
+
nativeRef.current?.start(url);
|
|
37
|
+
},
|
|
38
|
+
stop: () => {
|
|
39
|
+
nativeRef.current?.stop();
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
return <NativeView ref={nativeRef} {...props} />;
|
|
44
|
+
});
|
|
45
|
+
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2025 NodeMedia Technology Co., Ltd.
|
|
3
|
+
// Created by Chen Mingliang on 2025-07-22.
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
export { default as NodeMediaClient } from './ExpoNodeMediaClientModule';
|
|
8
|
+
export { default as NodePlayer, NodePlayerRef, NodePlayerProps } from './ExpoNodePlayerView';
|
package/tsconfig.json
ADDED