caution
Speaker Indication
Speaker indication feature in VideoSDK let you know, which participant in a meeting is active speaker.
Whenever any participant speaks in meeting, speaker-changed
event will trigger.
For example, the meeting is running with Alice and Bob. Whenever any of them speaks, speaker-changed
event will trigger and return the speaker participantId
.
We can access speaker-changed
event through meeting object.
speaker-changed Event
- JavaScript
- React
- ReactNative
- Android
- IOS
- Flutter
meeting.on("speaker-changed", (activeSpeakerId) => {
console.log("participantId", activeSpeakerId);
});
import { useMeeting } from "@videosdk.live/react-sdk";
/** useMeeting hooks events */
const {
/** Methods */
} = useMeeting({
onSpeakerChanged: (activeSpeakerId) => {
console.log("participantId", activeSpeakerId);
},
});
import { useMeeting } from "@videosdk.live/react-native-sdk";
/** useMeeting hooks events */
const {
/** Methods */
} = useMeeting({
onSpeakerChanged: (activeSpeakerId) => {
console.log("participantId", activeSpeakerId);
},
});
COMING SOON!
/// Called when speaker is changed
/// - Parameter participantId: participant id of the speaker, nil when no one is speaking.
func onSpeakerChanged(participantId: String?) {
// show indicator for active speaker
if let participant = participants.first(where: { $0.id == participantId }),
// show indication for active speaker
// ex. show border color
// cell.contentView.layer.borderColor = UIColor.blue.cgColor : UIColor.clear.cgColor
}
// hide indicator for others participants
let otherParticipants = participants.filter { $0.id != participantId }
for participant in otherParticipants {
// ex. remove border color
//cell.contentView.layer.borderColor = UIColor.clear.cgColor
}
}
meeting.on('speaker-changed', (activeSpeakerId) {
print("participantId => $activeSpeakerId");
});
Got a Question? Ask us on discord