Skip to main content

Call and Participant State

When a Call is created, users can subscribe to receive notifications about any changes that may occur during the call's lifecycle.

To access the state of a call, use call.state.value to obtain the latest CallState snapshot, or use valueStream to listen for real-time changes to the CallState.

This functionality is particularly useful for determining which parts of the UI or application to render based on the current state or lifecycle of the ongoing call. For example, you may want to display an indicator to users when a call is being recorded.

StreamBuilder<CallState>(
stream: call.state.valueStream, // Subscribe to state changes
builder: (context, snapshot) {
final state = snapshot.data;
if (state.isRecording) {
return CallRecordingUI();
} else {
return RegularCallUI();
}
},
),

Understanding Call Status

The CallStatus property of the CallState object indicates the current state of the call. Depending on where you are in the call lifecycle, CallStatus can have one of the following possible values.

Call StatusDescription
CallStatusIdleIndicates that there is no active call at the moment.
CallStatusIncomingIndicates that there’s an incoming call, and you need to display an incoming call screen.
CallStatusOutgoingIndicates that the user is making an outgoing call, and you need to display an outgoing call screen.
CallStatusConnecting
CallStatusReconnectingIndicates that the SDK is attempting to reconnect to the call. The number of attempts can be set via the attempt property.
CallStatusConnectedIndicates that the user is connected to the call and is ready to send and receive tracks.
CallStatusDisconnectedIndicates that the call has ended, failed, or has been canceled. The exact reason can be accessed via the DisconnectedReason property.
CallStatusJoining
CallStatusJoinedIndicates that the user has successfully joined the call.

By checking the CallStatus value in the CallState object, you can determine the current state of the call and adjust your UI accordingly.

Participant State

In the call state, you can find the parameter callParticipants. This parameter allows you to access and manipulate the participants present on the call. By using callParticipants, you can easily map over the participants and observe changes in their configuration.

For instance, you can keep track of which participant is currently speaking, which participant is the dominant speaker, and which participant is pinned to the call. Additionally, callParticipants allows you to monitor other changes to the call's configuration as well.

Overall, callParticipants is a powerful tool that provides you with a lot of control and insight into the call's current state and configuration. By leveraging this parameter effectively, you can create more advanced and robust call applications.

  • User Id
  • Role
  • Name
  • Image
  • Session Id
  • TrackId Prefix
  • PublishedTracks
  • Is Local
  • Connection Quality
  • Is Online
  • Audio Level
  • Is Speaking
  • Is Dominant Speaker
  • Is Pinned
  • Reaction
  • Viewport Visibility
for (final user in call.state.value.callParticipants){
if (user.isDominantSpeaker){
setState(() => dominantSpeaker = user);
}
}

Combining CallState and CallParticipantState makes building custom UIs and integrations a breeze. If there is a property or API that is not exposed for your specific use case, feel free to reach out to us. We are constantly iterating and exposing APIs based on your feedback.

Did you find this page helpful?