@100mslive/roomkit-react 0.1.6-alpha.1 → 0.1.6-alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{HLSView-HNVYG5VE.js → HLSView-HL455FYH.js} +3 -3
- package/dist/Prebuilt/components/Footer/ChatToggle.d.ts +1 -3
- package/dist/Prebuilt/components/Leave/DesktopLeaveRoom.d.ts +2 -1
- package/dist/Prebuilt/components/Leave/MwebLeaveRoom.d.ts +2 -1
- package/dist/Prebuilt/components/SidePaneTabs.d.ts +7 -0
- package/dist/{VirtualBackground-UM2FOUHQ.js → VirtualBackground-6EP3X7MO.js} +6 -6
- package/dist/VirtualBackground-6EP3X7MO.js.map +7 -0
- package/dist/{chunk-LYSAET4G.js → chunk-6JF3GAOH.js} +109 -127
- package/dist/chunk-6JF3GAOH.js.map +7 -0
- package/dist/{chunk-POE7H4IE.js → chunk-KAJJ56J4.js} +2 -2
- package/dist/{chunk-POE7H4IE.js.map → chunk-KAJJ56J4.js.map} +1 -1
- package/dist/{chunk-364HP22I.js → chunk-UXBTLGWY.js} +2 -2
- package/dist/{conference-UWLJHMB2.js → conference-MPZNWHV5.js} +472 -415
- package/dist/conference-MPZNWHV5.js.map +7 -0
- package/dist/index.cjs.js +714 -678
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.js +2 -2
- package/dist/meta.cjs.json +153 -153
- package/dist/meta.esbuild.json +185 -184
- package/package.json +6 -6
- package/src/Button/Button.tsx +6 -6
- package/src/Prebuilt/components/Chat/Chat.jsx +3 -9
- package/src/Prebuilt/components/Chat/useEmojiPickerStyles.js +1 -0
- package/src/Prebuilt/components/Footer/ChatToggle.tsx +2 -9
- package/src/Prebuilt/components/Footer/Footer.tsx +23 -7
- package/src/Prebuilt/components/Footer/ParticipantList.jsx +4 -5
- package/src/Prebuilt/components/Footer/RoleAccordion.tsx +1 -1
- package/src/Prebuilt/components/Header/HeaderComponents.jsx +10 -9
- package/src/Prebuilt/components/InsetTile.tsx +1 -0
- package/src/Prebuilt/components/Leave/DesktopLeaveRoom.tsx +7 -9
- package/src/Prebuilt/components/Leave/LeaveRoom.tsx +6 -2
- package/src/Prebuilt/components/Leave/MwebLeaveRoom.tsx +7 -4
- package/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.tsx +1 -1
- package/src/Prebuilt/components/Notifications/Notifications.jsx +4 -3
- package/src/Prebuilt/components/Preview/PreviewJoin.tsx +2 -3
- package/src/Prebuilt/components/RoleChangeRequestModal.tsx +4 -3
- package/src/Prebuilt/components/ScreenshareTile.jsx +15 -7
- package/src/Prebuilt/components/SidePaneTabs.tsx +141 -0
- package/src/Prebuilt/components/conference.jsx +9 -1
- package/src/Prebuilt/components/hooks/useMetadata.jsx +7 -25
- package/src/Prebuilt/layouts/SidePane.tsx +12 -10
- package/src/Prebuilt/plugins/VirtualBackground/VirtualBackground.jsx +3 -3
- package/src/Prebuilt/provider/roomLayoutProvider/hooks/useFetchRoomLayout.ts +2 -2
- package/dist/VirtualBackground-UM2FOUHQ.js.map +0 -7
- package/dist/chunk-LYSAET4G.js.map +0 -7
- package/dist/conference-UWLJHMB2.js.map +0 -7
- package/src/Prebuilt/components/Chat/ChatParticipantHeader.jsx +0 -84
- /package/dist/{HLSView-HNVYG5VE.js.map → HLSView-HL455FYH.js.map} +0 -0
- /package/dist/{chunk-364HP22I.js.map → chunk-UXBTLGWY.js.map} +0 -0
@@ -0,0 +1,141 @@
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
2
|
+
import { useMedia } from 'react-use';
|
3
|
+
import { ConferencingScreen } from '@100mslive/types-prebuilt';
|
4
|
+
import { selectPeerCount, useHMSStore } from '@100mslive/react-sdk';
|
5
|
+
import { CrossIcon } from '@100mslive/react-icons';
|
6
|
+
// @ts-ignore: No implicit Any
|
7
|
+
import { Chat } from './Chat/Chat';
|
8
|
+
// @ts-ignore: No implicit Any
|
9
|
+
import { ParticipantList } from './Footer/ParticipantList';
|
10
|
+
import { config as cssConfig, Flex, IconButton, Tabs, Text } from '../..';
|
11
|
+
// @ts-ignore: No implicit Any
|
12
|
+
import { useRoomLayoutConferencingScreen } from '../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
|
13
|
+
// @ts-ignore: No implicit Any
|
14
|
+
import { useIsSidepaneTypeOpen, useSidepaneReset, useSidepaneToggle } from './AppData/useSidepane';
|
15
|
+
// @ts-ignore: No implicit Any
|
16
|
+
import { SIDE_PANE_OPTIONS } from '../common/constants';
|
17
|
+
|
18
|
+
const tabTriggerCSS = {
|
19
|
+
color: '$on_surface_high',
|
20
|
+
p: '$4',
|
21
|
+
fontWeight: '$semiBold',
|
22
|
+
fontSize: '$sm',
|
23
|
+
w: '100%',
|
24
|
+
justifyContent: 'center',
|
25
|
+
};
|
26
|
+
|
27
|
+
export const SidePaneTabs = React.memo<{
|
28
|
+
active: 'Participants | Chat';
|
29
|
+
screenType: keyof ConferencingScreen;
|
30
|
+
hideControls?: boolean;
|
31
|
+
}>(({ active = SIDE_PANE_OPTIONS.CHAT, screenType, hideControls }) => {
|
32
|
+
const toggleChat = useSidepaneToggle(SIDE_PANE_OPTIONS.CHAT);
|
33
|
+
const toggleParticipants = useSidepaneToggle(SIDE_PANE_OPTIONS.PARTICIPANTS);
|
34
|
+
const resetSidePane = useSidepaneReset();
|
35
|
+
const [activeTab, setActiveTab] = useState(active);
|
36
|
+
const peerCount = useHMSStore(selectPeerCount);
|
37
|
+
const { elements } = useRoomLayoutConferencingScreen();
|
38
|
+
const showChat = !!elements?.chat;
|
39
|
+
const showParticipants = !!elements?.participant_list;
|
40
|
+
const hideTabs = !(showChat && showParticipants);
|
41
|
+
const isMobile = useMedia(cssConfig.media.md);
|
42
|
+
const isOverlayChat = !!elements?.chat?.is_overlay && isMobile;
|
43
|
+
const isChatOpen = useIsSidepaneTypeOpen(SIDE_PANE_OPTIONS.CHAT);
|
44
|
+
|
45
|
+
useEffect(() => {
|
46
|
+
if (activeTab === SIDE_PANE_OPTIONS.CHAT && !showChat && showParticipants) {
|
47
|
+
setActiveTab(SIDE_PANE_OPTIONS.PARTICIPANTS);
|
48
|
+
} else if (activeTab === SIDE_PANE_OPTIONS.PARTICIPANTS && showChat && !showParticipants) {
|
49
|
+
setActiveTab(SIDE_PANE_OPTIONS.CHAT);
|
50
|
+
} else if (!showChat && !showParticipants) {
|
51
|
+
resetSidePane();
|
52
|
+
}
|
53
|
+
}, [showChat, activeTab, showParticipants, resetSidePane]);
|
54
|
+
|
55
|
+
useEffect(() => {
|
56
|
+
setActiveTab(active);
|
57
|
+
}, [active]);
|
58
|
+
|
59
|
+
return (
|
60
|
+
<Flex
|
61
|
+
direction="column"
|
62
|
+
css={{
|
63
|
+
color: '$on_primary_high',
|
64
|
+
h: '100%',
|
65
|
+
marginTop: hideControls && isOverlayChat ? '$17' : '0',
|
66
|
+
transition: 'margin 0.3s ease-in-out',
|
67
|
+
}}
|
68
|
+
>
|
69
|
+
{isOverlayChat && isChatOpen && showChat ? (
|
70
|
+
<Chat screenType={screenType} />
|
71
|
+
) : (
|
72
|
+
<>
|
73
|
+
{hideTabs ? (
|
74
|
+
<>
|
75
|
+
<Text variant="sm" css={{ fontWeight: '$semiBold', p: '$4', c: '$on_surface_high', pr: '$12' }}>
|
76
|
+
{showChat ? 'Chat' : `Participants (${peerCount})`}
|
77
|
+
</Text>
|
78
|
+
|
79
|
+
{showChat ? <Chat screenType={screenType} /> : <ParticipantList />}
|
80
|
+
</>
|
81
|
+
) : (
|
82
|
+
<Tabs.Root
|
83
|
+
value={activeTab}
|
84
|
+
onValueChange={setActiveTab}
|
85
|
+
css={{
|
86
|
+
flexDirection: 'column',
|
87
|
+
size: '100%',
|
88
|
+
}}
|
89
|
+
>
|
90
|
+
<Tabs.List css={{ w: 'calc(100% - $12)', p: '$2', borderRadius: '$2', bg: '$surface_default' }}>
|
91
|
+
<Tabs.Trigger
|
92
|
+
value={SIDE_PANE_OPTIONS.CHAT}
|
93
|
+
onClick={toggleChat}
|
94
|
+
css={{
|
95
|
+
...tabTriggerCSS,
|
96
|
+
color: activeTab !== SIDE_PANE_OPTIONS.CHAT ? '$on_surface_low' : '$on_surface_high',
|
97
|
+
}}
|
98
|
+
>
|
99
|
+
Chat
|
100
|
+
</Tabs.Trigger>
|
101
|
+
<Tabs.Trigger
|
102
|
+
value={SIDE_PANE_OPTIONS.PARTICIPANTS}
|
103
|
+
onClick={toggleParticipants}
|
104
|
+
css={{
|
105
|
+
...tabTriggerCSS,
|
106
|
+
color: activeTab !== SIDE_PANE_OPTIONS.PARTICIPANTS ? '$on_surface_low' : '$on_surface_high',
|
107
|
+
}}
|
108
|
+
>
|
109
|
+
Participants ({peerCount})
|
110
|
+
</Tabs.Trigger>
|
111
|
+
</Tabs.List>
|
112
|
+
<Tabs.Content value={SIDE_PANE_OPTIONS.PARTICIPANTS} css={{ p: 0 }}>
|
113
|
+
<ParticipantList />
|
114
|
+
</Tabs.Content>
|
115
|
+
<Tabs.Content value={SIDE_PANE_OPTIONS.CHAT} css={{ p: 0 }}>
|
116
|
+
<Chat screenType={screenType} />
|
117
|
+
</Tabs.Content>
|
118
|
+
</Tabs.Root>
|
119
|
+
)}
|
120
|
+
</>
|
121
|
+
)}
|
122
|
+
|
123
|
+
{isOverlayChat && isChatOpen ? null : (
|
124
|
+
<IconButton
|
125
|
+
css={{ position: 'absolute', right: '$10', top: '$11', '@md': { top: '$8', right: '$8' } }}
|
126
|
+
onClick={e => {
|
127
|
+
e.stopPropagation();
|
128
|
+
if (activeTab === SIDE_PANE_OPTIONS.CHAT) {
|
129
|
+
toggleChat();
|
130
|
+
} else {
|
131
|
+
toggleParticipants();
|
132
|
+
}
|
133
|
+
}}
|
134
|
+
data-testid="close_chat"
|
135
|
+
>
|
136
|
+
<CrossIcon />
|
137
|
+
</IconButton>
|
138
|
+
)}
|
139
|
+
</Flex>
|
140
|
+
);
|
141
|
+
});
|
@@ -49,6 +49,7 @@ const Conference = () => {
|
|
49
49
|
setHideControls(value => !value);
|
50
50
|
}
|
51
51
|
};
|
52
|
+
const autoRoomJoined = useRef(isPreviewScreenEnabled);
|
52
53
|
|
53
54
|
useEffect(() => {
|
54
55
|
let timeout = null;
|
@@ -84,7 +85,13 @@ const Conference = () => {
|
|
84
85
|
}, [isConnectedToRoom, prevState, roomState, navigate, role, roomId, isPreviewScreenEnabled]);
|
85
86
|
|
86
87
|
useEffect(() => {
|
87
|
-
if (
|
88
|
+
if (
|
89
|
+
authTokenInAppData &&
|
90
|
+
!isConnectedToRoom &&
|
91
|
+
!isPreviewScreenEnabled &&
|
92
|
+
roomState !== HMSRoomState.Connecting &&
|
93
|
+
!autoRoomJoined.current
|
94
|
+
) {
|
88
95
|
hmsActions
|
89
96
|
.join({
|
90
97
|
userName,
|
@@ -97,6 +104,7 @@ const Conference = () => {
|
|
97
104
|
},
|
98
105
|
})
|
99
106
|
.catch(console.error);
|
107
|
+
autoRoomJoined.current = true;
|
100
108
|
}
|
101
109
|
}, [authTokenInAppData, endpoints?.init, hmsActions, isConnectedToRoom, isPreviewScreenEnabled, roomState, userName]);
|
102
110
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useCallback
|
1
|
+
import { useCallback } from 'react';
|
2
2
|
import {
|
3
3
|
selectLocalPeerID,
|
4
4
|
selectPeerMetadata,
|
@@ -12,8 +12,6 @@ export const useMyMetadata = () => {
|
|
12
12
|
const localPeerId = useHMSStore(selectLocalPeerID);
|
13
13
|
const vanillaStore = useHMSVanillaStore();
|
14
14
|
const metaData = useHMSStore(selectPeerMetadata(localPeerId));
|
15
|
-
const [isHandRaised, setHandRaised] = useState(metaData?.isHandRaised || false);
|
16
|
-
const [isBRBOn, setBRBOn] = useState(metaData?.isBRBOn || false); // BRB = be right back
|
17
15
|
|
18
16
|
const update = async updatedFields => {
|
19
17
|
try {
|
@@ -27,28 +25,12 @@ export const useMyMetadata = () => {
|
|
27
25
|
};
|
28
26
|
|
29
27
|
const toggleHandRaise = useCallback(async () => {
|
30
|
-
|
31
|
-
|
32
|
-
isHandRaised: !isHandRaised,
|
33
|
-
isBRBOn: brbUpdate,
|
34
|
-
});
|
35
|
-
if (success) {
|
36
|
-
setBRBOn(brbUpdate);
|
37
|
-
setHandRaised(!isHandRaised);
|
38
|
-
}
|
39
|
-
}, [isHandRaised, isBRBOn]); //eslint-disable-line
|
28
|
+
await update({ isHandRaised: !metaData?.isHandRaised, isBRBOn: false });
|
29
|
+
}, [metaData?.isHandRaised]); //eslint-disable-line
|
40
30
|
|
41
31
|
const toggleBRB = useCallback(async () => {
|
42
|
-
|
43
|
-
|
44
|
-
isHandRaised: handRaiseUpdate,
|
45
|
-
isBRBOn: !isBRBOn,
|
46
|
-
});
|
47
|
-
if (success) {
|
48
|
-
setBRBOn(!isBRBOn);
|
49
|
-
setHandRaised(handRaiseUpdate);
|
50
|
-
}
|
51
|
-
}, [isHandRaised, isBRBOn]); //eslint-disable-line
|
32
|
+
await update({ isBRBOn: !metaData?.isBRBOn, isHandRaised: false });
|
33
|
+
}, [metaData?.isBRBOn]); //eslint-disable-line
|
52
34
|
|
53
35
|
const setPrevRole = async role => {
|
54
36
|
await update({
|
@@ -57,8 +39,8 @@ export const useMyMetadata = () => {
|
|
57
39
|
};
|
58
40
|
|
59
41
|
return {
|
60
|
-
isHandRaised,
|
61
|
-
isBRBOn,
|
42
|
+
isHandRaised: !!metaData?.isHandRaised,
|
43
|
+
isBRBOn: !!metaData?.isBRBOn,
|
62
44
|
metaData,
|
63
45
|
updateMetaData: update,
|
64
46
|
toggleHandRaise,
|
@@ -2,10 +2,7 @@ import React from 'react';
|
|
2
2
|
import { useMedia } from 'react-use';
|
3
3
|
import { ConferencingScreen } from '@100mslive/types-prebuilt';
|
4
4
|
import { selectAppData, selectVideoTrackByPeerID, useHMSStore } from '@100mslive/react-sdk';
|
5
|
-
|
6
|
-
import { Chat } from '../components/Chat/Chat';
|
7
|
-
// @ts-ignore: No implicit Any
|
8
|
-
import { ParticipantList } from '../components/Footer/ParticipantList';
|
5
|
+
import { SidePaneTabs } from '../components/SidePaneTabs';
|
9
6
|
// @ts-ignore: No implicit Any
|
10
7
|
import { StreamingLanding } from '../components/Streaming/StreamingLanding';
|
11
8
|
import { TileCustomisationProps } from '../components/VideoLayouts/GridLayout';
|
@@ -32,10 +29,8 @@ const SidePane = ({
|
|
32
29
|
const trackId = useHMSStore(selectVideoTrackByPeerID(activeScreensharePeerId))?.id;
|
33
30
|
const { elements } = useRoomLayoutConferencingScreen();
|
34
31
|
let ViewComponent;
|
35
|
-
if (sidepane === SIDE_PANE_OPTIONS.PARTICIPANTS) {
|
36
|
-
ViewComponent = <
|
37
|
-
} else if (sidepane === SIDE_PANE_OPTIONS.CHAT) {
|
38
|
-
ViewComponent = <Chat screenType={screenType} hideControls={hideControls} />;
|
32
|
+
if (sidepane === SIDE_PANE_OPTIONS.PARTICIPANTS || sidepane === SIDE_PANE_OPTIONS.CHAT) {
|
33
|
+
ViewComponent = <SidePaneTabs screenType={screenType} hideControls={hideControls} active={sidepane} />;
|
39
34
|
} else if (sidepane === SIDE_PANE_OPTIONS.STREAMING) {
|
40
35
|
ViewComponent = <StreamingLanding />;
|
41
36
|
}
|
@@ -43,6 +38,14 @@ const SidePane = ({
|
|
43
38
|
return null;
|
44
39
|
}
|
45
40
|
|
41
|
+
const tileLayout = {
|
42
|
+
hideParticipantNameOnTile: tileProps?.hide_participant_name_on_tile,
|
43
|
+
roundedVideoTile: tileProps?.rounded_video_tile,
|
44
|
+
hideAudioMuteOnTile: tileProps?.hide_audio_mute_on_tile,
|
45
|
+
hideMetadataOnTile: tileProps?.hide_metadata_on_tile,
|
46
|
+
objectFit: tileProps?.video_object_fit,
|
47
|
+
};
|
48
|
+
|
46
49
|
const mwebStreamingChat = isMobile && sidepane === SIDE_PANE_OPTIONS.CHAT && elements?.chat?.is_overlay;
|
47
50
|
|
48
51
|
return (
|
@@ -64,8 +67,7 @@ const SidePane = ({
|
|
64
67
|
width="100%"
|
65
68
|
height={225}
|
66
69
|
rootCSS={{ p: 0, alignSelf: 'start', flexShrink: 0 }}
|
67
|
-
|
68
|
-
{...tileProps}
|
70
|
+
{...tileLayout}
|
69
71
|
/>
|
70
72
|
)}
|
71
73
|
{!!ViewComponent && (
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
2
2
|
import { HMSVirtualBackgroundTypes } from '@100mslive/hms-virtual-background';
|
3
3
|
import {
|
4
|
-
|
4
|
+
selectIsLocalVideoEnabled,
|
5
5
|
selectIsLocalVideoPluginPresent,
|
6
6
|
selectLocalPeerRole,
|
7
7
|
selectLocalVideoTrackID,
|
@@ -23,8 +23,8 @@ export const VirtualBackground = ({
|
|
23
23
|
}) => {
|
24
24
|
const pluginRef = useRef(null);
|
25
25
|
const hmsActions = useHMSActions();
|
26
|
-
const isAllowedToPublish = useHMSStore(selectIsAllowedToPublish);
|
27
26
|
const role = useHMSStore(selectLocalPeerRole);
|
27
|
+
const isVideoOn = useHMSStore(selectIsLocalVideoEnabled);
|
28
28
|
const [isVBLoading, setIsVBLoading] = useState(false);
|
29
29
|
const [isVBSupported, setIsVBSupported] = useState(false);
|
30
30
|
const [isVBOn, setIsVBOn] = useState(false);
|
@@ -69,7 +69,7 @@ export const VirtualBackground = ({
|
|
69
69
|
}
|
70
70
|
}
|
71
71
|
|
72
|
-
if (!
|
72
|
+
if (!isVBSupported || !isVideoOn) {
|
73
73
|
return null;
|
74
74
|
}
|
75
75
|
if (asActionTile) {
|
@@ -29,7 +29,7 @@ export type useFetchRoomLayoutResponse = {
|
|
29
29
|
};
|
30
30
|
|
31
31
|
export const useFetchRoomLayout = ({
|
32
|
-
endpoint = '
|
32
|
+
endpoint = '',
|
33
33
|
authToken = '',
|
34
34
|
}: useFetchRoomLayoutProps): useFetchRoomLayoutResponse => {
|
35
35
|
const [layout, setLayout] = useState<Layout | undefined>(undefined);
|
@@ -51,7 +51,7 @@ export const useFetchRoomLayout = ({
|
|
51
51
|
}
|
52
52
|
isFetchInProgress.current = true;
|
53
53
|
try {
|
54
|
-
const resp = await fetchWithRetry(endpoint, {
|
54
|
+
const resp = await fetchWithRetry(endpoint || 'https://api.100ms.live/v2/layouts/ui', {
|
55
55
|
headers: {
|
56
56
|
Authorization: `Bearer ${authToken}`,
|
57
57
|
},
|
@@ -1,7 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"version": 3,
|
3
|
-
"sources": ["../src/Prebuilt/plugins/VirtualBackground/VirtualBackground.jsx", "../src/Prebuilt/plugins/VirtualBackground/vbutils.js"],
|
4
|
-
"sourcesContent": ["import React, { useEffect, useRef, useState } from 'react';\nimport { HMSVirtualBackgroundTypes } from '@100mslive/hms-virtual-background';\nimport {\n selectIsAllowedToPublish,\n selectIsLocalVideoPluginPresent,\n selectLocalPeerRole,\n selectLocalVideoTrackID,\n useHMSActions,\n useHMSStore,\n} from '@100mslive/react-sdk';\nimport { VirtualBackgroundIcon } from '@100mslive/react-icons';\nimport { ActionTile } from '../../components/MoreSettings/ActionTile';\nimport { Loading } from '../../../Loading';\nimport { Tooltip } from '../../../Tooltip';\nimport IconButton from '../../IconButton';\nimport { getRandomVirtualBackground } from './vbutils';\n\nexport const VirtualBackground = ({\n asActionTile = false,\n onVBClick = () => {\n return;\n },\n}) => {\n const pluginRef = useRef(null);\n const hmsActions = useHMSActions();\n const isAllowedToPublish = useHMSStore(selectIsAllowedToPublish);\n const role = useHMSStore(selectLocalPeerRole);\n const [isVBLoading, setIsVBLoading] = useState(false);\n const [isVBSupported, setIsVBSupported] = useState(false);\n const [isVBOn, setIsVBOn] = useState(false);\n const localPeerVideoTrackID = useHMSStore(selectLocalVideoTrackID);\n const isVBPresent = useHMSStore(selectIsLocalVideoPluginPresent('HMSVB'));\n\n async function createPlugin() {\n if (!pluginRef.current) {\n const { HMSVBPlugin } = await import('@100mslive/hms-virtual-background');\n pluginRef.current = new HMSVBPlugin(HMSVirtualBackgroundTypes.NONE, HMSVirtualBackgroundTypes.NONE);\n }\n }\n useEffect(() => {\n if (!localPeerVideoTrackID) {\n return;\n }\n createPlugin().then(() => {\n //check support of plugin\n const pluginSupport = hmsActions.validateVideoPluginSupport(pluginRef.current);\n setIsVBSupported(pluginSupport.isSupported);\n });\n }, [hmsActions, localPeerVideoTrackID]);\n\n async function addPlugin() {\n setIsVBLoading(true);\n try {\n await createPlugin();\n window.HMS.virtualBackground = pluginRef.current;\n const { background, backgroundType } = getRandomVirtualBackground();\n await pluginRef.current.setBackground(background, backgroundType);\n await hmsActions.addPluginToVideoTrack(pluginRef.current, Math.floor(role.publishParams.video.frameRate / 2));\n } catch (err) {\n console.error('add virtual background plugin failed', err);\n }\n setIsVBLoading(false);\n }\n\n async function removePlugin() {\n if (pluginRef.current) {\n await hmsActions.removePluginFromVideoTrack(pluginRef.current);\n pluginRef.current = null;\n }\n }\n\n if (!isAllowedToPublish.video || !isVBSupported) {\n return null;\n }\n if (asActionTile) {\n return (\n <ActionTile.Root\n data-testid=\"virtual_bg_btn\"\n active={isVBPresent}\n disabled={isVBLoading}\n onClick={() => {\n setIsVBOn(!isVBOn);\n !isVBPresent ? addPlugin() : removePlugin();\n onVBClick();\n }}\n >\n <VirtualBackgroundIcon />\n <ActionTile.Title>Virtual Background</ActionTile.Title>\n </ActionTile.Root>\n );\n }\n\n return (\n <Tooltip\n boxCss={{ zIndex: '100' }}\n title={isVBLoading ? 'Adding virtual background' : `Turn ${!isVBPresent ? 'on' : 'off'} virtual background`}\n >\n <IconButton\n active={!isVBPresent}\n disabled={isVBLoading}\n onClick={() => {\n !isVBPresent ? addPlugin() : removePlugin();\n }}\n data-testid=\"virtual_bg_btn\"\n >\n {isVBLoading ? <Loading /> : <VirtualBackgroundIcon />}\n </IconButton>\n </Tooltip>\n );\n};\n\nexport default VirtualBackground;\n", "/* eslint-disable no-case-declarations */\nimport { HMSVirtualBackgroundTypes } from '@100mslive/hms-virtual-background';\nexport function getRandomVirtualBackground() {\n const backgroundList = [\n {\n background: HMSVirtualBackgroundTypes.BLUR,\n backgroundType: HMSVirtualBackgroundTypes.BLUR,\n },\n ];\n\n const images = [\n 'https://www.100ms.live/images/vb-1.jpeg',\n 'https://www.100ms.live/images/vb-2.jpg',\n 'https://www.100ms.live/images/vb-3.png',\n 'https://d2qi07yyjujoxr.cloudfront.net/webapp/vb/hms1.png',\n 'https://d2qi07yyjujoxr.cloudfront.net/webapp/vb/hms2.png',\n 'https://d2qi07yyjujoxr.cloudfront.net/webapp/vb/hms3.png',\n 'https://d2qi07yyjujoxr.cloudfront.net/webapp/vb/hms4.png',\n ].map(url => ({\n background: url,\n backgroundType: HMSVirtualBackgroundTypes.IMAGE,\n }));\n\n backgroundList.push(...images);\n\n /* \n //TODO: update with a better quality gif.\n const gifList = [\n {\n background: \"https://www.100ms.live/images/vb-1.gif\",\n backgroundType: HMSVirtualBackgroundTypes.GIF,\n },\n ];\n backgroundList.push(...gifList); \n */\n\n const videoList = [\n 'https://www.100ms.live/images/video-1.mp4',\n 'https://www.100ms.live/images/video-2.mp4',\n 'https://www.100ms.live/images/video-5.mp4',\n 'https://www.100ms.live/images/video-7.mp4',\n 'https://www.100ms.live/images/video-8.mp4',\n ].map(url => ({\n background: url,\n backgroundType: HMSVirtualBackgroundTypes.VIDEO,\n }));\n backgroundList.push(...videoList);\n\n const randomIdx = Math.floor(Math.random() * backgroundList.length);\n const virtualBackground = backgroundList[randomIdx];\n switch (virtualBackground.backgroundType) {\n case HMSVirtualBackgroundTypes.IMAGE:\n const img = document.createElement('img');\n img.alt = 'VB';\n img.src = backgroundList[randomIdx].background;\n virtualBackground.background = img;\n return virtualBackground;\n case HMSVirtualBackgroundTypes.VIDEO:\n const videoEl = document.createElement('video');\n videoEl.src = backgroundList[randomIdx].background;\n virtualBackground.background = videoEl;\n return virtualBackground;\n default:\n return virtualBackground;\n }\n}\n"],
|
5
|
-
"mappings": ";;;;;;;;;;;AAAA,OAAO,SAAS,WAAW,QAAQ,gBAAgB;AACnD,SAAS,6BAAAA,kCAAiC;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6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