Manage Participants for Android

You have a basic video conference application with which you can video call your friends using a conference room. However, you do not control the conference nor have any information about the conference participants.

This tutorial will take you through some simple steps to follow to have a full participants’ list.

Step 1: Create the participants’ list

Note: The participants’ list is only visible when the user has joined the conference.

Layout modification

1. To modify the layout, edit the main_activity.xml file, adding the following content for Step 4:

<LinearLayout ...>
    ...

    <!-- Step 4. Put the layout changes for the view participants step here -->
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="users :" />

    <EditText
        android:id="@+id/participants"
        android:enabled="false"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <!-- Step 5. ...

</LinearLayout>

2. Modify the interface linking in the MainActivity class in MainActivity.java:

  • New method updateParticipants for MainActivity with the following implementation:
public void updateParticipants() {
    List<Participant> participantsList = VoxeetSDK.conference().getParticipants();
    List<String> names = new ArrayList<>();

    for (Participant participant : participantsList) {
        if (participant.streams().size() > 0) {
            names.add(participant.getInfo().getName());
        }
    }

    binding.participants.setText(TextUtils.join(", ", names));
}

Step 2: Add a participant to the list

Note: The participants’ list is updated upon receiving the participantJoined and participantLeft events, the same way the participants’ streams were added in the previous tutorial.

1. Add the following logic to the application:

  • Add a handler for the ParticipantAddedEvent.
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(ParticipantAddedEvent event) {
    updateParticipants();
}

Step 3: Remove a participant from the list

1. Add the following logic to the application:

  • Add a handler for the ParticipantUpdatedEvent.
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(ParticipantUpdatedEvent event) {
    updateParticipants();
}

Did this page help you?