control Media
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:
Permission Check: Checks if the current user has permission to control media by verifying admin level or co-host responsibilities.
Participant Lookup: Searches for the specified participant in the room.
Media Type and Status Check: Based on the specified media type, checks the current state.
Emit Control Event: If the user has permission and conditions are met, emits a
controlMediaevent 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
Configuration and details for controlling media