diff --git a/src/components/StupWizard/index.tsx b/src/components/StupWizard/index.tsx index dae1699..9323f44 100644 --- a/src/components/StupWizard/index.tsx +++ b/src/components/StupWizard/index.tsx @@ -248,7 +248,9 @@ const AudioComponents = () => { useEffect(() => { getAudioMediaList() agora.registerEventHandler({ - onAudioVolumeIndication: (percentage: number) => { + onAudioVolumeIndication: (speakers: any) => { + const totalVolume = speakers.length ? speakers[0].volume : 0 + const percentage = (totalVolume / 255) * 100 const dom = document.getElementById('deviceTest') as any; if (dom) { dom.style.width = `${percentage}%` diff --git a/src/page/Meeting/index.tsx b/src/page/Meeting/index.tsx index 3140790..909a9ab 100644 --- a/src/page/Meeting/index.tsx +++ b/src/page/Meeting/index.tsx @@ -172,6 +172,9 @@ const Meeting: React.FC = () => { } return res }) + }, + onAudioVolumeIndication: async (speakers: any) => { + // console.log(speakers); } }) agora.startCameraCapture() @@ -349,6 +352,7 @@ const Meeting: React.FC = () => { setRoomUserList((res: any) => { res.forEach((item: any) => { if (item.uid === userInfo.uid) { + console.log(item.enableMicr, userInfo.uid,'哈哈哈哈哈哈哈'); const footerListTemplate = [...footerList] footerListTemplate[0][0].title = item.enableMicr ? '静音' : '解除静音' footerListTemplate[0][0].active = !item.enableMicr @@ -401,7 +405,7 @@ const Meeting: React.FC = () => { case 'OperAllMicr': setRoomUserList((res: any) => { res.forEach((row: any) => { - if (row.uid !== userInfo.uid) { + if (row.uid !== item.uid) { row.enableMicr = item.enableMicr } }) diff --git a/src/utils/package/agora.ts b/src/utils/package/agora.ts index f42b7f4..97940e0 100644 --- a/src/utils/package/agora.ts +++ b/src/utils/package/agora.ts @@ -87,6 +87,7 @@ const agora = { if (setting.playBackVolume) agora.setPlaybackDeviceVolume(setting.playBackVolume) // 设置播放设备音量 if (setting.ecordingDeviceId) agora.setRecordingDevice(setting.ecordingDeviceId) // 设置音频采集设备 if (setting.ecordingVolume) agora.setRecordingDeviceVolume(setting.ecordingVolume) // 设置音频设备音量 + rtcEngine.enableAudioVolumeIndication(200, 3, false) } }, 1000); }, @@ -118,9 +119,8 @@ const agora = { // } // }, // // 用户音量提示回调。 - onAudioVolumeIndication: async (_connection: any, _speakers: any, _speakerNumber: any, totalVolume: any,) => { - const percentage = (totalVolume / 255) * 100 - await onAudioVolumeIndication(percentage) + onAudioVolumeIndication: async (_connection: any, speakers: any, _speakerNumber: any, _totalVolume: any,) => { + await onAudioVolumeIndication(speakers) } }); }, diff --git a/src/utils/package/signalr.ts b/src/utils/package/signalr.ts index 7bb7fe4..2ec100d 100644 --- a/src/utils/package/signalr.ts +++ b/src/utils/package/signalr.ts @@ -103,10 +103,11 @@ export const onSignalr = (callBack: Function) => { }) }); // 所有用户开闭麦 - connection.on("OperAllMicr", (enableMicr: boolean) => { + connection.on("OperAllMicr", (enableMicr: boolean, uid: string) => { callBack({ key: 'OperAllMicr', - enableMicr + enableMicr, + uid }) }); // 用户关闭开启麦克风