|
1 | | -import { Alert, Box } from "@mui/material"; |
| 1 | +import { Alert, Box, Button } from "@mui/material"; |
2 | 2 | import { useEffect, useRef, useState } from "react"; |
3 | 3 | import promptlyLoader from "../../assets/images/promptly-loading.gif"; |
4 | 4 |
|
@@ -161,13 +161,13 @@ const createNewSession = async ( |
161 | 161 | const videoStyle = { |
162 | 162 | width: "100%", |
163 | 163 | height: "100%", |
164 | | - maxHeight: "440px", |
165 | 164 | objectFit: "cover", |
166 | 165 | }; |
167 | 166 |
|
168 | 167 | export const HeyGenRealtimeAvatar = (props) => { |
169 | 168 | const { processor, runProcessor } = props; |
170 | 169 | const [error, setError] = useState(null); |
| 170 | + const [overlayOpen, setOverlayOpen] = useState(false); |
171 | 171 | const videoRef = useRef(null); |
172 | 172 | const sessionRef = useRef(null); |
173 | 173 | const createSessionRef = useRef(null); |
@@ -196,17 +196,33 @@ export const HeyGenRealtimeAvatar = (props) => { |
196 | 196 | }, [processor, runProcessor]); |
197 | 197 |
|
198 | 198 | return ( |
199 | | - <Box> |
| 199 | + <Box |
| 200 | + sx={{ position: "relative" }} |
| 201 | + onMouseEnter={() => setOverlayOpen(true)} |
| 202 | + onMouseLeave={() => setOverlayOpen(false)} |
| 203 | + > |
200 | 204 | {error && ( |
201 | 205 | <Alert severity="error">{`${error.message}. Please refresh the app.`}</Alert> |
202 | 206 | )} |
203 | 207 | <video |
204 | 208 | ref={videoRef} |
205 | 209 | autoPlay |
206 | 210 | muted |
207 | | - style={videoStyle} |
208 | 211 | poster={promptlyLoader} |
| 212 | + style={{ |
| 213 | + ...videoStyle, |
| 214 | + ...{ opacity: overlayOpen ? 0.5 : 1 }, |
| 215 | + }} |
209 | 216 | /> |
| 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 | + )} |
210 | 226 | </Box> |
211 | 227 | ); |
212 | 228 | }; |
0 commit comments