Skip to main content
Version: 5.x.x

Participant Class Events - Flutter

  • streamEnabled, streamDisabled, streamPaused, streamResumed and onE2EEStateChanged are delivered on the participant, for its own streams, and on the Room, for every participant. On the room, stream.participantId tells you whose stream it is.
  • An AI agent in the room is an AgentParticipant, and its isAgent() returns true. It delivers its own events, which you listen for with on() on the agent.

streamEnabled​

  • This event will be emitted on the participant, and on the Room, when the participant starts sending or receiving a stream of any type.
  • The stream is also added to that participant's streams.

Example​

participant.on(Events.streamEnabled, (RTCStream stream) {
if (stream.kind == MediaType.VIDEO) {
// do something
}
});

// Or, for every participant, on the room:
room.on(Events.streamEnabled, (RTCStream stream) {
if (stream.participantId == participant.id) {
// do something
}
});

streamDisabled​

  • This event will be emitted on the participant, and on the Room, when the participant stops sending or receiving a stream of any type.
  • The stream is also removed from that participant's streams.

Example​

participant.on(Events.streamDisabled, (RTCStream stream) {
// do something
});

streamPaused​

  • This event will be emitted on the participant, and on the Room, when a stream you receive from this participant is paused.
  • The handler receives the stream's kind (audio, video or share) and the reason.

Example​

participant.on(Events.streamPaused, (String? kind, String? reason) {
// do something
});

streamResumed​

  • This event will be emitted on the participant, and on the Room, when a paused stream you receive from this participant is resumed.
  • The handler receives the stream's kind (audio, video or share) and the reason.

Example​

participant.on(Events.streamResumed, (String? kind, String? reason) {
// do something
});

onE2EEStateChanged​

  • This event will be emitted on the participant, and on the Room, when the end-to-end encryption state of one of its streams changes.
  • It reports EncryptionSuccess or DecryptionSuccess when encryption of that stream starts. Decryption failures are not reported yet.
  • The handler receives the new E2EEState and the RTCStream it applies to. The stream is null when the participant no longer has it.

Example​

participant.on(Events.onE2EEStateChanged, (E2EEState state, RTCStream? stream) {
if (state == E2EEState.DecryptionSuccess) {
// show that this participant's media is encrypted end to end
}
});

agentStateChanged​

  • This event will be emitted on an AgentParticipant when the agent's state changes.
  • The handler receives the new AgentState: IDLE, LISTENING, THINKING or SPEAKING.

Example​

room.on(Events.participantJoined, (Participant participant) {
if (participant is AgentParticipant) {
participant.on(Events.agentStateChanged, (AgentState state) {
// do something
});
}
});

agentTranscriptionReceived​

  • This event will be emitted on an AgentParticipant when the agent sends a transcription segment.
  • The handler receives a TranscriptionSegment, with the text and its timestamp in milliseconds, and the Participant who spoke.

Example​

agent.on(Events.agentTranscriptionReceived,
(TranscriptionSegment segment, Participant participant) {
// do something with segment.text
});

agentMetrics​

  • This event will be emitted on an AgentParticipant when the agent sends metrics.
  • The handler receives the metrics as a Map<String, dynamic>.

Example​

agent.on(Events.agentMetrics, (Map<String, dynamic> metrics) {
// do something
});

Got a Question? Ask us on discord