Manage Participants in a Session·续1

  1. Call disableAllAudio() on the participants object. If the local participant does not have the required permission, disableAllAudio() returns a HostError.
val error = meeting.participants.disableAllAudio()
if (error != null) {
    // Handle error - permission denied.
}
  1. Handle the result by listening for updates. After the call succeeds, each participant's audioEnabled becomes false.
meeting.addParticipantsEventListener(object : RtkParticipantsEventListener {
    override fun onAudioUpdate(participant: RtkRemoteParticipant, isEnabled: Boolean) {
        // audioEnabled is false
        // Update UI for the participant
    }
})
  1. Check that the local participant has permission to mute other participants' audio.
let canMuteAudio = meeting.localUser.permissions.host.canMuteAudio
if !canMuteAudio {
    // Disable the control in your UI.
}
  1. Call disableAllAudio() on the participants object. If the local participant does not have the required permission, disableAllAudio() returns a HostError.
if let error = meeting.participants.disableAllAudio() {
    // Handle error - permission denied.
}
  1. Handle the result by listening for updates. After the call succeeds, each participant's audioEnabled becomes false.
extension MeetingViewModel: RtkParticipantsEventListener {
    func onAudioUpdate(participant: RtkRemoteParticipant, isEnabled: Bool) {
        // audioEnabled is false
        // Update UI for the participant
    }
}

// Register the listener
meeting.addParticipantsEventListener(participantsEventListener: self)
  1. Check that the local participant has permission to mute other participants' audio.
const canDisableParticipantAudio = meeting.self.permissions.canDisableParticipantAudio;
if (!canDisableParticipantAudio) {
    // Disable the control in your UI.
}
  1. Call disableAllAudio() on the participants object.
meeting.participants
    .disableAllAudio(true)
    .catch((err) => {
        // Handle error - permission denied or other issue.
        console.log(err);
    });
  1. Handle the result by listening for updates. After the call succeeds, each participant's audioEnabled becomes false.
meeting.participants.joined.on('audioUpdate', (participant) => {
    // participant.audioEnabled is false
    // Update UI for the participant
});

Disable video

Disable video of participants when you need to moderate a session, enforce privacy, or prevent unwanted video during a classroom or webinar. This action requires the Mute Video (disable_participant_video) host control permission enabled in the local participant's preset.

Disable video for a participant

To disable a specific participant's video:

  1. Check that the local participant has permission to disable other participants' video.
   const canDisableVideo =
    meeting.self.permissions.canDisableParticipantVideo === true;
   if (!canDisableVideo) {
    // Disable the control in your UI.
   }
   ```

2. Call `disableVideo()` on the target participant.

If the local participant does not have the required permission, `disableVideo()` throws a `ClientError` with code `1201`.

```ts
   try {
    await participant.disableVideo();
   } catch (err: any) {
    if (err?.code === 1201) {
        // The local participant does not have permission to disable other participants’ video.
        return;
    }
    throw err;
   }
   ```

3. Handle the result by listening for updates.

After the call succeeds, the target participant's `videoEnabled` becomes `false`, and the SDK emits a `videoUpdate` event.

**Option A**: Listen on the participant object

```ts
   participant.on("videoUpdate", ({ videoEnabled, videoTrack }) => {
    // videoEnabled is false
    // Update UI for the participant
   });
   ```

**Option B**: Listen on the `joined` map

```ts
   meeting.participants.joined.on(
    "videoUpdate",
    (participant, { videoEnabled, videoTrack }) => {
        // videoEnabled is false
        // Update UI for the participant
    },
   );
   ```

1. Check that the local participant has permission to disable other participants' video.

```ts
   const canDisableVideo =
    meeting.self.permissions.canDisableParticipantVideo === true;
   if (!canDisableVideo) {
    // Disable the control in your UI.
   }
   ```

2. Call `disableVideo()` on the target participant.

If the local participant does not have the required permission, `disableVideo()` throws a `ClientError` with code `1201`.

```ts
   try {
    await participant.disableVideo();
   } catch (err: any) {
    if (err?.code === 1201) {
        // The local participant does not have permission to disable other participants’ video.
        return;
    }
    throw err;
   }
   ```

3. Handle the result by listening for updates.

After the call succeeds, the target participant's `videoEnabled` becomes `false`, and the SDK emits a `videoUpdate` event.

**Option A**: Listen on the participant object

```ts
   participant.on("videoUpdate", ({ videoEnabled, videoTrack }) => {
    // videoEnabled is false
    // Update UI for the participant
   });
   ```

**Option B**: Listen on the `joined` map

```ts
   meeting.participants.joined.on(
    "videoUpdate",
    (participant, { videoEnabled, videoTrack }) => {
        // videoEnabled is false
        // Update UI for the participant
    },
   );
   ```

1. Check that the local participant has permission to disable other participants' video.

```ts
   const canDisableVideo =
    meeting.self.permissions.canDisableParticipantVideo === true;
   if (!canDisableVideo) {
    // Disable the control in your UI.
   }
   ```

2. Call `disableVideo()` on the target participant.

If the local participant does not have the required permission, `disableVideo()` throws a `ClientError` with code `1201`.

```ts
   try {
    await participant.disableVideo();
   } catch (err: any) {
    if (err?.code === 1201) {
        // The local participant does not have permission to disable other participants’ video.
        return;
    }
    throw err;
   }
   ```

3. Handle the result by listening for updates.

After the call succeeds, the target participant's `videoEnabled` becomes `false`, and the SDK emits a `videoUpdate` event.

**Option A**: Listen on the participant object

```ts
   participant.on("videoUpdate", ({ videoEnabled, videoTrack }) => {
    // videoEnabled is false
    // Update UI for the participant
   });
   ```

**Option B**: Listen on the `joined` map

```ts
   meeting.participants.joined.on(
    "videoUpdate",
    (participant, { videoEnabled, videoTrack }) => {
        // videoEnabled is false
        // Update UI for the participant
    },
   );
   ```

1. Check that the local participant has permission to disable other participants' video.

```kotlin
val canMuteVideo = meeting.localUser.permissions.host.canMuteVideo
if (!canMuteVideo) {
    // Disable the control in your UI.
}
  1. Call disableVideo() on the target participant. If the local participant does not have the required permission, disableVideo() returns a HostError.
val error = participant.disableVideo()
if (error != null) {
    // Handle error - permission denied.
}
  1. Handle the result by listening for updates. After the call succeeds, the target participant's videoEnabled becomes false.
meeting.addParticipantsEventListener(object : RtkParticipantsEventListener {
    override fun onVideoUpdate(participant: RtkRemoteParticipant, isEnabled: Boolean) {
        // videoEnabled is false
        // Update UI for the participant
    }
})
  1. Check that the local participant has permission to disable other participants' video.
let canMuteVideo = meeting.localUser.permissions.host.canMuteVideo
if !canMuteVideo {
    // Disable the control in your UI.
}
  1. Call disableVideo() on the target participant. If the local participant does not have the required permission, disableVideo() returns a HostError.
if let error = participant.disableVideo() {
    // Handle error - permission denied.
}
  1. Handle the result by listening for updates. After the call succeeds, the target participant's videoEnabled becomes false.
extension MeetingViewModel: RtkParticipantsEventListener {
    func onVideoUpdate(participant: RtkRemoteParticipant, isEnabled: Bool) {
        // videoEnabled is false
        // Update UI for the participant
    }
}

// Register the listener
meeting.addParticipantsEventListener(participantsEventListener: self)
  1. Check that the local participant has permission to disable other participants' video.
const canDisableParticipantVideo = meeting.self.permissions.canDisableParticipantVideo;
if (!canDisableParticipantVideo) {
    // Disable the control in your UI.
}
  1. Call disableVideo() on the target participant.
participant
    .disableVideo()
    .catch((err) => {
        // Handle error - permission denied or other issue.
        console.log(err);
    });
  1. Handle the result by listening for updates. After the call succeeds, the target participant's videoEnabled becomes false.
meeting.participants.joined.on('videoUpdate', (participant) => {
    // participant.videoEnabled is false
    // Update UI for the participant
});

Disable video for all participants

This affects all participants, including the local participant. To disable video for all participants in the session:

  1. Check that the local participant has permission to disable other participants' video.
   const canDisableVideo =
    meeting.self.permissions.canDisableParticipantVideo === true;
   if (!canDisableVideo) {
    // Disable the control in your UI.
   }
   ```

2. Call `disableAllVideo()`.

If the local participant does not have the required permission, `disableAllVideo()` throws a `ClientError` with code `1201`.

```ts
   try {
    await meeting.participants.disableAllVideo();
   } catch (err: any) {
    if (err?.code === 1201) {
        // The local participant does not have permission to disable other participants’ video.
        return;
    }
    throw err;
   }
   ```

3. Handle the result by listening for updates.

After the call succeeds, each participant’s `videoEnabled` becomes `false`, and the SDK emits a `videoUpdate` event. The local participant also receives `videoUpdate` on `meeting.self`.

Listen to remote participant updates on the `joined` map:

```ts
   meeting.participants.joined.on(
    "videoUpdate",
    (participant, { videoEnabled, videoTrack }) => {
        // videoEnabled is false
        // Update UI for the participant
    },
   );
   ```

Listen to local participant update on `meeting.self`:

```ts
   meeting.self.on("videoUpdate", ({ videoEnabled, videoTrack }) => {
    // videoEnabled is false
    // Update UI for the local participant
   });
   ```

1. Check that the local participant has permission to disable other participants' video.

```ts
   const canDisableVideo =
    meeting.self.permissions.canDisableParticipantVideo === true;
   if (!canDisableVideo) {
    // Disable the control in your UI.
   }
   ```

2. Call `disableAllVideo()`.

If the local participant does not have the required permission, `disableAllVideo()` throws a `ClientError` with code `1201`.

```ts
   try {
    await meeting.participants.disableAllVideo();
   } catch (err: any) {
    if (err?.code === 1201) {
        // The local participant does not have permission to disable other participants’ video.
        return;
    }
    throw err;
   }
   ```

3. Handle the result by listening for updates.

After the call succeeds, each participant’s `videoEnabled` becomes `false`, and the SDK emits a `videoUpdate` event. The local participant also receives `videoUpdate` on `meeting.self`.

Listen to remote participant updates on the `joined` map:

```ts
   meeting.participants.joined.on(
    "videoUpdate",
    (participant, { videoEnabled, videoTrack }) => {
        // videoEnabled is false
        // Update UI for the participant
    },
   );
   ```

Listen to local participant update on `meeting.self`:

```ts
   meeting.self.on("videoUpdate", ({ videoEnabled, videoTrack }) => {
    // videoEnabled is false
    // Update UI for the local participant
   });
   ```

1. Check that the local participant has permission to disable other participants' video.

```ts
   const canDisableVideo =
    meeting.self.permissions.canDisableParticipantVideo === true;
   if (!canDisableVideo) {
    // Disable the control in your UI.
   }
   ```

2. Call `disableAllVideo()`.

If the local participant does not have the required permission, `disableAllVideo()` throws a `ClientError` with code `1201`.

```ts
   try {
    await meeting.participants.disableAllVideo();
   } catch (err: any) {
    if (err?.code === 1201) {
        // The local participant does not have permission to disable other participants’ video.
        return;
    }
    throw err;
   }
   ```

3. Handle the result by listening for updates.

After the call succeeds, each participant’s `videoEnabled` becomes `false`, and the SDK emits a `videoUpdate` event. The local participant also receives `videoUpdate` on `meeting.self`.

Listen to remote participant updates on the `joined` map:

```ts
   meeting.participants.joined.on(
    "videoUpdate",
    (participant, { videoEnabled, videoTrack }) => {
        // videoEnabled is false
        // Update UI for the participant
    },
   );
   ```

Listen to local participant update on `meeting.self`:

```ts
   meeting.self.on("videoUpdate", ({ videoEnabled, videoTrack }) => {
    // videoEnabled is false
    // Update UI for the local participant
   });
   ```

1. Check that the local participant has permission to disable other participants' video.

```kotlin
val canMuteVideo = meeting.localUser.permissions.host.canMuteVideo
if (!canMuteVideo) {
    // Disable the control in your UI.
}
  1. Call disableAllVideo() on the participants object. If the local participant does not have the required permission, disableAllVideo() returns a HostError.
val error = meeting.participants.disableAllVideo()
if (error != null) {
    // Handle error - permission denied.
}
  1. Handle the result by listening for updates. After the call succeeds, each participant's videoEnabled becomes false.
meeting.addParticipantsEventListener(object : RtkParticipantsEventListener {
    override fun onVideoUpdate(participant: RtkRemoteParticipant, isEnabled: Boolean) {
        // videoEnabled is false
        // Update UI for the participant
    }
})
  1. Check that the local participant has permission to disable other participants' video.
let canMuteVideo = meeting.localUser.permissions.host.canMuteVideo
if !canMuteVideo {
    // Disable the control in your UI.
}
  1. Call disableAllVideo() on the participants object. If the local participant does not have the required permission, disableAllVideo() returns a HostError.
if let error = meeting.participants.disableAllVideo() {
    // Handle error - permission denied.
}
  1. Handle the result by listening for updates. After the call succeeds, each participant's videoEnabled becomes false.
extension MeetingViewModel: RtkParticipantsEventListener {
    func onVideoUpdate(participant: RtkRemoteParticipant, isEnabled: Bool) {
        // videoEnabled is false
        // Update UI for the participant
    }
}

// Register the listener
meeting.addParticipantsEventListener(participantsEventListener: self)
  1. Check that the local participant has permission to disable other participants' video.
const canDisableParticipantVideo = meeting.self.permissions.canDisableParticipantVideo;
if (!canDisableParticipantVideo) {
    // Disable the control in your UI.
}