This topic describes the API operations for chit-chat room scenarios on Android.
API overview
Category | API operation | Description |
ARTCVoiceRoomEngine Chit-chat room engine | Initializes an engine instance. | |
Releases an engine instance. | ||
Adds an observer to listen for a room event callback. | ||
Removes the observer that listens for a room event callback | ||
Queries the information about the chit-chat room. | ||
Queries whether a user is the owner of the chit-chat room. | ||
Queries whether a user joins the chit-chat room. | ||
Joins the chit-chat room. | ||
Leaves the chit-chat room. | ||
Terminates the chit-chat room. Only the streamer can terminate the chit-chat room. | ||
Queries whether co-streaming is started. | ||
Directly starts co-streaming. | ||
Stops co-streaming. | ||
Applies for co-streaming. | ||
Turns on or off your microphone. | ||
Switches the audio output between your microphone and earpiece. | ||
Enables or disables in-ear monitoring. | ||
Specifies the audio recording volume. Default value: 50. Valid values: [0,100]. | ||
Starts or stops the playback of a sound effect. | ||
Specifies the volume of a sound effect. | ||
Starts or stops the playback of the background music. | ||
Specifies the volume of the background music. | ||
Specifies the voice changer effect. | ||
Specifies the reverberation mode. | ||
Sends a live comment. | ||
Sends a signaling message. | ||
ARTCVoiceRoomEngineDelegate Chit-chat room engine delegate | Indicates that you join the chit-chat room. | |
Indicates that you leave the chit-chat room. | ||
Indicates that a user joins the chit-chat room. | ||
Indicates that a user leaves the chit-chat room. | ||
Indicates that you are removed from the chit-chat room. | ||
Indicates that the chit-chat room is terminated. | ||
Indicates that the number of users in the chit-chat room changes. | ||
Indicates that a user starts co-streaming. | ||
Indicates that a user stops co-streaming. | ||
Indicates whether the microphone of the co-streamer is turned on or off. | ||
Indicates whether the co-streamer is speaking. | ||
Indicates that the network status changes. | ||
Indicates that the playback status of your background music changes. The playback may start, stop, or fail. | ||
Indicates that a live comment is sent to you. | ||
Indicates that an error occurred. |
Details of ARTCVoiceRoomEngine
init
Description: initializes an engine instance.
Sample code:
void init(Context context, ClientMode mode, String appId, UserInfo userInfo, IMNewToken token, ActionCallback callback);Parameters
Parameter | Type | Description |
context | Context | The context of the Android environment. |
mode | ClientMode | The client mode. |
appId | String | The ID of the ApsaraVideo Real-time Communication (ARTC) application. |
userInfo | UserInfo | The information about the user. |
callback | ActionCallback | The callback that is triggered when the operation is complete. |
release
Description: releases an engine instance.
Sample code:
void release();Parameters
None.
addObserver
Description: adds an observer to listen for a room event callback.
Sample code:
void addObserver(ARTCVoiceRoomEngineDelegate callback);Parameters
Parameter | Type | Description |
callback | ARTCVoiceRoomEngineDelegate | The observer to be added. |
removeObserver
Description: removes the observer that listens for a room event callback.
Sample code:
void removeObserver(ARTCVoiceRoomEngineDelegate callback);Parameters
Parameter | Type | Description |
callback | ARTCVoiceRoomEngineDelegate | The observer to be removed. |
getRoomInfo
Description: queries the information about the chit-chat room.
Sample code:
RoomInfo getRoomInfo();Parameters
None.
isAnchor
Description: queries whether a user is the owner of the chit-chat room.
Sample code:
boolean isAnchor();Parameters
None.
isJoinRoom
Description: queries whether a user joins the chit-chat room.
Sample code:
boolean isJoinRoom();Parameters
None.
joinRoom
Description: joins the chit-chat room.
Sample code:
void joinRoom(RoomInfo roomInfo, RtcInfo rtcInfo, ActionCallback callback);Parameters
Parameter | Type | Description |
roomInfo | RoomInfo | The information about the chit-chat room to be joined. |
rtcInfo | RtcInfo | The required information about the Real-Time Communication (RTC) channel to be joined. |
callback | ActionCallback | The callback that is triggered when the operation is complete. |
leaveRoom
Description: leaves the chit-chat room.
Sample code:
void leaveRoom(ActionCallback callback);Parameters
Parameter | Type | Description |
callback | ActionCallback | The callback that is triggered when the operation is complete. |
dismissRoom
Description: terminates the chit-chat room. Only the streamer can terminate the chit-chat room.
Sample code:
void dismissRoom(ActionCallback callback);Parameters
Parameter | Type | Description |
callback | ActionCallback | The callback that is triggered when the operation is complete. |
isJoinMic
Description: queries whether co-streaming is started.
Sample code:
boolean isJoinMic();Parameters
None.
joinMic
Description: directly starts co-streaming.
Sample code:
void joinMic(MicInfo micInfo, ActionCallback callback);Parameters
Parameter | Type | Description |
micInfo | MicInfo | The required information about co-streaming. |
callback | ActionCallback | The callback that is triggered when the operation is complete. |
leaveMic
Description: stops co-streaming.
Sample code:
void leaveMic(ActionCallback callback);Parameters
Parameter | Type | Description |
callback | ActionCallback | The callback that is triggered when the operation is complete. |
requestMic
Description: applies for co-streaming.
Sample code:
void requestMic(ActionCallback callback);Parameters
Parameter | Type | Description |
callback | ActionCallback | The callback that is triggered when the operation is complete. |
switchMicrophone
Description: turns on or off your microphone.
Sample code:
void switchMicrophone(boolean open);Parameters
Parameter | Type | Description |
open | boolean | Specifies whether to turn on your microphone. |
setAudioOutputType
Description: switches the audio output between your microphone and earpiece.
Sample code:
void setAudioOutputType(AudioOutputType type);Parameters
Parameter | Type | Description |
type | AudioOutputType | The type of the audio output device, which can be the microphone or earpiece. |
enableEarBack
Description: enables or disables in-ear monitoring.
Sample code:
void enableEarBack(boolean enable);Parameters
Parameter | Type | Description |
enable | boolean | Specifies whether to enable in-ear monitoring. |
setRecordingVolume
Description: specifies the audio recording volume. Default value: 50. Valid values: [0,100].
Sample code:
void setRecordingVolume(int volume);Parameters
Parameter | Type | Description |
volume | int | The audio recording volume. Default value: 50. Valid values: [0,100]. |
playAudioEffect
Description: starts or stops the playback of a sound effect.
Sample code:
int playAudioEffect(AudioEffect effect);Parameters
Parameter | Type | Description |
effect | AudioEffect | The encapsulation of the sound effect. If this parameter is set to null, the playback of the sound effect stops. |
setAudioEffectVolume
Description: specifies the volume of a sound effect.
Sample code:
void setAudioEffectVolume(int soundId, int volume);Parameters
Parameter | Type | Description |
soundId | int | The sound effect ID. |
volume | int | The volume of the sound effect. Default value: 50. Valid values: [0,100]. |
setBackgroundMusic
Description: starts or stops the playback of the background music.
Sample code:
void setBackgroundMusic(Music music);Parameters
Parameter | Type | Description |
music | Music | The encapsulation of the background music. If this parameter is set to null, the playback of the background music stops. |
setAccompanyVolume
Description: specifies the volume of the background music.
Sample code:
void setAccompanyVolume(int volume);Parameters
Parameter | Type | Description |
volume | int | The volume of the background music. Default value: 50. Valid values: [0,100]. |
setVoiceChange
Description: specifies the voice changer effect.
Sample code:
void setVoiceChange(VoiceChange change);Parameters
Parameter | Type | Description |
change | VoiceChange | The voice changer effect. |
setAudioMixSound
Description: specifies the reverberation mode.
Sample code:
void setAudioMixSound(MixSound mix);Parameters
Parameter | Type | Description |
mix | MixSound | The reverberation mode. |
sendTextMessage
Description: sends a live comment.
Sample code:
void sendTextMessage(String message, ActionCallback callback);Parameters
Parameter | Type | Description |
message | String | The content of the live comment. |
callback | ActionCallback | The callback that is triggered when the operation is complete. |
sendCommand
Description: sends a signaling message.
Sample code:
public func sendCommand(type: ARTCRoomMessageType, data:[AnyHashable: Any]? = nil , userId: String? = nil, completed: ARTCRoomCompleted? = nil)Parameters
Parameter | Type | Description |
user | UserInfo | The user to whom the signaling message is to be sent. |
type | int | The type of the signaling message. |
protocol | String | The signaling protocol. |
callback | ActionCallback | The callback that is triggered when the operation is complete. |
Details of ARTCVoiceRoomEngineDelegate
onJoin
Description: indicates that you join the chit-chat room.
Sample code:
void onJoin(String roomId, String uid);Parameters
Parameter | Type | Description |
roomId | String | The chit-chat room ID. |
uid | String | The user ID. |
onLeave
Description: indicates that you leave the chit-chat room.
Sample code:
void onLeave();Parameters
None.
onJoinedRoom
Description: indicates that a user joins the chit-chat room.
Sample code:
void onJoinedRoom(UserInfo user);Parameters
Parameter | Type | Description |
user | UserInfo | The user who joins the chit-chat room. |
onLeavedRoom
Description: indicates that a user leaves the chit-chat room.
Sample code:
void onLeavedRoom(UserInfo user);Parameters
Parameter | Type | Description |
user | UserInfo | The user who leaves the chit-chat room. |
onKickoutRoom
Description: indicates that you are removed from the chit-chat room.
Sample code:
void onKickOutRoom();Parameters
None.
onDismissRoom
Description: indicates that the chit-chat room is terminated.
Sample code:
void onDismissRoom(String commander);Parameters
Parameter | Type | Description |
commander | String | The ID of the user who terminates the chit-chat room. |
onMemberCountChanged
Description: indicates that the number of users in the chit-chat room changes.
Sample code:
void onMemberCountChanged(int count);Parameters
Parameter | Type | Description |
count | Int | The number of users. |
onJoinedMic
Description: indicates that a user starts co-streaming.
Sample code:
void onJoinedMic(UserInfo user);Parameters
Parameter | Type | Description |
user | UserInfo | The co-streamer. |
onLeavedMic
Description: indicates that a user stops co-streaming.
Sample code:
void onLeavedMic(UserInfo user);Parameters
Parameter | Type | Description |
user | UserInfo | The co-streamer. |
onMicUserMicrophoneChanged
Description: indicates whether the microphone of the co-streamer is turned on or off.
Sample code:
void onMicUserMicrophoneChanged(UserInfo user, boolean open);Parameters
Parameter | Type | Description |
user | UserInfo | The co-streamer. |
open | boolean | Indicates whether the microphone is turned on. |
onMicUserSpeakStateChanged
Description: indicates whether the co-streamer is speaking.
Sample code:
void onMicUserSpeakStateChanged(UserInfo user);Parameters
Parameter | Type | Description |
user | UserInfo | The user whose speaking status changes. |
onNetworkStateChanged
Description: indicates that the network status changes.
Sample code:
void onNetworkStateChanged(UserInfo user);Parameters
Parameter | Type | Description |
user | UserInfo | The user whose network status changes. |
onAccompanyStateChanged
Description: indicates that the playback status of your background music changes. The playback may start, stop, or fail.
Sample code:
void onAccompanyStateChanged(AccompanyPlayState state);Parameters
Parameter | Type | Description |
state | AccompanyPlayState | The playback status. |
onReceivedTextMessage
Description: indicates that a live comment is sent to you.
Sample code:
void onReceivedTextMessage(UserInfo user, String text);Parameters
Parameter | Type | Description |
user | UserInfo | The user who sends the live comment. |
text | String | The information about the live comment. |
onError
Description: indicates that an error occurred.
Sample code:
void onError(int code, String msg);Parameters
Parameter | Type | Description |
error | int | The error code. |
msg | String | The error message. |