@100mslive/roomkit-react 0.3.18-alpha.1 → 0.3.19-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,118 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { selectLocalPeerID, useHMSStore, useScreenShare } from '@100mslive/react-sdk';
3
- import { ChevronDownIcon, ChevronUpIcon, MusicIcon, ShareScreenIcon, VideoPlayerIcon } from '@100mslive/react-icons';
4
- import { Box, Dropdown, Flex, Text, Tooltip } from '../../../';
5
- import { useUISettings } from '../AppData/useUISettings';
6
- import { useScreenshareAudio } from '../hooks/useScreenshareAudio';
7
- import { UI_SETTINGS } from '../../common/constants';
8
-
9
- export const getRecordingText = ({ isBrowserRecordingOn, isServerRecordingOn, isHLSRecordingOn }, delimiter = ', ') => {
10
- if (!isBrowserRecordingOn && !isServerRecordingOn && !isHLSRecordingOn) {
11
- return '';
12
- }
13
- const title = [];
14
- if (isBrowserRecordingOn) {
15
- title.push('Browser');
16
- }
17
- if (isServerRecordingOn) {
18
- title.push('Server');
19
- }
20
- if (isHLSRecordingOn) {
21
- title.push('HLS');
22
- }
23
- return title.join(delimiter);
24
- };
25
-
26
- /**
27
- * Display state of recording, streaming, playlist, whiteboard
28
- */
29
- export const AdditionalRoomState = () => {
30
- const isAudioOnly = useUISettings(UI_SETTINGS.isAudioOnly);
31
- const screenshareAudio = useScreenshareAudio();
32
- const [open, setOpen] = useState(false);
33
- const isAudioshareInactive = [
34
- !screenshareAudio.peer || !screenshareAudio.track,
35
- !screenshareAudio.peer?.isLocal && !screenshareAudio.track?.enabled,
36
- ].some(Boolean);
37
-
38
- const localPeerID = useHMSStore(selectLocalPeerID);
39
- const { screenSharingPeerName, screenSharingPeerId, screenShareVideoTrackId } = useScreenShare();
40
-
41
- const isVideoScreenSharingOn = !!screenShareVideoTrackId;
42
- const shouldShowScreenShareState = isAudioOnly && isVideoScreenSharingOn;
43
- const shouldShowVideoState = isAudioOnly;
44
- if (isAudioshareInactive && !shouldShowScreenShareState && !shouldShowVideoState) {
45
- return null;
46
- }
47
-
48
- return (
49
- <Dropdown.Root open={open} onOpenChange={setOpen}>
50
- <Dropdown.Trigger asChild>
51
- <Flex
52
- align="center"
53
- css={{
54
- color: '$on_primary_high',
55
- borderRadius: '$1',
56
- border: '1px solid $on_surface_low',
57
- padding: '$4',
58
- '@sm': { display: 'none' },
59
- }}
60
- data-testid="record_status_dropdown"
61
- >
62
- {!isAudioshareInactive && (
63
- <Tooltip title="Screenshare Audio">
64
- <Flex align="center" css={{ color: '$on_primary_high', mx: '$2' }}>
65
- <MusicIcon width={24} height={24} />
66
- </Flex>
67
- </Tooltip>
68
- )}
69
- {shouldShowScreenShareState && (
70
- <Tooltip title="Screenshare">
71
- <Flex align="center" css={{ color: '$on_primary_high', mx: '$2' }}>
72
- <ShareScreenIcon width={24} height={24} />
73
- </Flex>
74
- </Tooltip>
75
- )}
76
- {shouldShowVideoState && (
77
- <Tooltip title="video playlist">
78
- <Flex align="center" css={{ color: '$on_primary_high', mx: '$2' }}>
79
- <VideoPlayerIcon width={24} height={24} />
80
- </Flex>
81
- </Tooltip>
82
- )}
83
- <Box css={{ '@lg': { display: 'none' }, color: '$on_surface_low' }}>
84
- {open ? <ChevronUpIcon /> : <ChevronDownIcon />}
85
- </Box>
86
- </Flex>
87
- </Dropdown.Trigger>
88
- <Dropdown.Content sideOffset={5} align="end" css={{ w: '$60' }}>
89
- {!isAudioshareInactive && (
90
- <Dropdown.Item css={{ color: '$on_primary_high' }}>
91
- <MusicIcon width={24} height={24} />
92
- <Text variant="sm" css={{ ml: '$2', flex: '1 1 0' }}>
93
- Music is playing
94
- </Text>
95
- <Text
96
- variant="sm"
97
- css={{ color: '$alert_error_default', ml: '$2', cursor: 'pointer' }}
98
- onClick={e => {
99
- e.preventDefault();
100
- screenshareAudio.onToggle();
101
- }}
102
- >
103
- {screenshareAudio.muted ? 'Unmute' : 'Mute'}
104
- </Text>
105
- </Dropdown.Item>
106
- )}
107
- {shouldShowScreenShareState && (
108
- <Dropdown.Item css={{ color: '$on_primary_high' }}>
109
- <ShareScreenIcon width={24} height={24} />
110
- <Text variant="sm" css={{ ml: '$2', flex: '1 1 0' }}>
111
- {`Shared by: ${screenSharingPeerId === localPeerID ? 'You' : screenSharingPeerName}`}
112
- </Text>
113
- </Dropdown.Item>
114
- )}
115
- </Dropdown.Content>
116
- </Dropdown.Root>
117
- );
118
- };