This commit is contained in:
yj 2024-08-15 10:02:17 +08:00
parent 6e0e767f58
commit fabf47d0aa
4 changed files with 14 additions and 7 deletions

View File

@ -248,7 +248,9 @@ const AudioComponents = () => {
useEffect(() => { useEffect(() => {
getAudioMediaList() getAudioMediaList()
agora.registerEventHandler({ 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; const dom = document.getElementById('deviceTest') as any;
if (dom) { if (dom) {
dom.style.width = `${percentage}%` dom.style.width = `${percentage}%`

View File

@ -172,6 +172,9 @@ const Meeting: React.FC = () => {
} }
return res return res
}) })
},
onAudioVolumeIndication: async (speakers: any) => {
// console.log(speakers);
} }
}) })
agora.startCameraCapture() agora.startCameraCapture()
@ -349,6 +352,7 @@ const Meeting: React.FC = () => {
setRoomUserList((res: any) => { setRoomUserList((res: any) => {
res.forEach((item: any) => { res.forEach((item: any) => {
if (item.uid === userInfo.uid) { if (item.uid === userInfo.uid) {
console.log(item.enableMicr, userInfo.uid,'哈哈哈哈哈哈哈');
const footerListTemplate = [...footerList] const footerListTemplate = [...footerList]
footerListTemplate[0][0].title = item.enableMicr ? '静音' : '解除静音' footerListTemplate[0][0].title = item.enableMicr ? '静音' : '解除静音'
footerListTemplate[0][0].active = !item.enableMicr footerListTemplate[0][0].active = !item.enableMicr
@ -401,7 +405,7 @@ const Meeting: React.FC = () => {
case 'OperAllMicr': case 'OperAllMicr':
setRoomUserList((res: any) => { setRoomUserList((res: any) => {
res.forEach((row: any) => { res.forEach((row: any) => {
if (row.uid !== userInfo.uid) { if (row.uid !== item.uid) {
row.enableMicr = item.enableMicr row.enableMicr = item.enableMicr
} }
}) })

View File

@ -87,6 +87,7 @@ const agora = {
if (setting.playBackVolume) agora.setPlaybackDeviceVolume(setting.playBackVolume) // 设置播放设备音量 if (setting.playBackVolume) agora.setPlaybackDeviceVolume(setting.playBackVolume) // 设置播放设备音量
if (setting.ecordingDeviceId) agora.setRecordingDevice(setting.ecordingDeviceId) // 设置音频采集设备 if (setting.ecordingDeviceId) agora.setRecordingDevice(setting.ecordingDeviceId) // 设置音频采集设备
if (setting.ecordingVolume) agora.setRecordingDeviceVolume(setting.ecordingVolume) // 设置音频设备音量 if (setting.ecordingVolume) agora.setRecordingDeviceVolume(setting.ecordingVolume) // 设置音频设备音量
rtcEngine.enableAudioVolumeIndication(200, 3, false)
} }
}, 1000); }, 1000);
}, },
@ -118,9 +119,8 @@ const agora = {
// } // }
// }, // },
// // 用户音量提示回调。 // // 用户音量提示回调。
onAudioVolumeIndication: async (_connection: any, _speakers: any, _speakerNumber: any, totalVolume: any,) => { onAudioVolumeIndication: async (_connection: any, speakers: any, _speakerNumber: any, _totalVolume: any,) => {
const percentage = (totalVolume / 255) * 100 await onAudioVolumeIndication(speakers)
await onAudioVolumeIndication(percentage)
} }
}); });
}, },

View File

@ -103,10 +103,11 @@ export const onSignalr = (callBack: Function) => {
}) })
}); });
// 所有用户开闭麦 // 所有用户开闭麦
connection.on("OperAllMicr", (enableMicr: boolean) => { connection.on("OperAllMicr", (enableMicr: boolean, uid: string) => {
callBack({ callBack({
key: 'OperAllMicr', key: 'OperAllMicr',
enableMicr enableMicr,
uid
}) })
}); });
// 用户关闭开启麦克风 // 用户关闭开启麦克风