-
Notifications
You must be signed in to change notification settings - Fork 18
/
HostLivestreamControls.tsx
90 lines (87 loc) · 2.55 KB
/
HostLivestreamControls.tsx
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
89
90
import React from 'react';
import { StyleSheet, View, ViewProps } from 'react-native';
import {
HostStartStreamButton as DefaultHostStartStreamButton,
HostStartStreamButtonProps,
} from './HostStartStreamButton';
import {
LivestreamMediaControls as DefaultLivestreamMediaControls,
LivestreamMediaControlsProps,
} from './LivestreamMediaControls';
import { useTheme } from '../../../contexts';
import { Z_INDEX } from '../../../constants';
/**
* Props for the HostLivestreamControls component.
*/
export type HostLivestreamControlsProps = HostStartStreamButtonProps & {
/**
* Component to customize the host's start/end live stream button.
*/
HostStartStreamButton?: React.ComponentType<HostStartStreamButtonProps> | null;
/**
* Component to customize the host's media control(audio/video) buttons.
*/
LivestreamMediaControls?: React.ComponentType<LivestreamMediaControlsProps> | null;
onLayout?: ViewProps['onLayout'];
};
/**
* The HostLivestreamControls component displays the call controls for the live stream at host's end.
*/
export const HostLivestreamControls = ({
HostStartStreamButton = DefaultHostStartStreamButton,
LivestreamMediaControls = DefaultLivestreamMediaControls,
onEndStreamHandler,
onStartStreamHandler,
hls,
disableStopPublishedStreamsOnEndStream,
onLayout,
}: HostLivestreamControlsProps) => {
const {
theme: { colors, hostLivestreamControls },
} = useTheme();
return (
<View
style={[
styles.container,
{ backgroundColor: colors.static_overlay },
hostLivestreamControls.container,
]}
onLayout={onLayout}
>
<View style={[styles.leftElement, hostLivestreamControls.leftElement]}>
{HostStartStreamButton && (
<HostStartStreamButton
onEndStreamHandler={onEndStreamHandler}
onStartStreamHandler={onStartStreamHandler}
hls={hls}
disableStopPublishedStreamsOnEndStream={
disableStopPublishedStreamsOnEndStream
}
/>
)}
</View>
<View style={[styles.rightElement, hostLivestreamControls.rightElement]}>
{LivestreamMediaControls && <LivestreamMediaControls />}
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
position: 'absolute',
bottom: 0,
flexDirection: 'row',
alignItems: 'center',
paddingVertical: 16,
paddingHorizontal: 8,
zIndex: Z_INDEX.IN_FRONT,
},
leftElement: {
flex: 1,
alignItems: 'flex-start',
},
rightElement: {
flex: 1,
alignItems: 'flex-end',
},
});