switchRole method
Switch roles (applicable only to the live streaming scenarios TRTCCloudDef.TRTC_APP_SCENE_LIVE and TRTCCloudDef.TRTC_APP_SCENE_VOICE_CHATROOM)
In the live streaming scenario, a user may need to switch between "audience" and "anchor" roles. You can use the role
field in TRTCParams before room entry to determine the role or use the switchRole API to switch roles after room entry.
Parameters:
role
Target role, which is anchor by default:
TRTCCloudDef.TRTCRoleAnchor
: anchor, who can upstream video and audio. Up to 50 anchors are allowed to upstream videos at the same time in one room.
TRTCCloudDef.TRTCRoleAudience
: audience, who can only watch the video but cannot upstream video or audio. There is no upper limit for the number of audience users in one room.
Implementation
Future<void> switchRole(int role // Target role, which is anchor by default:
) {
return _cloudChannel!.invokeMethod('switchRole', {
"role": role,
});
}