controlMedia

suspend fun controlMedia(options: ControlMediaOptions)

Controls media for a participant in a room by sending a controlMedia event to the server.

This function allows specific users, like admins and authorized co-hosts, to manage the media (audio, video, screenshare, or all) for other participants in a room. The function checks permissions based on participant level, co-host responsibilities, and media type before sending a control request to the server. Unauthorized users receive an alert instead.

Logic Flow:

  1. Permission Check: Checks if the current user has permission to control media by verifying admin level or co-host responsibilities.

  2. Participant Lookup: Searches for the specified participant in the room.

  3. Media Type and Status Check: Based on the specified media type, checks the current state.

  4. Emit Control Event: If the user has permission and conditions are met, emits a controlMedia event with media details.

Example:

val options = ControlMediaOptions(
participantId = "participant-123",
participantName = "John Doe",
type = "audio",
socket = socket,
coHostResponsibility = myCoHostResponsibility,
participants = myParticipants,
member = "user-456",
islevel = "1",
showAlert = { msg, type, duration -> Logger.d("ControlMedia", msg) },
coHost = "cohost-789",
roomName = "Room 1"
)

controlMedia(options)

Parameters

options

Configuration and details for controlling media