Show Audio Level

Show Audio Level

You can also show audio levels in your UI corresponding to every peer so it's easier to see who is speaking currently. You can retrieve all the speaker object which will contain peerID, trackID and their audioLevel using selectSpeakers selector. You can fetch audio level for a particular peer using selectPeerAudioByID and for a particular track using selectTrackAudioByID selector.

You can also fetch the current active speaker using the selectDominantSpeaker selector.

import { selectPeerAudioByID, selectDominantSpeaker, selectSpeakers } from '@100mslive/hms-video-store'; const peerId = '..'; function updateAudioLevel(audioLevel) { console.log(`audio level for peer - ${peerID} is ${audioLevel}`); } hmsStore.subscribe(updateAudioLevel, selectPeerAudioByID(peerId)); console.log('all speakers', hmsStore.getState(selectSpeakers)); function activeSpeaker(peer, prevPeer) { console.log(`previous active speaker - ${} with role - ${prevPeer.roleName}`); console.log(`current active speaker - ${} with role - ${peer.roleName}`); } hmsStore.subscribe(activeSpeaker, selectDominantSpeaker);

Have a suggestion? Recommend changes ->

Was this helpful?