@tellescope/video-chat 1.167.0 → 1.168.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/video-chat",
3
- "version": "1.167.0",
3
+ "version": "1.168.0",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -34,13 +34,13 @@
34
34
  "@fontsource/roboto": "^4.5.1",
35
35
  "@mui/icons-material": "^5.0.1",
36
36
  "@mui/material": "^5.0.2",
37
- "@tellescope/constants": "^1.167.0",
38
- "@tellescope/react-components": "^1.167.0",
39
- "@tellescope/sdk": "^1.167.0",
40
- "@tellescope/types-client": "^1.167.0",
41
- "@tellescope/types-models": "^1.167.0",
42
- "@tellescope/types-utilities": "^1.167.0",
43
- "@tellescope/utilities": "^1.167.0",
37
+ "@tellescope/constants": "^1.168.0",
38
+ "@tellescope/react-components": "^1.168.0",
39
+ "@tellescope/sdk": "^1.168.0",
40
+ "@tellescope/types-client": "^1.168.0",
41
+ "@tellescope/types-models": "^1.168.0",
42
+ "@tellescope/types-utilities": "^1.168.0",
43
+ "@tellescope/utilities": "^1.168.0",
44
44
  "@typescript-eslint/eslint-plugin": "^4.33.0",
45
45
  "@typescript-eslint/parser": "^4.33.0",
46
46
  "amazon-chime-sdk-component-library-react": "^3.7.0",
@@ -55,7 +55,7 @@
55
55
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
56
56
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
57
57
  },
58
- "gitHead": "c38c1cdd092cc5a0881c68117d88e98b83daed8e",
58
+ "gitHead": "2a92eab06c67bafc1445136c8e81dab4a94d260e",
59
59
  "publishConfig": {
60
60
  "access": "public"
61
61
  }
package/src/controls.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  // components that work with web or native
2
- import React from "react"
2
+ import React, { useCallback, useEffect, useState } from "react"
3
3
 
4
4
  import {
5
5
  VideoIcon,
@@ -9,14 +9,19 @@ import {
9
9
  CallEndIcon,
10
10
  LabeledIconButton,
11
11
  Flex,
12
- Paper,
13
12
  Styled,
14
13
  Button,
15
- Typography,
16
14
  } from "@tellescope/react-components"
17
15
  import { CurrentCallContext } from "./video_shared"
18
16
  import { useStartVideoCall } from "./video"
19
- import { BlurToggleIcon, ScreenShareIcon, useJoinVideoCall } from "."
17
+ import { useJoinVideoCall } from "."
18
+ import {
19
+ AudioInputControl,
20
+ AudioOutputControl,
21
+ ControlBar as BaseControlBar,
22
+ Camera, ContentShareControl, ControlBarButton, Phone, useBackgroundBlur, useMeetingManager, useVideoInputs
23
+ } from "amazon-chime-sdk-component-library-react"
24
+ import { isVideoTransformDevice } from "amazon-chime-sdk-js"
20
25
 
21
26
  const DEFAULT_BUTTON_SIZE = 30
22
27
  interface ButtonProps {
@@ -77,6 +82,43 @@ export const LeaveMeeting = ({ onLeave, size=DEFAULT_BUTTON_SIZE } : LeaveMeetin
77
82
  )
78
83
  }
79
84
 
85
+ const useToggleBlur = () => {
86
+ const meetingManager = useMeetingManager();
87
+ const { selectedDevice } = useVideoInputs();
88
+ const { isBackgroundBlurSupported, createBackgroundBlurDevice } = useBackgroundBlur();
89
+ const [isVideoTransformCheckBoxOn, setisVideoTransformCheckBoxOn] = useState(false);
90
+
91
+ useEffect(() => {
92
+ async function toggleBackgroundBlur() {
93
+ try {
94
+ let current = selectedDevice;
95
+ if (isVideoTransformCheckBoxOn) {
96
+ current = await createBackgroundBlurDevice(selectedDevice as any);
97
+ } else {
98
+ if (isVideoTransformDevice(selectedDevice)) {
99
+ current = await selectedDevice.intrinsicDevice();
100
+ }
101
+ }
102
+ await meetingManager.startVideoInputDevice(current!);
103
+ } catch (error) {
104
+ // Handle device selection failure here
105
+ console.error('Failed to toggle Background Blur');
106
+ }
107
+ }
108
+
109
+ toggleBackgroundBlur();
110
+ // eslint-disable-next-line
111
+ }, [isVideoTransformCheckBoxOn]);
112
+
113
+ const toggleBlur = useCallback(() => setisVideoTransformCheckBoxOn((current) => !current), [])
114
+
115
+ return {
116
+ blurIsActive: isVideoTransformCheckBoxOn,
117
+ isBackgroundBlurSupported,
118
+ toggleBlur,
119
+ }
120
+ };
121
+
80
122
  interface ControlbarProps {
81
123
  spacing?: number,
82
124
  size?: number,
@@ -88,52 +130,67 @@ export const ControlBar = ({ onLeave, style, spacing=15, size, showEndMeeting, s
88
130
  const { isHost } = React.useContext(CurrentCallContext)
89
131
  const itemStyle = { marginLeft: spacing, marginRight: spacing }
90
132
 
133
+ const { leaveMeeting } = useJoinVideoCall()
134
+ const { toggleVideo, videoIsEnabled: cameraActive } = React.useContext(CurrentCallContext)
135
+
136
+ const { blurIsActive, isBackgroundBlurSupported, toggleBlur } = useToggleBlur()
137
+ // const { backgroundIsActive, isBackgroundReplacementSupported, toggleBackground } = useToggleReplacement()
138
+
139
+ const cameraButtonProps = {
140
+ icon: cameraActive ? <Camera /> : <Camera disabled />,
141
+ isSelected: true,
142
+ popOver: ([
143
+ ...(
144
+ isBackgroundBlurSupported ?
145
+ [{
146
+ onClick: toggleBlur,
147
+ children: (
148
+ <span style={{ fontWeight: blurIsActive ? 'bold' : undefined}}>
149
+ {blurIsActive ? "Disable Blur" : "Blur Background"}
150
+ </span>
151
+ )
152
+ }]
153
+ : []
154
+ ),
155
+ // ...(
156
+ // isBackgroundReplacementSupported ?
157
+ // [{
158
+ // onClick: toggleBackground,
159
+ // children: (
160
+ // <span style={{ fontWeight: backgroundIsActive ? 'bold' : undefined}}>
161
+ // {backgroundIsActive ? "Remove Background Image" : "Use Background Image"}
162
+ // </span>
163
+ // )
164
+ // }]
165
+ // : []
166
+ // ),
167
+ ]),
168
+ onClick: toggleVideo,
169
+ label: 'Camera',
170
+ };
171
+
172
+ const hangUpButtonProps = {
173
+ icon: <Phone />,
174
+ onClick: leaveMeeting,
175
+ label: 'Leave',
176
+ };
177
+
91
178
  return (
92
- <Flex flex={1} alignItems="center" justifyContent="center" style={style}>
93
- <Paper elevation={5}
94
- style={{
95
- display: 'flex', flexDirection: 'row', padding: spacing,
96
- backgroundColor: '#00000088',
97
- borderColor: 'white',
98
- }}
99
- >
100
- {showScreenShare &&
101
- <Flex column justifyContent="center" style={itemStyle}>
102
- <Flex>
103
- <ScreenShareIcon />
104
- </Flex>
105
-
106
- <Flex>
107
- <Typography style={{ color: 'white', textAlign: 'center', fontSize: 11 }}>
108
- Screen share
109
- </Typography>
110
- </Flex>
111
- </Flex>
112
- }
113
- {showBlurToggle &&
114
- <Flex column justifyContent="center" style={itemStyle}>
115
- <Flex>
116
- <BlurToggleIcon />
117
- </Flex>
118
- </Flex>
119
- }
120
- {!showBlurToggle && // blur toggle also provides toggle video controls
121
- <Flex style={itemStyle}>
122
- <VideoToggle size={size}/>
123
- </Flex>
124
- }
125
- <Flex style={itemStyle}>
126
- <MicrophoneToggle size={size}/>
127
- </Flex>
128
- <Flex style={itemStyle}>
129
- <LeaveMeeting size={size} onLeave={onLeave}/>
179
+ <BaseControlBar showLabels={true} layout="bottom" css="position: absolute;"
180
+ style={style}
181
+ >
182
+ <AudioInputControl />
183
+ <AudioOutputControl />
184
+ <ControlBarButton {...cameraButtonProps} />
185
+ {showScreenShare && <ContentShareControl iconTitle="Screen" label="Share" />}
186
+ <ControlBarButton {...hangUpButtonProps} />
187
+
188
+ {(isHost || showEndMeeting) &&
189
+ <Flex style={{ marginLeft: 30, marginRight: 20 }}>
190
+ <EndMeeting size={size} onLeave={onLeave} />
130
191
  </Flex>
131
- {(isHost || showEndMeeting) &&
132
- <Flex style={{ marginLeft: 30, marginRight: 20 }}>
133
- <EndMeeting size={size} onLeave={onLeave} />
134
- </Flex>
135
- }
136
- </Paper>
137
- </Flex>
138
- )
192
+ }
193
+
194
+ </BaseControlBar>
195
+ );
139
196
  }
package/src/video.tsx CHANGED
@@ -42,6 +42,7 @@ import {
42
42
  useVideoInputs,
43
43
  useBackgroundReplacement,
44
44
  useAudioVideo,
45
+ BackgroundBlurProvider,
45
46
  // useRemoteVideoTileState,
46
47
  // useContentShareControls, // screen sharing
47
48
  } from 'amazon-chime-sdk-component-library-react';
@@ -252,9 +253,11 @@ const WithContext = ({ children } : { children: React.ReactNode }) => {
252
253
  export const WithVideo = ({ children }: VideoProps) => (
253
254
  <ThemeProvider theme={darkTheme}>
254
255
  <MeetingProvider>
256
+ <BackgroundBlurProvider>
255
257
  <WithContext>
256
258
  {children}
257
259
  </WithContext>
260
+ </BackgroundBlurProvider>
258
261
  </MeetingProvider>
259
262
  </ThemeProvider>
260
263
  )