setClientRole abstract method

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

Sets the user role and audience latency level in live streaming.

By default, the SDK sets the user role to audience. You can call this method to set the user role to broadcaster. The user role (role) determines the user's privileges at the SDK level, such as whether they can publish streams. When the user role is set to broadcaster, the audience latency level only supports audienceLatencyLevelUltraLowLatency (ultra-low latency). If you call this method before joining a channel and set role to BROADCASTER, the local user will not receive the onClientRoleChanged callback.

  • role User role. See ClientRoleType. Users with the audience role cannot publish audio or video streams in the channel. When publishing in live streaming, make sure the user role is switched to broadcaster.
  • options User-specific settings, including 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. See Error Codes for details and resolution suggestions.

Implementation

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