Skip to content

Commit 00c125e

Browse files
committed
Add overlay and close session button to HeyGenRealtimeAvatar component
1 parent 12bd18e commit 00c125e

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

llmstack/client/src/components/apps/HeyGenRealtimeAvatar.jsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Alert, Box } from "@mui/material";
1+
import { Alert, Box, Button } from "@mui/material";
22
import { useEffect, useRef, useState } from "react";
33
import promptlyLoader from "../../assets/images/promptly-loading.gif";
44

@@ -161,13 +161,13 @@ const createNewSession = async (
161161
const videoStyle = {
162162
width: "100%",
163163
height: "100%",
164-
maxHeight: "440px",
165164
objectFit: "cover",
166165
};
167166

168167
export const HeyGenRealtimeAvatar = (props) => {
169168
const { processor, runProcessor } = props;
170169
const [error, setError] = useState(null);
170+
const [overlayOpen, setOverlayOpen] = useState(false);
171171
const videoRef = useRef(null);
172172
const sessionRef = useRef(null);
173173
const createSessionRef = useRef(null);
@@ -196,17 +196,33 @@ export const HeyGenRealtimeAvatar = (props) => {
196196
}, [processor, runProcessor]);
197197

198198
return (
199-
<Box>
199+
<Box
200+
sx={{ position: "relative" }}
201+
onMouseEnter={() => setOverlayOpen(true)}
202+
onMouseLeave={() => setOverlayOpen(false)}
203+
>
200204
{error && (
201205
<Alert severity="error">{`${error.message}. Please refresh the app.`}</Alert>
202206
)}
203207
<video
204208
ref={videoRef}
205209
autoPlay
206210
muted
207-
style={videoStyle}
208211
poster={promptlyLoader}
212+
style={{
213+
...videoStyle,
214+
...{ opacity: overlayOpen ? 0.5 : 1 },
215+
}}
209216
/>
217+
{overlayOpen && (
218+
<Button
219+
sx={{ position: "absolute", left: "45%", top: "50%" }}
220+
variant="contained"
221+
onClick={() => closeSession(processor, runProcessor)}
222+
>
223+
Close Session
224+
</Button>
225+
)}
210226
</Box>
211227
);
212228
};

0 commit comments

Comments
 (0)