@100mslive/roomkit-react 0.3.8-alpha.3 → 0.3.8-alpha.4

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.
@@ -1,5 +1,4 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
- import { useMedia } from 'react-use';
3
2
  import { DefaultConferencingScreen_Elements } from '@100mslive/types-prebuilt';
4
3
  import { v4 as uuid } from 'uuid';
5
4
  import {
@@ -19,7 +18,6 @@ import { ActivatedPIP } from './PIP/PIPComponent';
19
18
  import { PictureInPicture } from './PIP/PIPManager';
20
19
  import { RoleChangeRequestModal } from './RoleChangeRequest/RoleChangeRequestModal';
21
20
  import { Box, Flex } from '../../Layout';
22
- import { config } from '../../Theme';
23
21
  import { useHMSPrebuiltContext } from '../AppContext';
24
22
  import { VideoStreamingSection } from '../layouts/VideoStreamingSection';
25
23
  // @ts-ignore: No implicit Any
@@ -28,21 +26,17 @@ import FullPageProgress from './FullPageProgress';
28
26
  import { Header } from './Header';
29
27
  import { PreviousRoleInMetadata } from './PreviousRoleInMetadata';
30
28
  import { RaiseHand } from './RaiseHand';
31
- import { CaptionsViewer } from '../plugins/CaptionsViewer';
32
29
  import {
33
30
  useRoomLayoutConferencingScreen,
34
31
  useRoomLayoutPreviewScreen,
35
32
  } from '../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
36
33
  // @ts-ignore: No implicit Any
37
- import { useIsSidepaneTypeOpen } from './AppData/useSidepane';
38
- // @ts-ignore: No implicit Any
39
- import { useAuthToken, useIsCaptionEnabled, useSetAppDataByKey } from './AppData/useUISettings';
34
+ import { useAuthToken, useSetAppDataByKey } from './AppData/useUISettings';
40
35
  import { useLandscapeHLSStream, useMobileHLSStream } from '../common/hooks';
41
- import { APP_DATA, isAndroid, isIOS, isIPadOS, SIDE_PANE_OPTIONS } from '../common/constants';
36
+ import { APP_DATA, isAndroid, isIOS, isIPadOS } from '../common/constants';
42
37
 
43
38
  export const ConferenceScreen = () => {
44
39
  const { userName, endpoints, onJoin: onJoinFunc } = useHMSPrebuiltContext();
45
- const isMobile = useMedia(config.media.md);
46
40
  const screenProps = useRoomLayoutConferencingScreen();
47
41
  const { isPreviewScreenEnabled } = useRoomLayoutPreviewScreen();
48
42
  const roomState = useHMSStore(selectRoomState);
@@ -63,10 +57,6 @@ export const ConferenceScreen = () => {
63
57
  const isMobileHLSStream = useMobileHLSStream();
64
58
  const isLandscapeHLSStream = useLandscapeHLSStream();
65
59
  const isMwebHLSStream = isMobileHLSStream || isLandscapeHLSStream;
66
- const isCaptionEnabled = useIsCaptionEnabled();
67
- const isChatOpen = useIsSidepaneTypeOpen(SIDE_PANE_OPTIONS.CHAT);
68
-
69
- const showCaptionAtTop = screenProps.elements?.chat?.is_overlay && isChatOpen && isMobile;
70
60
 
71
61
  const toggleControls = () => {
72
62
  if (dropdownListRef.current?.length === 0 && isMobileDevice && !isMwebHLSStream) {
@@ -134,28 +124,6 @@ export const ConferenceScreen = () => {
134
124
  <FullPageProgress text="Starting live stream..." css={{ opacity: 0.8, bg: '$background_dim' }} />
135
125
  </Box>
136
126
  ) : null}
137
- {isCaptionEnabled && screenProps.screenType !== 'hls_live_streaming' && (
138
- <Box
139
- css={{
140
- position: 'fixed',
141
- w: isMobile ? '100%' : '40%',
142
- bottom: showCaptionAtTop ? '' : hideControlsForStreaming ? '5%' : '10%',
143
- top: showCaptionAtTop ? (hideControlsForStreaming ? '5%' : '10%') : '',
144
- left: isMobile ? 0 : '50%',
145
- transform: isMobile ? '' : 'translateX(-50%)',
146
- background: '#000000A3',
147
- overflow: 'clip',
148
- zIndex: 10,
149
- height: 'fit-content',
150
- r: '$1',
151
- p: '$6',
152
- transition: 'bottom 0.3s ease-in-out',
153
- '&:empty': { display: 'none' },
154
- }}
155
- >
156
- <CaptionsViewer />
157
- </Box>
158
- )}
159
127
  <Flex css={{ size: '100%', overflow: 'hidden' }} direction="column">
160
128
  {!(screenProps.hideSections.includes('header') || isMwebHLSStream) && (
161
129
  <Box
@@ -16,6 +16,8 @@ import { PDFView } from './PDFView';
16
16
  import SidePane from './SidePane';
17
17
  // @ts-ignore: No implicit Any
18
18
  import { WaitingView } from './WaitingView';
19
+ import { CaptionsViewer } from '../plugins/CaptionsViewer';
20
+ // @ts-ignore: No implicit Any
19
21
  import {
20
22
  usePDFConfig,
21
23
  useUrlToEmbed,
@@ -25,7 +27,6 @@ import {
25
27
  import { useCloseScreenshareWhiteboard } from '../components/hooks/useCloseScreenshareWhiteboard';
26
28
  import { useLandscapeHLSStream, useMobileHLSStream } from '../common/hooks';
27
29
  import { SESSION_STORE_KEY } from '../common/constants';
28
-
29
30
  // @ts-ignore: No implicit Any
30
31
  const HLSView = React.lazy(() => import('./HLSView'));
31
32
 
@@ -105,6 +106,7 @@ export const VideoStreamingSection = ({
105
106
  // @ts-ignore
106
107
  return <GridLayout {...(elements as DefaultConferencingScreen_Elements)?.video_tile_layout?.grid} />;
107
108
  })}
109
+ <CaptionsViewer />
108
110
  <Box
109
111
  css={{
110
112
  flex: match({ isLandscapeHLSStream, isMobileHLSStream })
@@ -1,8 +1,15 @@
1
1
  import React, { useEffect, useState } from 'react';
2
+ import { useMedia } from 'react-use';
2
3
  import { HMSTranscript, selectPeerNameByID, useHMSStore, useTranscript } from '@100mslive/react-sdk';
3
- import { Flex } from '../../Layout';
4
+ import { Box, Flex } from '../../Layout';
4
5
  import { Text } from '../../Text';
5
-
6
+ import { config } from '../../Theme';
7
+ // @ts-ignore: No implicit Any
8
+ import { useIsSidepaneTypeOpen } from '../components/AppData/useSidepane';
9
+ // @ts-ignore: No implicit Any
10
+ import { useIsCaptionEnabled } from '../components/AppData/useUISettings';
11
+ import { useRoomLayoutConferencingScreen } from '../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
12
+ import { SIDE_PANE_OPTIONS } from '../common/constants';
6
13
  interface CaptionQueueData extends HMSTranscript {
7
14
  transcriptQueue: SimpleQueue;
8
15
  }
@@ -152,9 +159,17 @@ const TranscriptView = ({ peer_id, data }: { peer_id: string; data: string }) =>
152
159
  };
153
160
 
154
161
  export const CaptionsViewer = () => {
162
+ const { elements, screenType } = useRoomLayoutConferencingScreen();
163
+ const isMobile = useMedia(config.media.md);
164
+ const isChatOpen = useIsSidepaneTypeOpen(SIDE_PANE_OPTIONS.CHAT);
165
+
166
+ const showCaptionAtTop = elements?.chat?.is_overlay && isChatOpen && isMobile;
167
+
155
168
  const [captionQueue] = useState<CaptionMaintainerQueue>(new CaptionMaintainerQueue());
156
169
  const [currentData, setCurrentData] = useState<{ [key: string]: string }[]>([]);
157
170
 
171
+ const isCaptionEnabled = useIsCaptionEnabled();
172
+
158
173
  useEffect(() => {
159
174
  const timeInterval = setInterval(() => {
160
175
  if (!captionQueue) {
@@ -178,15 +193,34 @@ export const CaptionsViewer = () => {
178
193
  }
179
194
  return false;
180
195
  });
181
- if (dataToShow.length <= 0) {
196
+ if (dataToShow.length <= 0 || screenType === 'hls_live_streaming' || !isCaptionEnabled) {
182
197
  return null;
183
198
  }
184
199
  return (
185
- <Flex direction="column">
186
- {dataToShow.map((data: { [key: string]: string }, index: number) => {
187
- const key = Object.keys(data)[0];
188
- return <TranscriptView key={index} peer_id={key} data={data[key]} />;
189
- })}
190
- </Flex>
200
+ <Box
201
+ css={{
202
+ position: 'absolute',
203
+ w: isMobile ? '100%' : '40%',
204
+ bottom: showCaptionAtTop ? '' : '0',
205
+ top: showCaptionAtTop ? '0' : '',
206
+ left: isMobile ? 0 : '50%',
207
+ transform: isMobile ? '' : 'translateX(-50%)',
208
+ background: '#000000A3',
209
+ overflow: 'clip',
210
+ zIndex: 10,
211
+ height: 'fit-content',
212
+ r: '$1',
213
+ p: '$6',
214
+ transition: 'bottom 0.3s ease-in-out',
215
+ '&:empty': { display: 'none' },
216
+ }}
217
+ >
218
+ <Flex direction="column">
219
+ {dataToShow.map((data: { [key: string]: string }, index: number) => {
220
+ const key = Object.keys(data)[0];
221
+ return <TranscriptView key={index} peer_id={key} data={data[key]} />;
222
+ })}
223
+ </Flex>
224
+ </Box>
191
225
  );
192
226
  };