Skip to content

Commit

Permalink
Create audio-levels.mdx (#2280)
Browse files Browse the repository at this point in the history
* Create audio-levels.mdx

* Update audio-levels.mdx
  • Loading branch information
pawan-100ms authored and KaustubhKumar05 committed Jun 17, 2024
1 parent 7bc13d9 commit ea6f1cd
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Show Audio Levels
nav: 4.46
---

## Audio Level

The audio level for every speaking peer can be retrieved by listening to 'onUpdatedSpeakers' callback in 'HMSUpdateListener', like so.

```swift
public func on(updated speakers: [HMSSpeaker]) {
if let firstSpeakingPeer = speakers.first {
let audioLevel = firstSpeakingPeer.level
// Use this audio level
// level : `Int` The level of the audio. It may vary from 0-100. A higher value indicates a higher speaking volume.
...
}
}
```

Note: on(updated speakers) is called when set of speaking peers change in the conference call. These are called active speakers. If you'd live to know the current dominant speaker, you can just get the first speaker in the list as the speaker list is sorted based on their audio levels, that is, loudest speaker is first in the list.

0 comments on commit ea6f1cd

Please sign in to comment.