Skip to main content
Version: 3.x.x

Layout and Grid Management - Android

In this guide, we will take a look at how to efficiently manage the participants in different types of layout.

Grid Layout​

The most common way to show participants is in a grid. There are multiple things you should keep in mind when showing participants in the grid.

This includes the number of participants being shown on the screens, number of participants in the background (in the room but not on the grid), and the video quality you receive for each participant in the grid.

Quality of Participant's Video​

When there are a large number of participants on the screen, it is best to receive their video in lower resolutions. For this we recommend you to call the setQuality method on the participants present in the grid with dynamic values based on the number of participants on the screen.

Here is the recommended video quality:

  1. Participants less than 3: setQuality(VideoQuality.HIGH)
  2. Participants between 3 to 4: setQuality(VideoQuality.MEDIUM)
  3. Participants greater than 4: setQuality(VideoQuality.LOW)

setQuality() is a suspend function, so call it from a coroutine. It takes a VideoQuality value. It does nothing when the participant already has that quality, so you can call it on every layout change.

Grid with Screen Share​

When you are rendering a small grid along with the screen share of the presenter or you are showing a simple sidebar video of the participants while the screenshare is on, it is recommended to do setQuality(VideoQuality.LOW) for the participants who are present in the sidebar.

Grid with Pagination​

If you are having large video calls where there are multiple speakers with video turned on, it is best to implement a pagination type setup where only a few (4-6) participants are shown on the grid and rest can be seen by changing the page.

To save bandwidth, pause the streams of the participants who are not in the grid and resume them when they come into the grid. You can follow this guide to pause/resume the stream.

note

You can get the sample code for grid with pagination here. The sample is built on SDK 2.x, so follow the Migration Guide for the 3.0.0 API.

Pause/Resume Stream​

To stop or resume receiving the streams (webcam, screenShare and mic) of a participant, use the pause and resume methods.

  • pause() and resume() are suspend functions. Call them from a coroutine, such as lifecycleScope.launch.
  • They work only on the streams of a remote participant that this device receives. The participant keeps sending them to everyone else.
  • They throw VideoSDKException, for example with 3054 (ERROR_ALREADY_IN_REQUESTED_STATE) when the stream is already paused, or when you resume a stream that is not paused.
  • participant.streams can change while the loop waits for each call, so copy it first, as in the examples below.

Pause stream​

  • pause() pauses a stream (webcam, screenShare or mic) of a particular participant.
lifecycleScope.launch {
for (stream in participant.streams.values.toList()) {
try {
stream.pause()
} catch (e: VideoSDKException) {
Log.e("VideoSDK", "pause() failed: ${e.code} ${e.name}")
}
}
}

Resume stream​

  • resume() resumes a stream (webcam, screenShare or mic) of a particular participant.
lifecycleScope.launch {
for (stream in participant.streams.values.toList()) {
try {
stream.resume()
} catch (e: VideoSDKException) {
Log.e("VideoSDK", "resume() failed: ${e.code} ${e.name}")
}
}
}

API Reference​

The API references for all the methods and events utilised in this guide are provided below.

Got a Question? Ask us on discord