MediaSFU Shared
    Preparing search index...

    Function controlMedia

    • Controls the media of a participant in a media session if certain conditions are met.

      Parameters

      • options: ControlMediaOptions

        The options for controlling media.

        • participantId

          The ID of the participant to control.

        • participantName

          The name of the participant to control.

        • type

          The type of media to control.

        • socket

          The socket instance for communication.

        • coHostResponsibility

          List of co-host responsibilities.

        • participants

          List of participants in the session.

        • member

          The current member attempting to control media.

        • islevel

          The level of the current member.

        • showAlert

          Optional function to show alerts.

        • coHost

          The co-host information.

        • roomName

          The name of the room.

      Returns Promise<void>

      A promise that resolves when the media control operation is complete.

      Will log an error message if there are issues controlling the media or if participant is not found.

      const options = {
      participantId: '1234',
      participantName: 'John Doe',
      type: 'audio',
      socket: socketInstance,
      coHostResponsibility: [{ name: 'media', value: true }],
      participants: participantList,
      member: 'Admin',
      islevel: '1',
      showAlert: (alert) => console.log(alert.message),
      coHost: 'CoHostName',
      roomName: 'Room 1',
      };

      controlMedia(options)
      .then(() => {
      console.log('Media control operation completed successfully.');
      })
      .catch((error) => {
      console.error('Error controlling media:', error);
      });