@100mslive/roomkit-react 0.2.6-alpha.2 → 0.2.6-alpha.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,8 +46,8 @@ export const APP_DATA = {
46
46
  disableNotifications: 'disableNotifications',
47
47
  pollState: 'pollState',
48
48
  background: 'background',
49
- backgroundType: 'backgroundType',
50
49
  };
50
+
51
51
  export const UI_SETTINGS = {
52
52
  isAudioOnly: 'isAudioOnly',
53
53
  maxTileCount: 'maxTileCount',
@@ -1,15 +1,19 @@
1
1
  import React, { useEffect } from 'react';
2
+ import { useMedia } from 'react-use';
2
3
  import {
3
4
  HMSRoomState,
4
5
  selectFullAppData,
5
6
  selectHLSState,
6
7
  selectRoomState,
7
8
  selectRTMPState,
9
+ useAVToggle,
8
10
  useHMSActions,
9
11
  useHMSStore,
10
12
  useRecordingStreaming,
11
13
  } from '@100mslive/react-sdk';
14
+ import { config as cssConfig } from '../../../Theme';
12
15
  import { LayoutMode } from '../Settings/LayoutSettings';
16
+ import { useRoomLayoutConferencingScreen } from '../../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
13
17
  //@ts-ignore
14
18
  import { UserPreferencesKeys, useUserPreferences } from '../hooks/useUserPreferences';
15
19
  // @ts-ignore
@@ -60,7 +64,6 @@ const initialAppData = {
60
64
  [APP_DATA.activeScreensharePeerId]: '',
61
65
  [APP_DATA.disableNotifications]: false,
62
66
  [APP_DATA.background]: 'none',
63
- [APP_DATA.backgroundType]: 'none',
64
67
  [APP_DATA.pollState]: {
65
68
  [POLL_STATE.pollInView]: '',
66
69
  [POLL_STATE.view]: '',
@@ -71,6 +74,10 @@ export const AppData = React.memo(() => {
71
74
  const hmsActions = useHMSActions();
72
75
  const [preferences = {}] = useUserPreferences(UserPreferencesKeys.UI_SETTINGS);
73
76
  const appData = useHMSStore(selectFullAppData);
77
+ const { elements } = useRoomLayoutConferencingScreen();
78
+ const toggleVB = useSidepaneToggle(SIDE_PANE_OPTIONS.VB);
79
+ const isMobile = useMedia(cssConfig.media.md);
80
+ const { isLocalVideoEnabled } = useAVToggle();
74
81
 
75
82
  useEffect(() => {
76
83
  hmsActions.initAppData({
@@ -103,6 +110,21 @@ export const AppData = React.memo(() => {
103
110
  hmsActions.setAppData(APP_DATA.subscribedNotifications, preferences.subscribedNotifications, true);
104
111
  }, [preferences.subscribedNotifications, hmsActions]);
105
112
 
113
+ useEffect(() => {
114
+ let defaultMediaURL;
115
+ elements?.virtual_background?.background_media?.forEach(media => {
116
+ if (media.default && media.url) {
117
+ defaultMediaURL = media.url;
118
+ }
119
+ });
120
+ if (defaultMediaURL) {
121
+ hmsActions.setAppData(APP_DATA.background, defaultMediaURL);
122
+ if (isLocalVideoEnabled && !isMobile) {
123
+ toggleVB();
124
+ }
125
+ }
126
+ }, [hmsActions, elements?.virtual_background?.background_media, toggleVB, isLocalVideoEnabled, isMobile]);
127
+
106
128
  return <ResetStreamingStart />;
107
129
  });
108
130
 
@@ -12,7 +12,7 @@ export const SpeakerTag = () => {
12
12
  <Flex
13
13
  align="center"
14
14
  justify="center"
15
- css={{ flex: '1 1 0', color: '$on_primary_high', '@md': { display: 'none' } }}
15
+ css={{ flex: '1 1 0', color: '$on_surface_high', '@md': { display: 'none' } }}
16
16
  >
17
17
  <VerticalDivider css={{ ml: '$8' }} />
18
18
  <VolumeOneIcon />
@@ -22,7 +22,6 @@ import {
22
22
  QuizIcon,
23
23
  RecordIcon,
24
24
  SettingsIcon,
25
- VirtualBackgroundIcon,
26
25
  } from '@100mslive/react-icons';
27
26
  import { Box, Loading, Tooltip } from '../../../..';
28
27
  import { Sheet } from '../../../../Sheet';
@@ -91,10 +90,10 @@ export const MwebOptions = ({
91
90
  const peerCount = useHMSStore(selectPeerCount);
92
91
  const emojiCardRef = useRef(null);
93
92
  const { isBRBOn, toggleBRB, isHandRaised, toggleHandRaise } = useMyMetadata();
94
- const { toggleAudio, toggleVideo, isLocalVideoEnabled } = useAVToggle();
93
+ const { toggleAudio, toggleVideo } = useAVToggle();
95
94
  const noAVPermissions = !(toggleAudio || toggleVideo);
96
95
  const { unreadPollQuiz, setUnreadPollQuiz } = useUnreadPollQuizPresent();
97
- const toggleVB = useSidepaneToggle(SIDE_PANE_OPTIONS.VB);
96
+ // const toggleVB = useSidepaneToggle(SIDE_PANE_OPTIONS.VB);
98
97
 
99
98
  useDropdownList({ open: openModals.size > 0 || openOptionsSheet || openSettingsSheet, name: 'MoreSettings' });
100
99
 
@@ -181,7 +180,7 @@ export const MwebOptions = ({
181
180
  </ActionTile.Root>
182
181
  ) : null}
183
182
 
184
- {isLocalVideoEnabled && !!elements?.virtual_background ? (
183
+ {/* {isLocalVideoEnabled && !!elements?.virtual_background ? (
185
184
  <ActionTile.Root
186
185
  onClick={() => {
187
186
  toggleVB();
@@ -191,7 +190,7 @@ export const MwebOptions = ({
191
190
  <VirtualBackgroundIcon />
192
191
  <ActionTile.Title>Virtual Background</ActionTile.Title>
193
192
  </ActionTile.Root>
194
- ) : null}
193
+ ) : null} */}
195
194
 
196
195
  {elements?.emoji_reactions && (
197
196
  <ActionTile.Root
@@ -103,7 +103,6 @@ const PreviewJoin = ({
103
103
  asRole,
104
104
  });
105
105
  const roomState = useHMSStore(selectRoomState);
106
-
107
106
  const savePreferenceAndJoin = useCallback(() => {
108
107
  setPreviewPreference({
109
108
  name,
@@ -268,7 +267,7 @@ export const PreviewControls = ({ hideSettings, vbEnabled }: { hideSettings: boo
268
267
  >
269
268
  <Flex css={{ gap: '$4' }}>
270
269
  <AudioVideoToggle />
271
- {vbEnabled ? <VBToggle /> : null}
270
+ {vbEnabled && !isMobile ? <VBToggle /> : null}
272
271
  </Flex>
273
272
  {!hideSettings ? <PreviewSettings /> : null}
274
273
  </Flex>
@@ -95,7 +95,7 @@ const Tile = ({ peerId, width = '100%', height = '100%' }: { peerId: string; wid
95
95
  {isFullscreen ? <ShrinkIcon /> : <ExpandIcon />}
96
96
  </StyledVideoTile.FullScreenButton>
97
97
  ) : null}
98
- {!isMobile && isMouseHovered && (
98
+ {!isMobile && isMouseHovered && !isFullscreen && (
99
99
  <Box
100
100
  css={{
101
101
  position: 'absolute',
@@ -70,9 +70,9 @@ export class VBPlugin {
70
70
  }
71
71
  };
72
72
 
73
- setPreset = (preset: string) => {
73
+ setPreset = async (preset: string) => {
74
74
  if (this.effectsPlugin) {
75
- this.effectsPlugin.setPreset(preset);
75
+ await this.effectsPlugin.setPreset(preset);
76
76
  }
77
77
  };
78
78
 
@@ -1,5 +1,10 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { selectEffectsKey, selectIsEffectsEnabled, selectLocalPeerRole } from '@100mslive/hms-video-store';
2
+ import {
3
+ selectAppData,
4
+ selectEffectsKey,
5
+ selectIsEffectsEnabled,
6
+ selectLocalPeerRole,
7
+ } from '@100mslive/hms-video-store';
3
8
  import { HMSEffectsPlugin, HMSVBPlugin, HMSVirtualBackgroundTypes } from '@100mslive/hms-virtual-background';
4
9
  import { VirtualBackgroundMedia } from '@100mslive/types-prebuilt/elements/virtual_background';
5
10
  import {
@@ -22,7 +27,7 @@ import { VBHandler } from './VBHandler';
22
27
  import { useSidepaneToggle } from '../AppData/useSidepane';
23
28
  // @ts-ignore
24
29
  import { useUISettings } from '../AppData/useUISettings';
25
- import { SIDE_PANE_OPTIONS, UI_SETTINGS } from '../../common/constants';
30
+ import { APP_DATA, SIDE_PANE_OPTIONS, UI_SETTINGS } from '../../common/constants';
26
31
  import { defaultMedia } from './constants';
27
32
 
28
33
  const iconDims = { height: '40px', width: '40px' };
@@ -42,9 +47,7 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
42
47
  const isEffectsEnabled = useHMSStore(selectIsEffectsEnabled);
43
48
  const effectsKey = useHMSStore(selectEffectsKey);
44
49
  const isPluginAdded = useHMSStore(selectIsLocalVideoPluginPresent(VBHandler?.getName() || ''));
45
- const [activeBackground, setActiveBackground] = useState<string | HMSVirtualBackgroundTypes>(
46
- (VBHandler?.getBackground() as string | HMSVirtualBackgroundTypes) || HMSVirtualBackgroundTypes.NONE,
47
- );
50
+ const background = useHMSStore(selectAppData(APP_DATA.background));
48
51
  const mediaList = backgroundMedia.length
49
52
  ? backgroundMedia.map((media: VirtualBackgroundMedia) => media.url || '')
50
53
  : defaultMedia;
@@ -71,8 +74,22 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
71
74
  hmsActions.addPluginToVideoTrack(vbObject as HMSVBPlugin, Math.floor(role.publishParams.video.frameRate / 2));
72
75
  }
73
76
  }
77
+ const handleDefaultBackground = async () => {
78
+ switch (background) {
79
+ case HMSVirtualBackgroundTypes.NONE: {
80
+ break;
81
+ }
82
+ case HMSVirtualBackgroundTypes.BLUR: {
83
+ await VBHandler.setBlur(blurAmount);
84
+ break;
85
+ }
86
+ default:
87
+ await VBHandler.setBackground(background);
88
+ }
89
+ };
90
+ handleDefaultBackground();
74
91
  }
75
- }, [hmsActions, role, isPluginAdded, isEffectsEnabled, effectsKey, track?.id]);
92
+ }, [hmsActions, role, isPluginAdded, isEffectsEnabled, effectsKey, track?.id, background, blurAmount]);
76
93
 
77
94
  useEffect(() => {
78
95
  if (!isVideoOn) {
@@ -120,7 +137,7 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
120
137
  value: HMSVirtualBackgroundTypes.NONE,
121
138
  onClick: async () => {
122
139
  await VBHandler.removeEffects();
123
- setActiveBackground(HMSVirtualBackgroundTypes.NONE);
140
+ hmsActions.setAppData(APP_DATA.background, HMSVirtualBackgroundTypes.NONE);
124
141
  },
125
142
  },
126
143
  {
@@ -129,16 +146,16 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
129
146
  value: HMSVirtualBackgroundTypes.BLUR,
130
147
  onClick: async () => {
131
148
  await VBHandler?.setBlur(blurAmount);
132
- setActiveBackground(HMSVirtualBackgroundTypes.BLUR);
149
+ hmsActions.setAppData(APP_DATA.background, HMSVirtualBackgroundTypes.BLUR);
133
150
  },
134
151
  },
135
152
  ]}
136
- activeBackground={activeBackground}
153
+ activeBackground={background}
137
154
  />
138
155
 
139
156
  {/* Slider */}
140
157
  <Flex direction="column" css={{ w: '100%', gap: '$8', mt: '$8' }}>
141
- {activeBackground === HMSVirtualBackgroundTypes.BLUR && isEffectsEnabled && effectsKey ? (
158
+ {background === HMSVirtualBackgroundTypes.BLUR && isEffectsEnabled && effectsKey ? (
142
159
  <Box>
143
160
  <Text variant="sm" css={{ color: '$on_surface_high', fontWeight: '$semiBold', mb: '$4' }}>
144
161
  Blur intensity
@@ -173,10 +190,10 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
173
190
  value: mediaURL,
174
191
  onClick: async () => {
175
192
  await VBHandler?.setBackground(mediaURL);
176
- setActiveBackground(mediaURL);
193
+ hmsActions.setAppData(APP_DATA.background, mediaURL);
177
194
  },
178
195
  }))}
179
- activeBackground={activeBackground}
196
+ activeBackground={background}
180
197
  />
181
198
  </Box>
182
199
  </Flex>
@@ -308,8 +308,7 @@ const HLSView = () => {
308
308
  align="center"
309
309
  justify="center"
310
310
  css={{
311
- width:
312
- videoRef.current && videoRef.current.clientWidth <= 720 ? `${videoRef.current.clientWidth}px` : '100%',
311
+ width: '100%',
313
312
  margin: '0 auto',
314
313
  height: '100%',
315
314
  }}