@@ -62,6 +62,15 @@ const Container = styled.div<{ $style: any }>`
62
62
align-items: center;
63
63
justify-content: center;
64
64
` ;
65
+ const TextContainer = styled . div < { $style : any } > `
66
+ height: 100%;
67
+ width: 100%;
68
+ display: flex;
69
+ align-items: center;
70
+ position: absolute;
71
+ justify-content: center;
72
+ ${ ( props ) => props . $style && getStyle ( props . $style ) }
73
+ ` ;
65
74
const VideoContainer = styled . video < { $style : any } > `
66
75
height: 100%;
67
76
width: 100%;
@@ -166,13 +175,16 @@ export const meetingStreamChildren = {
166
175
style : ButtonStyleControl ,
167
176
viewRef : RefControl < HTMLElement > ,
168
177
userId : stringExposingStateControl ( "" ) ,
178
+ noVideoText : stringExposingStateControl ( "No Video" ) ,
169
179
} ;
170
180
171
181
let VideoCompBuilder = ( function ( props ) {
172
182
return new UICompBuilder ( meetingStreamChildren , ( props ) => {
173
183
const videoRef = useRef < HTMLVideoElement > ( null ) ;
174
184
const conRef = useRef < HTMLDivElement > ( null ) ;
185
+ const userNameRef = useRef < HTMLDivElement > ( null ) ;
175
186
const [ userId , setUserId ] = useState ( ) ;
187
+ const [ userName , setUsername ] = useState ( "" ) ;
176
188
177
189
useEffect ( ( ) => {
178
190
onResize ( ) ;
@@ -181,21 +193,31 @@ let VideoCompBuilder = (function (props) {
181
193
const onResize = async ( ) => {
182
194
const container = conRef . current ;
183
195
let videoCo = videoRef . current ;
184
- videoCo ! . style . height = container ?. clientHeight + "px" ;
185
- videoCo ! . style . width = container ?. clientWidth + "px" ;
196
+ if ( videoCo ) {
197
+ videoCo ! . style . height = container ?. clientHeight + "px" ;
198
+ videoCo ! . style . width = container ?. clientWidth + "px" ;
199
+ }
186
200
} ;
187
201
useEffect ( ( ) => {
188
202
if ( props . userId . value !== "" ) {
189
203
let userData = JSON . parse ( props . userId ?. value ) ;
190
- if ( userData . user == userId && userData . streamingVideo == false && videoRef . current && videoRef . current ?. id == userId + "" ) {
204
+ if (
205
+ userData . user == userId &&
206
+ userData . streamingVideo == false &&
207
+ videoRef . current &&
208
+ videoRef . current ?. id == userId + ""
209
+ ) {
191
210
if ( videoRef . current && videoRef . current ?. id == userId + "" ) {
192
211
videoRef . current . srcObject = null ;
212
+ if ( userNameRef . current ) {
213
+ userNameRef . current . textContent = userData . user ;
214
+ }
193
215
}
194
216
}
195
217
client . on (
196
218
"user-published" ,
197
219
async ( user : IAgoraRTCRemoteUser , mediaType : "video" | "audio" ) => {
198
- if ( mediaType === "video" ) {
220
+ if ( mediaType === "video" ) {
199
221
const remoteTrack = await client . subscribe ( user , mediaType ) ;
200
222
let userId = user . uid + "" ;
201
223
if (
@@ -254,26 +276,29 @@ let VideoCompBuilder = (function (props) {
254
276
) ;
255
277
256
278
setUserId ( userData . user ) ;
279
+ setUsername ( userData . user ) ;
257
280
}
258
281
} , [ props . userId . value ] ) ;
259
282
260
- // useEffect(() => {
261
- // if (videoRef.current && videoRef.current?.id == userId + "") {
262
- // videoRef.current.srcObject = null;
263
- // }
264
- // }, []);
265
-
266
283
return (
267
284
< EditorContext . Consumer >
268
285
{ ( editorState ) => (
269
286
< ReactResizeDetector onResize = { onResize } >
270
287
< Container ref = { conRef } $style = { props . style } >
271
- < VideoContainer
272
- onClick = { ( ) => props . onEvent ( "videoClicked" ) }
273
- ref = { videoRef }
274
- $style = { props . style }
275
- id = { props . shareScreen ? "share-screen" : userId }
276
- > </ VideoContainer >
288
+ { props . shareScreen || userId ? (
289
+ < div style = { { position : "relative" } } >
290
+ < VideoContainer
291
+ onClick = { ( ) => props . onEvent ( "videoClicked" ) }
292
+ ref = { videoRef }
293
+ $style = { props . style }
294
+ id = { props . shareScreen ? "share-screen" : userId }
295
+ > </ VideoContainer >
296
+ </ div >
297
+ ) : (
298
+ < TextContainer $style = { props . style } >
299
+ < p > No Video</ p >
300
+ </ TextContainer >
301
+ ) }
277
302
</ Container >
278
303
</ ReactResizeDetector >
279
304
) }
0 commit comments