setClientRole abstract method

Future<void> setClientRole({
  1. required ClientRoleType role,
  2. ClientRoleOptions? options,
})

Sets the user role and level in an interactive live streaming channel.

In the interactive live streaming profile, the SDK sets the user role as audience by default. You can call this method to set the user role as host. You can call this method either before or after joining a channel. If you call this method to set the user's role as the host before joining the channel and set the local video property through the setupLocalVideo method, the local video preview is automatically enabled when the user joins the channel. If you call this method to switch the user role after joining a channel, the SDK automatically does the following: Calls muteLocalAudioStream and muteLocalVideoStream to change the publishing state. Triggers onClientRoleChanged on the local client. Triggers onUserJoined or onUserOffline on the remote client. This method applies to the interactive live streaming profile (the profile parameter of setChannelProfile is set as channelProfileLiveBroadcasting) only.

  • role The user role in the interactive live streaming. See ClientRoleType.
  • options The detailed options of a user, including the user level. See ClientRoleOptions.

Returns When the method call succeeds, there is no return value; when fails, the AgoraRtcException exception is thrown. You need to catch the exception and handle it accordingly.

Implementation

Future<void> setClientRole(
    {required ClientRoleType role, ClientRoleOptions? options});