ApsaraVideo Real-time Communication (ARTC) SDK for Web supports configuring channel modes and user roles to create different interactive experiences.
Set the channel mode
ARTC SDK for Web provides two channel modes, each optimized for different streaming scenarios.
To set the channel mode, you must call the setChannelProfile method before you join the channel. Channel mode settings after you join the channel do not take effect.
// Make sure that an AliRtcEngine instance is created.
// Call the method to set the channel mode.
aliRtcEngine.setChannelProfile('communication');
|
Argument |
Meaning |
Description |
Is default value |
|
communication |
The communication mode. |
All users can interact with each other. Suitable for online conferencing and calling. |
Yes |
|
interactive_live |
The interactive mode. |
Streamers can publish and subscribe to audio and video streams, while viewers can only subscribe. Suitable for conferencing and real-time communication. |
No |
Set the user role
In interactive_live mode, call the setClientRole method to assign roles to users. Two roles are available: interactive and live.
User role settings in communication mode do not take effect.
// Make sure that you set the channel mode to interactive_live. User role settings in communication mode do not take effect.
// You can set the user role at any time. For example, when a viewer wants to talk with the streamer, you can set the user role to interactive.
aliRtcEngine.setClientRole('interactive');
// When the talk ends, set the user role to live.
aliRtcEngine.setClientRole('live');
|
Argument |
Meaning |
Description |
Is default value |
|
interactive |
The streamer role. |
A streamer can publish and subscribe to audio and video streams. |
No |
|
live |
The viewer role. |
A viewer can only subscribe to audio and video streams. |
Yes |