@@ -182,9 +182,10 @@ let VideoCompBuilder = (function (props) {
182
182
return new UICompBuilder ( meetingStreamChildren , ( props ) => {
183
183
const videoRef = useRef < HTMLVideoElement > ( null ) ;
184
184
const conRef = useRef < HTMLDivElement > ( null ) ;
185
- const userNameRef = useRef < HTMLDivElement > ( null ) ;
185
+ const placeholderRef = useRef < HTMLDivElement > ( null ) ;
186
186
const [ userId , setUserId ] = useState ( ) ;
187
187
const [ userName , setUsername ] = useState ( "" ) ;
188
+ const [ showVideo , setVideo ] = useState ( true ) ;
188
189
189
190
useEffect ( ( ) => {
190
191
onResize ( ) ;
@@ -209,10 +210,10 @@ let VideoCompBuilder = (function (props) {
209
210
) {
210
211
if ( videoRef . current && videoRef . current ?. id == userId + "" ) {
211
212
videoRef . current . srcObject = null ;
212
- if ( userNameRef . current ) {
213
- userNameRef . current . textContent = userData . user ;
214
- }
213
+ setVideo ( false ) ;
215
214
}
215
+ } else {
216
+ setVideo ( true ) ;
216
217
}
217
218
client . on (
218
219
"user-published" ,
@@ -228,6 +229,7 @@ let VideoCompBuilder = (function (props) {
228
229
props . onEvent ( "videoOn" ) ;
229
230
}
230
231
const element = document . getElementById ( userId ) ;
232
+
231
233
if ( element ) {
232
234
remoteTrack . play ( userId ) ;
233
235
}
@@ -276,7 +278,7 @@ let VideoCompBuilder = (function (props) {
276
278
) ;
277
279
278
280
setUserId ( userData . user ) ;
279
- setUsername ( userData . user ) ;
281
+ setUsername ( userData . userName ) ;
280
282
}
281
283
} , [ props . userId . value ] ) ;
282
284
@@ -286,13 +288,25 @@ let VideoCompBuilder = (function (props) {
286
288
< ReactResizeDetector onResize = { onResize } >
287
289
< Container ref = { conRef } $style = { props . style } >
288
290
{ props . shareScreen || userId ? (
291
+ < >
289
292
< VideoContainer
290
293
onClick = { ( ) => props . onEvent ( "videoClicked" ) }
291
294
ref = { videoRef }
295
+ style = { { display : `${ showVideo ? "flex" : "none" } ` } }
292
296
$style = { props . style }
293
297
id = { props . shareScreen ? "share-screen" : userId }
294
298
> </ VideoContainer >
299
+ < TextContainer
300
+ onClick = { ( ) => props . onEvent ( "videoClicked" ) }
301
+ ref = { placeholderRef }
302
+ style = { { display : `${ ! showVideo ? "flex" : "none" } ` } }
303
+ $style = { props . style }
304
+ >
305
+ { userName ?? "No Username" }
306
+ </ TextContainer >
307
+ </ >
295
308
) : (
309
+ // )
296
310
< TextContainer $style = { props . style } >
297
311
< p > No Video</ p >
298
312
</ TextContainer >
0 commit comments