@@ -312,12 +312,7 @@ let MTComp = (function () {
312
312
const [ rtmMessages , setRtmMessages ] = useState < any > ( [ ] ) ;
313
313
314
314
useEffect ( ( ) => {
315
- dispatch (
316
- changeChildAction ( "participants" , getData ( userIds ) . data , false )
317
- ) ;
318
- } , [ userIds ] ) ;
319
-
320
- useEffect ( ( ) => {
315
+ console . log ( userIds ) ;
321
316
dispatch (
322
317
changeChildAction ( "participants" , getData ( userIds ) . data , false )
323
318
) ;
@@ -372,28 +367,51 @@ let MTComp = (function () {
372
367
} , [ rtmChannelResponse ] ) ;
373
368
374
369
useEffect ( ( ) => {
375
- client . on ( "user-joined" , ( user : IAgoraRTCRemoteUser ) => {
376
- let userData = {
377
- user : user . uid ,
378
- host : false ,
379
- audiostatus : user . hasVideo ,
380
- } ;
381
- if ( userIds . length == 0 ) {
382
- userData . host = true ;
383
- } else {
384
- userData . host = false ;
385
- }
386
- setUserIds ( ( userIds : any ) => [ ...userIds , userData ] ) ;
387
- } ) ;
388
- client . on ( "user-left" , ( user : IAgoraRTCRemoteUser , reason : any ) => {
389
- let newUsers = userIds . filter ( ( item : any ) => item . user !== user . uid ) ;
390
- let hostExists = newUsers . filter ( ( f : any ) => f . host === true ) ;
391
- if ( hostExists . length == 0 && newUsers . length > 0 ) {
392
- newUsers [ 0 ] . host = true ;
393
- hostChanged ( newUsers ) ;
394
- }
395
- setUserIds ( newUsers ) ;
396
- } ) ;
370
+ if ( client ) {
371
+ client . enableAudioVolumeIndicator ( ) ;
372
+ client . on ( "user-joined" , ( user : IAgoraRTCRemoteUser ) => {
373
+ let userData = {
374
+ user : user . uid ,
375
+ host : false ,
376
+ audiostatus : user . hasVideo ,
377
+ } ;
378
+
379
+ if ( userIds . length == 0 ) {
380
+ userData . host = true ;
381
+ } else {
382
+ userData . host = false ;
383
+ }
384
+ setUserIds ( ( userIds : any ) => [ ...userIds , userData ] ) ;
385
+ } ) ;
386
+ client . on ( "user-left" , ( user : IAgoraRTCRemoteUser , reason : any ) => {
387
+ let newUsers = userIds . filter (
388
+ ( item : any ) => item . user !== user . uid
389
+ ) ;
390
+ let hostExists = newUsers . filter ( ( f : any ) => f . host === true ) ;
391
+ if ( hostExists . length == 0 && newUsers . length > 0 ) {
392
+ newUsers [ 0 ] . host = true ;
393
+ hostChanged ( newUsers ) ;
394
+ }
395
+ setUserIds ( newUsers ) ;
396
+ } ) ;
397
+ client . on ( "volume-indicator" , ( volumeInfos : any ) => {
398
+ if ( volumeInfos . length == 0 ) return ;
399
+ volumeInfos . map ( ( volumeInfo : any ) => {
400
+ const speaking = volumeInfo . level >= 30 ;
401
+ if ( volumeInfo . uid == userId ) {
402
+ props . localUser . onChange ( {
403
+ ...props . localUser . value ,
404
+ speaking,
405
+ } ) ;
406
+ } else {
407
+ const userInfo = userIds . find (
408
+ ( info : any ) => info . user === volumeInfo . uid
409
+ ) ;
410
+ setUserIds ( [ ...userIds , { ...userInfo , speaking } ] ) ;
411
+ }
412
+ } ) ;
413
+ } ) ;
414
+ }
397
415
} , [ client ] ) ;
398
416
399
417
return (
@@ -579,7 +597,10 @@ MTComp = withMethodExposing(MTComp, [
579
597
comp . children . localUser . change ( {
580
598
user : userId + "" ,
581
599
audiostatus : false ,
600
+ speaking : false ,
582
601
} ) ;
602
+ console . log ( userId ) ;
603
+
583
604
await publishVideo (
584
605
comp . children . appId . getView ( ) ,
585
606
comp . children . meetingName . getView ( ) . value == ""
0 commit comments