Manage Participants in a Session·续2

  1. Call disableAllVideo() on the participants object.
meeting.participants
    .disableAllVideo(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 videoEnabled becomes false.
meeting.participants.joined.on('videoUpdate', (participant) => {
    // participant.videoEnabled is false
    // Update UI for the participant
});

Pin participants

Pin a participant to highlight them, such as a webinar presenter or classroom teacher. This is a session-wide action. All participants will see the pinned participant as the focus. This action requires the Pin Participant (pin_participant) host control permission enabled in the local participant's preset.

Note

Only one participant can be pinned at a time. Pinning a new participant automatically unpins the previous one.

Pin a participant

To pin a participant in a session:

  1. Check that the local participant has permission to pin participants.
   const canPinParticipant = meeting.self.permissions.pinParticipant === true;
   if (!canPinParticipant) {
    // Disable the control in your UI.
   }
   ```

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

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

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

3. Handle the result by listening for updates.

After the call succeeds:
   - The target participant's `isPinned` becomes true.
   - The participant is added to `meeting.participants.pinned`.
   - The SDK emits a `pinned` event.

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

```ts
   participant.on("pinned", (updatedParticipant) => {
    // updatedParticipant.isPinned is true
    // Update your UI.
   });
   ```

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

```ts
   meeting.participants.joined.on("pinned", (updatedParticipant) => {
    // updatedParticipant.isPinned is true
    // Update your UI.
   });
   ```

If there was an existing pinned participant before, then the SDK emits an `unpinned` event for that participant.
4. On the target pinned participant's side, `meeting.self.isPinned` becomes `true` and `meeting.self` emits `pinned`:

```ts
   meeting.self.on("pinned", (selfParticipant) => {
    // Update the local UI to indicate the participant is pinned.
   });
   ```

1. Check that the local participant has permission to pin participants.

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

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

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

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

3. Handle the result by listening for updates.

After the call succeeds:
   - The target participant's `isPinned` becomes true.
   - The participant is added to `meeting.participants.pinned`.
   - The SDK emits a `pinned` event.

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

```ts
   participant.on("pinned", (updatedParticipant) => {
    // updatedParticipant.isPinned is true
    // Update your UI.
   });
   ```

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

```ts
   meeting.participants.joined.on("pinned", (updatedParticipant) => {
    // updatedParticipant.isPinned is true
    // Update your UI.
   });
   ```

If there was an existing pinned participant before, then the SDK emits an `unpinned` event for that participant.
4. On the target pinned participant's side, `meeting.self.isPinned` becomes `true` and `meeting.self` emits `pinned`:

```ts
   meeting.self.on("pinned", (selfParticipant) => {
    // Update the local UI to indicate the participant is pinned.
   });
   ```

1. Check that the local participant has permission to pin participants.

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

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

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

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

3. Handle the result by listening for updates.

After the call succeeds:
   - The target participant's `isPinned` becomes true.
   - The participant is added to `meeting.participants.pinned`.
   - The SDK emits a `pinned` event.

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

```ts
   participant.on("pinned", (updatedParticipant) => {
    // updatedParticipant.isPinned is true
    // Update your UI.
   });
   ```

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

```ts
   meeting.participants.joined.on("pinned", (updatedParticipant) => {
    // updatedParticipant.isPinned is true
    // Update your UI.
   });
   ```

If there was an existing pinned participant before, then the SDK emits an `unpinned` event for that participant.
4. On the target pinned participant's side, `meeting.self.isPinned` becomes `true` and `meeting.self` emits `pinned`:

```ts
   meeting.self.on("pinned", (selfParticipant) => {
    // Update the local UI to indicate the participant is pinned.
   });
   ```

1. Check that the local participant has permission to pin participants.

```kotlin
val canPinParticipant = meeting.localUser.permissions.host.canPinParticipant
if (!canPinParticipant) {
    // Disable the control in your UI.
}
  1. Call pin() on the target participant. If the local participant does not have the required permission, pin() returns a HostError.
val error = participant.pin()
if (error != null) {
    // Handle error - permission denied.
}
  1. Handle the result by listening for updates. After the call succeeds, the target participant's isPinned becomes true and the participant is available in meeting.participants.pinned.
meeting.addParticipantsEventListener(object : RtkParticipantsEventListener {
    override fun onParticipantPinned(participant: RtkRemoteParticipant) {
        // participant.isPinned is true
        // Update your UI.
    }
})
  1. Check that the local participant has permission to pin participants.
let canPinParticipant = meeting.localUser.permissions.host.canPinParticipant
if !canPinParticipant {
    // Disable the control in your UI.
}
  1. Call pin() on the target participant. If the local participant does not have the required permission, pin() returns a HostError.
if let error = participant.pin() {
    // Handle error - permission denied.
}
  1. Handle the result by listening for updates. After the call succeeds, the target participant's isPinned becomes true and the participant is available in meeting.participants.pinned.
extension MeetingViewModel: RtkParticipantsEventListener {
    func onParticipantPinned(participant: RtkRemoteParticipant) {
        // participant.isPinned is true
        // Update your UI.
    }
}

// Register the listener
meeting.addParticipantsEventListener(participantsEventListener: self)
  1. Check that the local participant has permission to pin participants.
const canPinParticipant = meeting.self.permissions.pinParticipant;
if (!canPinParticipant) {
    // Disable the control in your UI.
}
  1. Call pin() on the target participant.
participant.pin();
  1. Handle the result by listening for updates. After the call succeeds, the target participant's isPinned becomes true and the participant is available in meeting.participants.pinned.
meeting.participants.pinned.on('participantPinned', (participant) => {
    // participant.isPinned is true
    // Update your UI.
});

Unpin a participant

Unpin a participant when you need to undo the highlight and return the session to a standard grid or active speaker view. To unpin a pinned participant in a session:

  1. Check that the local participant has permission to unpin participants.
   const canUnpinParticipant = meeting.self.permissions.pinParticipant === true;
   if (!canUnpinParticipant) {
    // Disable the control in your UI.
   }
   ```

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

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

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

3. Handle the result by listening for updates.

After the call succeeds:
   - The target participant's `isPinned` becomes `false`.
   - The participant is removed from `meeting.participants.pinned`.
   - The SDK emits an `unpinned` event.

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

```ts
   participant.on("unpinned", (updatedParticipant) => {
    // updatedParticipant.isPinned is false
    // Update your UI.
   });
   ```

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

```ts
   meeting.participants.joined.on("unpinned", (updatedParticipant) => {
    // updatedParticipant.isPinned is false
    // Update your UI.
   });
   ```

4. On the target unpinned participant's side, `meeting.self.isPinned` becomes `false` and `meeting.self` emits `unpinned`:

```ts
   meeting.self.on("unpinned", (selfParticipant) => {
    // Update the local UI to indicate the participant is no longer pinned.
   });
   ```

1. Check that the local participant has permission to unpin participants.

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

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

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

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

3. Handle the result by listening for updates.

After the call succeeds:
   - The target participant's `isPinned` becomes `false`.
   - The participant is removed from `meeting.participants.pinned`.
   - The SDK emits an `unpinned` event.

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

```ts
   participant.on("unpinned", (updatedParticipant) => {
    // updatedParticipant.isPinned is false
    // Update your UI.
   });
   ```

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

```ts
   meeting.participants.joined.on("unpinned", (updatedParticipant) => {
    // updatedParticipant.isPinned is false
    // Update your UI.
   });
   ```

4. On the target unpinned participant's side, `meeting.self.isPinned` becomes `false` and `meeting.self` emits `unpinned`:

```ts
   meeting.self.on("unpinned", (selfParticipant) => {
    // Update the local UI to indicate the participant is no longer pinned.
   });
   ```

1. Check that the local participant has permission to unpin participants.

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

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

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

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

3. Handle the result by listening for updates.

After the call succeeds:
   - The target participant's `isPinned` becomes `false`.
   - The participant is removed from `meeting.participants.pinned`.
   - The SDK emits an `unpinned` event.

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

```ts
   participant.on("unpinned", (updatedParticipant) => {
    // updatedParticipant.isPinned is false
    // Update your UI.
   });
   ```

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

```ts
   meeting.participants.joined.on("unpinned", (updatedParticipant) => {
    // updatedParticipant.isPinned is false
    // Update your UI.
   });
   ```

4. On the target unpinned participant's side, `meeting.self.isPinned` becomes `false` and `meeting.self` emits `unpinned`:

```ts
   meeting.self.on("unpinned", (selfParticipant) => {
    // Update the local UI to indicate the participant is no longer pinned.
   });
   ```

1. Check that the local participant has permission to unpin participants.

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

// Register the listener
meeting.addParticipantsEventListener(participantsEventListener: self)
  1. Check that the local participant has permission to unpin participants.
const canPinParticipant = meeting.self.permissions.pinParticipant;
if (!canPinParticipant) {
    // Disable the control in your UI.
}
  1. Call unpin() on the target participant.
participant.unpin();
  1. Handle the result by listening for updates. After the call succeeds, the target participant's isPinned becomes false.
meeting.participants.pinned.on('unpinned', (participant) => {
    // participant.isPinned is false
    // Update your UI.
});

Remove participants

Remove participants from the session when you need to moderate disruptive behavior or enforce session rules. This action requires the Kick Participants (kick_participant) host control permission enabled in the local participant's preset.