100ms Logo

100ms

Docs

Search docs
/

Show Audio Levels

Getting Audio Levels for all speaking peers

We can find the currently speaking peers from onUpdateSpeakers method of HMSUpdateListener

class Meeting implements HMSUpdateListener, HMSActionResultListener{ ... void onUpdateSpeakers({required List<HMSSpeaker> updateSpeakers}){ // This is called every 1 second with list of active speakers } }

Let's look at HMSSpeaker class

class HMSSpeaker { final HMSPeer peer; final HMSTrack track; final int audioLevel; }

Let's understand the properties of HMSSpeaker class:

  1. audioLevel : int -> The level of the audio. It may vary from 0-100. A higher value indicates a higher speaking volume.
  2. track : HMSTrack -> The audio track corresponding to the speaker.
  3. peer : HMSPeer -> The peer who is speaking.

Where can we use onUpdateSpeakers

Active Speaker Views

To maintain an active speaker view, such as the default view in the open source advanced sample app, you need to keep track of who the active speakers are over time. We'll be using the input from onUpdateSpeakers listener update as mentioned above and then building something that attempts to show all the active speakers while minimizing re-ordering/re-building the list.

Checkout the active speaker mode here

Dominant Speaker - the loudest speaker.

The updateSpeakers list returned in onUpdateSpeakers is already in descending order based on the audioLevel. So, the first element of the list will be loudest speaker.


Have a suggestion? Recommend changes ->

Was this helpful?

1234