Events
Local User - Events
You can subscribe to various events on the local user by implementing
DyteSelfEventsListener and passing the object to
meeting.addSelfEventsListener(dyteSelfEventsListener).
Room joined
Triggered when the room join event completes and now the meeting is ready to produce and consume media.
extension MeetingViewModel: DyteSelfEventsListener {
func onRoomJoined() {
//Room Joined
}
}
Video update
Triggered when the user starts / stops the video using enableVideo or
disableVideo
extension MeetingViewModel: DyteSelfEventsListener {
func onVideoUpdate(videoEnabled: Bool) {
if (videoEnabled) {
// video is enabled, and other participants in room can see local user
} else {
// video is disabled, and other participants in room can not see local user.
}
}
}
Audio update
Triggered when the user starts / stops the audio using enableAudio or
disableAudio
extension MeetingViewModel: DyteSelfEventsListener {
func onAudioUpdate(audioEnabled: Bool) {
if (audioEnabled) {
// audio is enabled, and other participants in room can hear local user
} else {
// audio is disabled, and other participants in room can not hear local user.
}
}
}
Room disconnected update
Triggered when the user is disconnected due to media/network errors
extension MeetingViewModel: DyteSelfEventsListener {
func onMeetingRoomDisconnected() {
//disconnected
}
}
Proximity changed
Triggered when there is any change in proximity. Meaning if device is near ear piece which triggers display on/off.
extension MeetingViewModel: DyteSelfEventsListener {
func onProximityChanged(isNear: Bool) {
// isNear
// if true, display should be turned off, as user might be speaking through earpiece
// if false, display should be turned on, as user might be looking at display and listening through speaker/earphones.
}
}
Waitlist status
For meetings whose waiting room is enabled:
To get status of localUser in waiting room we can use
let waitListStatus = meeting.localUser.waitListStatus
Developers can listen to those changes in onWaitListStatusUpdate() callbacks
extension MeetingViewModel: DyteSelfEventsListener {
func onWaitListStatusUpdate(waitListStatus: WaitListStatus) {
}
}
Participants list events
You can subscribe to events for all participants by implementing
DyteParticipantEventsListener callback and then passing that object to
meeting.addParticipantEventsListener(dyteParticipantEventsListener) method.
Here are the supported methods:
Participant joined
Triggers an event when any participant joins the meeting.
extension MeetingViewModel: DyteParticipantEventsListener {
func onParticipantJoin(participant: DyteMeetingParticipant) {
// your code here to handle new participant
}
}
Participant left
Triggers an event when any participant leaves the meeting.
extension MeetingViewModel: DyteParticipantEventsListener {
func onParticipantLeave(participant: DyteMeetingParticipant) {
// your code here to handle participant left from meeting
}
}
Screenshare updates
Triggers an event when there is any change in screenshares in a meeting.
extension MeetingViewModel: DyteParticipantEventsListener {
func onScreenSharesUpdated() {
// your code here to handle screenshares from meeting
// you can use `meeting.participants.screenshares` to get latest screenshare participants
}
}
Grid change
Whenever there is a change in the GridInfo for the room, the following method is triggered. called.
extension MeetingViewModel: DyteParticipantEventsListener {
func onGridUpdated(gridInfo: GridInfo) {
// your code here to handle grid changes.
}
}
Video update
Trigger an event when any participant starts / stops video.
extension MeetingViewModel: DyteParticipantEventsListener {
func onVideoUpdate(videoEnabled: Bool, participant: DyteMeetingParticipant) {
// your code here to handle participant video toggle update
}
}
Audio update
Trigger an event when any participant starts / stops audio.
extension MeetingViewModel: DyteParticipantEventsListener {
func onAudioUpdate(audioEnabled: Bool, participant: DyteMeetingParticipant) {
// your code here to handle participant audio toggle update
}
}
Active speaker
Trigger an event when any is change in active speaker in the meeting.
extension MeetingViewModel: DyteParticipantEventsListener {
func onActiveSpeakerChanged(participant: DyteMeetingParticipant) {
// your code here to handle active speaker
}
func onNoActiveSpeaker() {
// your code here to handle no active speaker
}
}
Pinned participant
Trigger an event when any is change in pinned participant in the meeting.
extension MeetingViewModel: DyteParticipantEventsListener {
func onParticipantPinned(participant: DyteMeetingParticipant) {
// your code here to show pinned participant
}
func onParticipantUnpinned() {
// your code here to remove pinned participant
}
}
Active participants list change
Triggers an event when any change in active participants list in the meeting.
extension MeetingViewModel: DyteParticipantEventsListener {
func onActiveParticipantsChanged(active: [DyteMeetingParticipant]) {
// your code here to refresh active participants
}
}
Recording
The meeting.recording object can be used start and stop recordings in a
meeting. You can also get the current status of a recording using this API.
The meeting.recording object has the following properties:
recordingState: Indicates the current recording state of the meeting.
Get active recording state
The meeting.recording.recordingState property describes the current state of
the recording. The valid states are IDLE, STARTING, RECORDING, and
STOPPING.
Listen to recording state changes
The changes to meeting.recording.recordingState can be listened by
implementing onMeetingRecordingStateUpdated from
DyteMeetingRoomEventsListener. You can attach this observer by calling
meeting.addMeetingRoomEventsListener(listener).
meeting.addMeetingRoomEventsListener(object : DyteMeetingRoomEventsListener {
override fun onMeetingRecordingStarted() {
super.onMeetingRecordingStarted()
// on recording started
}
override fun onMeetingRecordingEnded() {
super.onMeetingRecordingEnded()
// on recording ended
}
override fun onMeetingRecordingStateUpdated(state: DyteRecordingState) {
super.onMeetingRecordingStateUpdated(state)
// on recording state update
}
override fun onMeetingRecordingStopError(e: Exception) {
super.onMeetingRecordingStopError(e)
// when local user tried to end recording but it fails
}
})