- meetingSDK: version 3.12
- react: version 18.2.0
*Sorry if it’s hard to read as my English is not good and I’m using the translate function.
We would like to implement a function that detects the status of voice communication during a Zoom conference and changes the background color of the icon if the status is bad.
Now the code is written as follows, but I can’t get it to work.
Since console.log is not output, it is assumed that it is not being called.
There is not enough information about audio-statistic-data-change to know what is missing in this code.
I’d appreciate any insight you can give me.
const handleAudioStatisticDataChange = useCallback(
(payload: { data: { avg_loss: number; jitter: number } }) => {
const avg_loss = payload.data.avg_loss
const jitter = payload.data.jitter
console.log('handleAudioStatisticDataChange', avg_loss, jitter)
const AVG_LOSS_THRESHOLD = 5
const JITTER_THRESHOLD = 30
let newLevel = networkQualityRef.current.level
console.log('newLevel1', newLevel)
if (avg_loss < AVG_LOSS_THRESHOLD && jitter < JITTER_THRESHOLD) {
newLevel = 4
} else if (avg_loss < AVG_LOSS_THRESHOLD || jitter < JITTER_THRESHOLD) {
newLevel = 3
} else {
newLevel = 1
}
console.log('newLevel2', newLevel)
const newNetworkQuality = {
level: newLevel,
label: getNetworkQualityText(newLevel),
}
setNetworkQuality(newNetworkQuality)
networkQualityRef.current = newNetworkQuality
},
[getNetworkQualityText],
)
client
.init({
zoomAppRoot: meetingSDKElement,
language: 'jp-JP',
~~~~~
})
.then(() => {
client.on('audio-statistic-data-change', handleAudioStatisticDataChange)
useEffect(() => {
client.on('audio-statistic-data-change', handleAudioStatisticDataChange)
return () => {
client.off('audio-statistic-data-change', handleAudioStatisticDataChange)
}
}, [client, handleAudioStatisticDataChange])