TRTCLiveRoom APIs (Android)
TRTCLiveRoom
includes the following features which are based on Tencent Real-Time Communication (TRTC) and Tencent Cloud Chat.A user can create a room and start live streaming, or enter a room as an audience member.
The anchor can co-anchor with audience members in the room.
Anchors in two rooms can compete and interact with each other.
All users can send text and custom messages. Custom messages can be used to send on-screen comments, give likes, and send gifts.
Note
TRTCLiveRoom
is an open-source class depending on two closed-source Tencent Cloud SDKs. For the specific implementation process, please see Interactive Live Video Streaming (Android).The TRTC SDK is used as a low-latency audio chat component.
The
AVChatRoom
feature of the Chat SDK is used to implement chat rooms. The attribute APIs of Chat are used to store room information such as the seat list, and invitation signaling is used to send requests to speak or invite others to speak.
TRTCLiveRoom API Overview
Basic SDK APIs
API | Description |
Gets a singleton object. | |
Terminates a singleton object. | |
Sets event callbacks. | |
Sets the thread where event callbacks are. | |
Logs in. | |
Logs out. | |
Sets the profile. |
Room APIs
API | Description |
Creates a room (called by anchor). If the room does not exist, the system will create the room automatically. | |
Terminates a room (called by anchor). | |
Enters a room (called by audience). | |
Exits a room (called by audience). | |
Gets room list details. | |
Gets the anchors in a room. This API works only if it is called after enterRoom() . | |
Gets the information of all audience members in a room. This API works only if it is called after enterRoom() . |
Stream pushing/pulling APIs
API | Description |
Enables preview of the local video. | |
Stops local video capturing and preview. | |
Starts live streaming (pushing streams). | |
Stops live streaming (pushing streams). | |
Plays a remote video. This API can be called in common playback and co-anchoring scenarios. | |
Stops rendering a remote video. |
APIs for anchor-audience co-anchoring
API | Description |
Requests co-anchoring (called by audience). | |
Responds to a co-anchoring request (called by anchor). | |
Removes a user from co-anchoring (called by anchor). |
APIs for cross-room communication
API | Description |
Sends a cross-room communication request (called by anchor). | |
Responds to a cross-room communication request (called by anchor). | |
Quits cross-room communication. |
Audio/Video APIs
API | Description |
Switches between the front and rear cameras. | |
Specifies whether to mirror video. | |
Mutes/Unmutes the local user. | |
Mutes/Unmutes a remote user. | |
Mutes/Unmutes all remote users. |
Background music and audio effect APIs
API | Description |
Beauty filter APIs
API | Description |
Message sending APIs
API | Description |
Broadcasts a text chat message in a room. This API is generally used for on-screen comments. | |
Sends a custom text message. |
Debugging APIs
API | Description |
Specifies whether to display debugging information on the UI. |
TRTCLiveRoomDelegate API Overview
Common event callbacks
API | Description |
Callback for error. | |
Callback for warning. | |
Callback of log. |
Room event callback APIs
API | Description |
The room was terminated. | |
The room information changed. |
Callback APIs for entry/exit of anchors/audience
API | Description |
There is a new anchor in the room. | |
An anchor left the room. | |
An audience member entered the room. | |
An audience member left the room. |
Callback APIs for anchor-audience co-anchoring events
API | Description |
A co-anchoring request was received. | |
A user was removed from co-anchoring. |
Callback APIs for cross-room communication events
API | Description |
A cross-room communication request was received. | |
Cross-room communication ended. |
Message event callback APIs
API | Description |
A text chat message was received. | |
A custom message was received. |
Basic SDK APIs
sharedInstance
public static synchronized TRTCLiveRoom sharedInstance(Context context);
The parameters are described below:
Parameter | Type | Description |
context | Context | Android context, which will be converted to ApplicationContext for the calling of system APIs |
destroySharedInstance
Note
After the instance is terminated, the externally cached
TRTCLiveRoom
instance can no longer be used. You need to call sharedInstance again to get a new instance.public static void destroySharedInstance();
setDelegate
This API is used to get callbacks for the events of TRTCLiveRoom. You can use
TRTCLiveRoomDelegate
to get the callbacks.public abstract void setDelegate(TRTCLiveRoomDelegate delegate);
Note
setDelegate
is the delegate callback of TRTCLiveRoom
. setDelegateHandler
This API is used to set the thread where event callbacks are.
public abstract void setDelegateHandler(Handler handler);
The parameters are described below:
Parameter | Type | Description |
handler | Handler | Callbacks for the events of TRTCLiveRoom are returned via this handler. Do not use it together with setDelegate . |
login
Login
public abstract void login(int sdkAppId,String userId, String userSig,TRTCLiveRoomDef.TRTCLiveRoomConfig config,TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
sdkAppId | int | |
userId | String | The ID of the current user, which is a string that can contain only letters (a-z and A-Z), digits (0-9), hyphens (-), and underscores (_) |
userSig | String | Tencent Cloud's proprietary security signature. For how to calculate and use it, see FAQs > UserSig. |
config | TRTCLiveRoomConfig | Global configuration information, which needs to be initialized during login and cannot be modified afterward. useCDNFirst : Specifies the way the audience watches live streams. true means that the audience watches live streams over CDNs, which is cost-efficient but has high latency. false means that the audience watches live streams in the low latency mode, the cost of which is between that of CDN live streaming and co-anchoring, but the latency is within 1 second. CDNPlayDomain : Specifies the domain name for CDN live streaming. It takes effect only if useCDNFirst is set to true . You can set it in Domain Management of the CSS console. |
callback | ActionCallback | The callback for login. The code is 0 if login succeeds. |
logout
Log out
public abstract void logout(TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
callback | ActionCallback | Callback for logout. The code is 0 if logout succeeds. |
setSelfProfile
This API is used to set the profile.
public abstract void setSelfProfile(String userName, String avatarURL, TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
userName | String | Username |
avatarURL | String | Profile photo URL |
callback | ActionCallback | Callback for profile setting. The code is 0 if the operation succeeds. |
Room APIs
createRoom
This API is used to create a room (called by anchor).
public abstract void createRoom(int roomId, TRTCLiveRoomDef.TRTCCreateRoomParam roomParam, TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
roomId | int | The room ID. You need to assign and manage the IDs in a centralized manner. Multiple roomId values can be aggregated into a live room list. Currently, Tencent Cloud does not provide list management services. Please manage your own room lists. |
roomParam | TRTCCreateRoomParam | Room information, such as room name and cover information. If both the room list and room information are managed on your server, you can ignore this parameter. |
callback | ActionCallback | Callback for room creation. The code is 0 if the operation succeeds. |
The process of creating a room and starting live streaming as an anchor is as follows:
1. A user calls
startCameraPreview()
to enable camera preview and set beauty filters. 2. The user calls
createRoom()
to create a room, the result of which is returned via the ActionCallback
callback.3. The user calls
starPublish()
to push streams.destroyRoom
This API is used to terminate a room (called by anchor).
public abstract void destroyRoom(TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
callback | ActionCallback | Callback for room termination. The code is 0 if the operation succeeds. |
enterRoom
This API is used to enter a room (called by audience).
public abstract void enterRoom(int roomId, TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
roomId | int | The room ID. |
callback | ActionCallback | Callback for room entry. The code is 0 if the operation succeeds. |
The process of entering a room and starting playback as an audience member is as follows:
1. A user gets the latest room list from your server. The list may contain the
roomID
and other information of multiple rooms.2. The user selects a room and calls
enterRoom()
to enter the room.3. The user calls
startPlay(userId)
, passing in the anchor’s userId
to start playback.If the room list contains the anchor’s
userId
, the user can call startPlay(userId)
to start playback.If the user does not have the anchor's
userId
before room entry, he or she can find it in the onAnchorEnter(userId)
callback of TRTCLiveRoomDelegate
, which is returned after room entry, and can then call startPlay(userId)
to start playback.exitRoom
This API is used to leave a room.
public abstract void exitRoom(TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
callback | ActionCallback | Callback for room exit. The code is 0 if the operation succeeds. |
getRoomInfos
This API is used to get room list details, which are set by anchors via
roomInfo
when they call createRoom()
.Note
You don’t need this API if both the room list and room information are managed on your server.
public abstract void getRoomInfos(List<Integer> roomIdList, TRTCLiveRoomCallback.RoomInfoCallback callback);
The parameters are described below:
Parameter | Type | Description |
roomIdList | List<Integer> | Room ID list |
callback | RoomInfoCallback | Callback of room details |
getAnchorList
This API is used to get the anchors and co-anchoring viewers in a room. It takes effect only if it is called after
enterRoom()
.public abstract void getAnchorList(TRTCLiveRoomCallback.UserListCallback callback);
The parameters are described below:
Parameter | Type | Description |
callback | UserListCallback | Callback of user details |
getAudienceList
This API is used to get the information of all audience members in a room. It takes effect only if it is called after
enterRoom()
.public abstract void getAudienceList(TRTCLiveRoomCallback.UserListCallback callback);
The parameters are described below:
Parameter | Type | Description |
callback | UserListCallback | Callback of user details |
Stream Pushing/Pulling APIs
startCameraPreview
This API is used to enable local video preview.
public abstract void startCameraPreview(boolean isFront, TXCloudVideoView view, TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
isFront | boolean | true : Front camera; false : Rear camera |
view | TXCloudVideoView | The control that loads video images |
callback | ActionCallback | Callback for the operation |
stopCameraPreview
This API is used to stop local video capturing and preview.
public abstract void stopCameraPreview();
startPublish
This API is used to start live streaming (pushing streams), which can be called in the following scenarios:
An anchor starts live streaming.
An audience member starts co-anchoring.
public abstract void startPublish(String streamId, TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
streamId | String | The streamId used to bind live streaming CDNs. You need to set it to the streamId of the anchor if you want audience to play the anchor’s stream via live streaming CDNs. |
callback | ActionCallback | Callback for the operation |
stopPublish
This API is used to stop live streaming (pushing streams), which can be called in the following scenarios:
An anchor ends live streaming.
An audience member ends co-anchoring.
public abstract void stopPublish(TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
callback | ActionCallback | Callback for the operation |
startPlay
This API is used to play a remote video. It can be called in common playback and co-anchoring scenarios.
public abstract void startPlay(String userId, TXCloudVideoView view, TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
userId | String | ID of the user whose video is to be played |
view | TXCloudVideoView | The control that loads video images |
callback | ActionCallback | Callback for the operation |
Common playback scenario
If the room list contains anchors’
userId
, after entering a room, a user can call startPlay(userId)
to play the anchor's video.If a user does not have the anchor's
userId
before room entry, he or she can find it in the onAnchorEnter(userId)
callback of TRTCLiveRoomDelegate
, which is returned after room entry, and can then call startPlay(userId)
to play the anchor’s video.Co-anchoring scenario
After co-anchoring starts, the anchor will receive the
onAnchorEnter(userId)
callback from TRTCLiveRoomDelegate
and can call startPlay(userId)
, passing in the userId
obtained from the callback to play the co-anchoring user’s video.stopPlay
This API is used to stop rendering a remote video. It needs to be called after the
onAnchorExit()
callback is received.public abstract void stopPlay(String userId, TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
userId | String | ID of the remote user |
callback | ActionCallback | Callback for the operation |
APIs for Anchor-Audience Co-anchoring
requestJoinAnchor
This API is used to send a co-anchoring request (called by audience).
public abstract void requestJoinAnchor(String reason, int timeout, TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
reason | String | Reason for co-anchoring |
timeout | int | Timeout period |
callback | ActionCallback | Callback of the anchor’s response |
The process of co-anchoring between anchors and audience members is as follows:
1. A viewer calls
requestJoinAnchor()
to send a co-anchoring request to the anchor.2. The anchor receives the
onRequestJoinAnchor()
callback of TRTCLiveRoomDelegate
.3. The anchor calls
responseJoinAnchor()
to accept or reject the co-anchoring request.4. The viewer receives the
responseCallback
callback, which carries the anchor’s response.5. If the request is accepted, the viewer calls
startCameraPreview()
to enable local camera preview.6. The viewer calls
startPublish()
to push streams.7. After the viewer starts pushing streams, the anchor receives the
onAnchorEnter()
callback of TRTCLiveRoomDelegate
.8. The anchor calls
startPlay()
to play the co-anchoring viewer’s video.9. If there are other viewers co-anchoring with the anchor in the room, the new co-anchoring viewer will receive the
onAnchorEnter()
callback and can call startPlay()
to play other co-anchoring viewers’ video.responseJoinAnchor
This API is used to respond to a co-anchoring request (called by anchor) after receiving the
onRequestJoinAnchor()
callback of TRTCLiveRoomDelegate
.public abstract void responseJoinAnchor(String userId, boolean agree, String reason);
The parameters are described below:
Parameter | Type | Description |
userId | String | The user ID of the audience member. |
agree | boolean | true : accept; false : reject |
reason | String | Reason for accepting/rejecting the request |
kickoutJoinAnchor
This API is used to remove a user from co-anchoring (called by anchor). The removed user will receive the
onKickoutJoinAnchor()
callback of TRTCLiveRoomDelegate
.public abstract void kickoutJoinAnchor(String userId, TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
userId | String | The ID of the co-anchoring user. |
callback | ActionCallback | Callback for the operation |
APIs for Cross-Room Communication
requestRoomPK
This API is used to send a cross-room communication request (called by anchor).
public abstract void requestRoomPK(int roomId, String userId, TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
roomId | int | Room ID of the anchor to call |
userId | String | User ID of the anchor to call |
callback | ActionCallback | Callback for requesting cross-room communication. |
Anchors in different rooms can communicate with each other. The process of starting cross-room communication between anchor A and anchor B is as follows:
1. Anchor A calls
requestRoomPK()
to send a ccross-room communication request to anchor B.2. Anchor B receives the
onRequestRoomPK()
callback of TRTCLiveRoomDelegate
.3. Anchor B calls
responseRoomPK()
to respond to the cross-room communication request.4. If anchor B accepts the request, he or she would wait for the
onAnchorEnter()
callback of TRTCLiveRoomDelegate
and call startPlay()
to play anchor A's video.5. Anchor A receives the
responseCallback
callback, which carries anchor B’s response.6. If the request is accepted, anchor A waits for the
onAnchorEnter()
callback of TRTCLiveRoomDelegate
and calls startPlay()
to play anchor B’s video.responseRoomPK
This API is used to respond to a cross-room communication request (called by anchor), after which the request sending anchor will receive the
responseCallback
passed in to requestRoomPK
.public abstract void responseRoomPK(String userId, boolean agree, String reason);
The parameters are described below:
Parameter | Type | Description |
userId | String | User ID of the request sending anchor |
agree | boolean | true : Accept; false : Reject |
reason | String | Reason for accepting/rejecting the request |
quitRoomPK
This API is used to quit cross-room communication. If either anchor quits cross-room communication, the other anchor will receive the
onQuitRoomPk()
callback of TRTCLiveRoomDelegate
.public abstract void quitRoomPK(TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
callback | ActionCallback | Callback for the operation |
Audio/Video APIs
switchCamera
This API is used to switch between the front and rear cameras.
public abstract void switchCamera();
setMirror
This API is used to set the mirror mode.
public abstract void setMirror(boolean isMirror);
The parameters are described below:
Parameter | Type | Description |
isMirror | boolean | Enable/Disable mirroring |
muteLocalAudio
This API is used to mute or unmute the local user.
public abstract void muteLocalAudio(boolean mute);
The parameters are described below:
Parameter | Type | Description |
mute | boolean | true : Mute; false : Unmute |
muteRemoteAudio
This API is used to mute or unmute a remote user.
public abstract void muteRemoteAudio(String userId, boolean mute);
The parameters are described below:
Parameter | Type | Description |
userId | String | ID of the remote user |
mute | boolean | true : Mute; false : Unmute |
muteAllRemoteAudio
This API is used to mute or unmute all remote users.
public abstract void muteAllRemoteAudio(boolean mute);
The parameters are described below:
Parameter | Type | Description |
mute | boolean | true : Mute; false : Unmute |
Background Music and Audio Effect APIs
getAudioEffectManager
This API is used to get the background music and audio effect management object TXAudioEffectManager.
public abstract TXAudioEffectManager getAudioEffectManager();
Beauty Filter APIs
getBeautyManager
public abstract TXBeautyManager getBeautyManager();
You can do the following using
TXBeautyManager
:Set the beauty filter style and apply effects including skin brightening, rosy skin, eye enlarging, face slimming, chin slimming, chin lengthening/shortening, face shortening, nose narrowing, eye brightening, teeth whitening, eye bag removal, wrinkle removal, and smile line removal.
Adjust the hairline, eye spacing, eye corners, lip shape, nose wings, nose position, lip thickness, and face shape.
Apply animated effects such as face widgets (materials).
Add makeup effects.
Recognize gestures.
Message Sending APIs
sendRoomTextMsg
This API is used to broadcast a text chat message in a room, which is generally used for on-screen comments.
public abstract void sendRoomTextMsg(String message, TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
message | String | Text message |
callback | ActionCallback | Callback for the operation |
sendRoomCustomMsg
This API is used to send a custom text message.
public abstract void sendRoomCustomMsg(String cmd, String message, TRTCLiveRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter | Type | Description |
cmd | String | A custom command word used to distinguish between different message types |
message | String | Text message |
callback | ActionCallback | Callback for the operation |
Debugging APIs
showVideoDebugLog
This API is used to specify whether to display debugging information on the UI.
public abstract void showVideoDebugLog(boolean isShow);
The parameters are described below:
Parameter | Type | Description |
isShow | boolean | Show/Hide debugging information |
TRTCLiveRoomDelegate
Event Callback APIs
Common Event Callback APIs
onError
Callback for error.
Note
This callback indicates that the SDK encountered an unrecoverable error. Such errors must be listened for, and UI reminders should be sent to users if necessary.
void onError(int code, String message);
The parameters are described below:
Parameter | Type | Description |
code | int | Error code |
message | String | Error message |
onWarning
Callback for warning.
void onWarning(int code, String message);
The parameters are described below:
Parameter | Type | Description |
code | int | Error code |
message | String | Warning message |
onDebugLog
Callback for log.
void onDebugLog(String message);
The parameters are described below:
Parameter | Type | Description |
message | String | Log information |
Room Event Callback APIs
onRoomDestroy
Callback for room termination. All users in a room will receive this callback after the anchor leaves the room.
void onRoomDestroy(String roomId);
The parameters are described below:
Parameter | Type | Description |
roomId | String | Room ID |
onRoomInfoChange
Callback for change of room information. This callback is usually used to notify users of room status change in co-anchoring and cross-room communication scenarios.
void onRoomInfoChange(TRTCLiveRoomDef.TRTCLiveRoomInfo roomInfo);
The parameters are described below:
Parameter | Type | Description |
roomInfo | TRTCLiveRoomInfo | Room information |
Callback APIs for Entry/Exit of Anchors/Audience
onAnchorEnter
Callback for a new anchor/co-anchoring viewer. The audience will receive this callback when there is a new anchor/co-anchoring viewer in the room and can call
startPlay()
of TRTCLiveRoom
to play the video of the anchor/co-anchoring viewer.void onAnchorEnter(String userId);
The parameters are described below:
Parameter | Type | Description |
userId | String | User ID of the new anchor/co-anchoring viewer |
onAnchorExit
Callback for the quitting of an anchor/co-anchoring viewer. The anchors and co-anchoring viewers in a room will receive this callback after an anchor/co-anchoring viewer quits cross-room communication/co-anchoring and can call
stopPlay()
of TRTCLiveRoom
to stop playing the video of the anchor/co-anchoring viewer.void onAnchorExit(String userId);
The parameters are described below:
Parameter | Type | Description |
userId | String | ID of the user who quit |
onAudienceEnter
Callback for room entry by a viewer.
void onAudienceEnter(TRTCLiveRoomDef.TRTCLiveUserInfo userInfo);
The parameters are described below:
Parameter | Type | Description |
userInfo | TRTCLiveUserInfo | Information of the viewer who entered the room |
onAudienceExit
Callback for room exit by a viewer.
void onAudienceExit(TRTCLiveRoomDef.TRTCLiveUserInfo userInfo);
The parameters are described below:
Parameter | Type | Description |
userInfo | TRTCLiveUserInfo | Information of the viewer who left the room |
Callback APIs Audience-Anchor Co-anchoring Events
onRequestJoinAnchor
Callback for receiving a co-anchoring request from a viewer.
void onRequestJoinAnchor(TRTCLiveRoomDef.TRTCLiveUserInfo userInfo, String reason, int timeOut);
The parameters are described below:
Parameter | Type | Description |
userInfo | TRTCLiveUserInfo | Information of the viewer who requested co-anchoring |
reason | String | Reason for co-anchoring |
timeout | int | Timeout period for response from the anchor. If the anchor does not respond to the request within the period, it will be discarded automatically. |
onKickoutJoinAnchor
Callback for being removed from co-anchoring. After receiving this callback, a co-anchoring viewer needs to call
stopPublish()
of TRTCLiveRoom
to quit co-anchoring.void onKickoutJoinAnchor();
Callback APIs for Cross-Room Communication Events
onRequestRoomPK
Callback for receiving a cross-room communication request. If an anchor accepts the request, he or she should wait for the
onAnchorEnter()
callback of TRTCLiveRoomDelegate
and call startPlay()
to play the other anchor’s video.void onRequestRoomPK(TRTCLiveRoomDef.TRTCLiveUserInfo userInfo, int timeout);
The parameters are described below:
Parameter | Type | Description |
userInfo | TRTCLiveUserInfo | Information of the anchor who requested cross-room communication. |
timeout | int | Timeout period for response from the anchor |
onQuitRoomPK
Callback for ending cross-room communication.
void onQuitRoomPK();
Message Event Callback APIs
onRecvRoomTextMsg
Callback for receiving a text chat message.
void onRecvRoomTextMsg(String message, TRTCLiveRoomDef.TRTCLiveUserInfo userInfo);
The parameters are described below:
Parameter | Type | Description |
message | String | Text message |
userInfo | TRTCLiveUserInfo | Information of the sender |
onRecvRoomCustomMsg
A custom message was received.
void onRecvRoomCustomMsg(String cmd, String message, TRTCLiveRoomDef.TRTCLiveUserInfo userInfo);
The parameters are described below:
Parameter | Type | Description |
command | String | A custom command word used to distinguish between different message types |
message | String | Text message |
userInfo | TRTCLiveUserInfo | Information of the sender |
TRTCAudioEffectManager
playBGM
Background Music
void playBGM(String url, int loopTimes, int bgmVol, int micVol, TRTCCloud.BGMNotify notify);
The parameters are described below:
Parameter | Type | Description |
url | String | Path of the music file |
loopTimes | int | Loop times |
bgmVol | int | Volume of background music |
micVol | int | Audio capturing volume |
notify | TRTCCloud.BGMNotify | Playback notification |
stopBGM
stop playing background music
void stopBGM();
pauseBGM
pause background music
void pauseBGM();
resumeBGM
This API is used to resume background music playback.
void resumeBGM();
setBGMVolume
This API is used to set the playback volume of background music.
void setBGMVolume(int volume);
The parameters are described below:
Parameter | Type | Description |
volume | int | Volume. Value range: 0-100. Default value: 100 |
setBGMPosition
This API is used to set the background music playback progress.
int setBGMPosition(int position);
The parameters are described below:
Parameter | Type | Description |
position | int | Playback progress of background music in milliseconds (ms) |
Return code
0
: successfulsetMicVolume
This API is used to set the mic volume. It can be used to control the volume of the mic when background music is mixed.
void setMicVolume(int volume);
The parameters are described below:
Parameter | Type | Description |
volume | Int | Volume. Value range: 0-100. Default value: 100 |
setReverbType
This API is used to set the reverb effect.
void setReverbType(int reverbType);
The parameters are described below:
Parameter | Type | Description |
reverbType | int |
setVoiceChangerType
This API is used to set the voice changing effect.
void setVoiceChangerType(int type);
The parameters are described below:
Parameter | Type | Description |
type | int | Voice changing effect. For details, please see the definitions of TRTC_VOICE_CHANGER_TYPE in TRTCCloudDef . |
playAudioEffect
This API is used to play an audio effect. For each audio effect, you need to assign an ID, which is used to start and stop the playback of an audio effect as well as set its playback volume. Supported formats include AAC, MP3, and M4A.
void playAudioEffect(int effectId, String path, int count, boolean publish, int volume);
The parameters are described below:
Parameter | Type | Description |
effectId | int | Audio effect ID |
path | String | Audio effect path |
count | int | Loop times |
publish | boolean | Whether to push the audio effect. true : push the effect to remote users; false : preview the effect locally only |
volume | int | Volume. Value range: 0-100. Default value: 100 |
pauseAudioEffect
This API is used to pause playing an audio effect.
void pauseAudioEffect(int effectId);
The parameters are described below:
Parameter | Type | Description |
effectId | int | Audio effect ID |
resumeAudioEffect
This API is used to resume playing an audio effect.
void resumeAudioEffect(int effectId);
The parameters are described below:
Parameter | Type | Description |
effectId | int | Audio effect ID |
stopAudioEffect
This API is used to stop playing an audio effect.
void stopAudioEffect(int effectId);
The parameters are described below:
Parameter | Type | Description |
effectId | int | Audio effect ID |
stopAllAudioEffects
This API is used to stop playing all audio effects.
void stopAllAudioEffects();
setAudioEffectVolume
This API is used to set the volume of an audio effect.
void setAudioEffectVolume(int effectId, int volume);
The parameters are described below:
Parameter | Type | Description |
effectId | int | Audio effect ID |
volume | int | Volume. Value range: 0-100. Default value: 100 |
setAllAudioEffectsVolume
This API is used to set the volume of all audio effects.
void setAllAudioEffectsVolume(int volume);
The parameters are described below:
Parameter | Type | Description |
volume | int | Volume. Value range: 0-100. Default value: 100 |
- TRTCLiveRoom API Overview
- TRTCLiveRoomDelegate API Overview
- Basic SDK APIs
- Room APIs
- Stream Pushing/Pulling APIs
- APIs for Anchor-Audience Co-anchoring
- APIs for Cross-Room Communication
- Audio/Video APIs
- Background Music and Audio Effect APIs
- Beauty Filter APIs
- Message Sending APIs
- Debugging APIs
- TRTCLiveRoomDelegate Event Callback APIs
- Common Event Callback APIs
- Room Event Callback APIs
- Callback APIs for Entry/Exit of Anchors/Audience
- Callback APIs Audience-Anchor Co-anchoring Events
- Callback APIs for Cross-Room Communication Events
- Message Event Callback APIs
- TRTCAudioEffectManager