Active Speaker Indication - iOS
The Active Speaker indication feature in VideoSDK lets you know which participant in a room is the active speaker. This feature can be particularly useful in larger rooms or webinars, where there may be many participants and it can be difficult to tell who is speaking.
Whenever any participant speaks in the room, onSpeakerChanged event will trigger with the participant id of the active speaker. You can also read the current speaker at any time with room.getActiveSpeakerId().
For example, the room is running with Alice and Bob. Whenever any of them speaks, onSpeakerChanged event will trigger and return the speaker id as activeSpeakerId.
Event
- Swift
extension RoomViewController: RoomEventListener {
/// Called when speaker is changed
/// - Parameter activeSpeakerId: participant id of the active speaker
func onSpeakerChanged(activeSpeakerId: String?) {
// show indicator for active speaker
if let participant = participants.first(where: { $0.id == activeSpeakerId }) {
// show indication for active speaker
// ex. show border color
// cell.contentView.layer.borderColor = UIColor.blue.cgColor
print("\(participant.displayName) is speaking")
}
// hide indicator for others participants
let otherParticipants = participants.filter { $0.id != activeSpeakerId }
for participant in otherParticipants {
// ex. remove border color
//cell.contentView.layer.borderColor = UIColor.clear.cgColor
print("\(participant.displayName) is not speaking")
}
}
}
API Reference
The API references for all the methods and events utilised in this guide are provided below.
Got a Question? Ask us on discord

