-
Notifications
You must be signed in to change notification settings - Fork 1
/
PublishScreen.jsx
88 lines (84 loc) · 2.63 KB
/
PublishScreen.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import React, { useRef, useState } from 'react';
import { View } from 'react-native';
import { NodePublisher } from 'react-native-nodemediaclient';
import { FloatingAction } from "react-native-floating-action";
const actions = [
{
text: "Start",
name: "bt_start",
position: 1
},
{
text: "Switch",
name: "bt_switch",
position: 2
},
{
text: "Torch",
name: "bt_torch",
position: 3
},
{
text: "Mute",
name: "bt_mute",
position: 4
}
];
function PublishScreen({ route, navigation }) {
const { url } = route.params;
const [frontCamera, setFrontCamera] = useState(true);
const [torchEnable, setTorchEnable] = useState(false);
const [mute, setMute] = useState(false);
const np = useRef(null);
return (
<View style={{ flex: 1 }}>
<NodePublisher
ref={np}
style={{ flex: 1 }}
url={url}
audioParam={{
codecid: NodePublisher.NMC_CODEC_ID_AAC,
profile: NodePublisher.NMC_PROFILE_AUTO,
samplerate: 48000,
channels: 1,
bitrate: 64 * 1000,
}}
videoParam={{
codecid: NodePublisher.NMC_CODEC_ID_H264,
profile: NodePublisher.NMC_PROFILE_AUTO,
width: 720,
height: 1280,
fps: 30,
bitrate: 2000 * 1000,
}}
frontCamera={frontCamera}
HWAccelEnable={true}
denoiseEnable={true}
torchEnable={torchEnable}
keyFrameInterval={2}
volume={mute ? 0.0 : 1.0}
videoOrientation={NodePublisher.VIDEO_ORIENTATION_PORTRAIT}
></NodePublisher >
<FloatingAction
actions={actions}
onPressItem={name => {
switch (name) {
case "bt_start":
np.current.start();
break;
case "bt_switch":
setFrontCamera(!frontCamera);
break;
case "bt_torch":
setTorchEnable(!torchEnable);
break;
case "bt_mute":
setMute(!mute);
break;
}
}}
/>
</View>
)
}
export default PublishScreen;