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 the speaker object for any peer which will contain peerID, trackID and their audioLevel using selectSpeakerByPeerID selector.

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

import { selectSpeakerByPeerID, selectDominantSpeaker, } from '@100mslive/hms-video-store'; function updateAudioLevel(speaker) { console.log(`audio level for peer - ${speaker.peerID}, track - ${speaker.trackID} is ${speaker.audioLevel}`) } hmsStore.subscribe(updateAudioLevel, selectSpeakerByPeerID('<Peer ID>')); function activeSpeaker(peer, prevPeer) { console.log(`previous active speaker - ${prevPeer.name} with role - ${prevPeer.roleName}`) console.log(`current active speaker - ${peer.name} with role - ${peer.roleName}`) } hmsStore.subscribe(activeSpeaker, selectDominantSpeaker);