ParticipantsModule Overview
ParticipantsModule Overview
Participant

Participant

Exposes details of an individual participant in a video call effect.

Example

//============================================================================
// Retrieves information about the current participant and logs it to the
// console.
//
// Required project capabilities:
// - Participant (auto added on module import)
//
//============================================================================


// Load in the required modules
const Participants = require('Participants');
const Diagnostics = require('Diagnostics');

(async function() { // Enable async/await in JS [part 1]

  // Create a reference to the current participant and log their unique ID
  // to the console
  const self = await Participants.self;
  Diagnostics.log(self.id);

  //==========================================================================
  // Create references to whether the current participant is active in the
  // effect and/or call and monitor these values in the console.
  //==========================================================================

  const isActiveInCall = self.isActiveInCall;
 
  // Monitor when the participant joins or leaves the call
  isActiveInCall.monitor({fireOnInitialValue: true}).subscribe((event) => {
    Diagnostics.log(`Participant is active in call: ${event.newValue}`);
  });
 
  const isActiveInEffect = self.isActiveInSameEffect;
 
  // Monitor when the participant joins or leaves the effect
  isActiveInEffect.monitor({fireOnInitialValue: true}).subscribe((event) => {
    Diagnostics.log(`Participant is active in effect: ${event.newValue}`);
  });

})(); // Enable async/await in JS [part 2]

Properties

PropertyDescription
id
(get) id: string
(set) (Not Available)


The unique identifier for the specified participant.

You can pass this ID into the getParticipantById() method exposed by the Participants module to retrieve a specific participant.

IDs are constant for the duration of the video call but are not persistent across separate calls. If a participant drops out and rejoins the same video call they will retain the same ID.

However, if the video call ends and a new one is started, new unique identifiers are generated for each participant.
isActiveInCall
(get) isActiveInCall: BoolSignal
(set) (Not Available)


Whether the specified participant is currently active in the video call, as a BoolSignal.

If a participant leaves the video call this property will return false but the participant will not be removed from the array returned by Participants.getAllOtherParticipants() or subtracted from the value returned by Participants.otherParticipantCount.
isActiveInSameEffect
(get) isActiveInSameEffect: BoolSignal
(set) (Not Available)


Whether the specified participant is currently active in the same effect, as a BoolSignal.

This is distinct from isActiveInCall as a participant may be active in the video call but not necessarily be active in the running effect.

Methods

This module exposes no methods.

Was this article helpful?