Starter Deal! First 3 month from only  $9.9 /month!
Starter Deal! First 3 month from only  $9.9 /month!
Grab It Now 
RTC Engine
  • Overview
  • Web
    • Run Sample Demo
    • SDK Quickstart
    • Basic Features
      • Screen Sharing
      • Live Streaming
      • Media Device
      • Audio Volume
      • Set Encoding Profile
      • Detect Network Quality
      • Detect Capabilities
    • Advance Features
      • Enable AI Denoiser
      • Enable Audio Mixer
      • Enable Watermark
      • Enable Beauty and Effects
      • Data Messages
      • Custom Capturing and Rendering
    • API List
    • Released Notes
    • Supported Platforms
    • Web FAQs
      • Optimize Multi-Person Video Calls
      • Handle Autoplay Restriction
      • Handle Firewall Restriction
      • Others
  • Android
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Newwork Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCStatistics
      • TRTCCloudListener
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Solution
      • Real-Time Chorus (TUIKaraoke)
        • Quick Integration
        • Implementation Steps
        • Song Synchronization
        • Lyric Synchronization
        • Vocal Synchronization
        • Mixing Stream Solution
        • TRTCKaraoke APIs
        • FAQs
    • Release Notes
  • iOS
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
    • Solution
      • Quick Integration
      • Implementation Steps
      • Song Synchronization
      • Lyric Synchronization
      • Vocal Synchronization
      • Mixing Stream Solution
      • TRTCKaraoke APIs
      • FAQs
    • Release Notes
  • macOS
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Testing Hardware Devices
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
      • Release Notes
    • Release Notes
  • Windows
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Hardware Devices
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • ITRTCCloud
      • ITRTCStatistics
      • TRTCCloudCallback
      • ITXAudioEffectManager
      • ITXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Release Notes
  • Electron
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Flutter
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Unity
    • Integration
      • 1.API Examples
      • 2Importing the SDK
    • Client APIs
      • Overview
      • Error Codes
  • Qt
    • Integration
      • 1.Importing the SDK
  • Overview
    • Overview
  • Concepts
  • Features
  • Performance Statistics
  • Pricing
    • RTC-Engine Packages
    • Billing of On-Cloud Recording
    • Billing of MixTranscoding and Relay to CDN
    • Billing Explanation for Subscription Package Duration
    • Billing of Monitoring Dashboard
    • Free Minutes
    • Pay-As-You-Go
  • FAQs
    • FAQs for Beginners
    • Migration Guide
      • Twilio Video to Tencent RTC
      • Billing
      • Features
      • UserSig
      • Firewall Restrictions
      • How to Downsize Installation Package
      • TRTCCalling for Web
      • Audio and Video Quality
      • Others
RTC Engine

TRTCKaraoke APIs

TRTCKaraokeRoom includes the following features, which are based on Tencent Real-Time Communication (TRTC) and Tencent Cloud Chat.
A user can create a karaoke room and become a speaker or enter a karaoke room as a listener.
The room owner can manage song requests as well as remove a speaker from a seat.
The room owner can also block a seat. A listener cannot request to take a blocked seat to become a speaker.
A listener can become a speaker to request songs and sing. A speaker can also become a listener.
All users can send gifts as well as custom chat messages. Custom messages can be used to send on-screen comments and give likes.
Note
All TUIKit components are based on two basic PaaS services of Tencent Cloud, namely TRTC and Chat. When you activate TRTC, the Chat SDK trial edition (which supports up to 100 DAUs) will be activated automatically. For Chat billing details, see Pricing.
TRTCKaraokeRoom is an open-source class that depends on two closed-source Tencent Cloud SDKs. For the specific implementation process, see Karaoke (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.


TRTCKaraokeRoom 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 profile.

Room APIs

API
Description
Creates a room (called by room owner). If the room does not exist, the system will automatically create a room.
Terminates a room (called by room owner).
Enters a room (called by listener).
Exits a room (called by listener).
Gets room list details.
Gets the user information of the specified userId. If the value is null, the information of all users in the room is obtained.

Music playback APIs

API
Description
Starts music.
Stops music.
Pauses music.
Resumes music.

Seat management APIs

API
Description
Becomes a speaker (called by room owner or listener).
Becomes a listener (called by speaker).
Places a user in a seat (called by room owner).
Removes a speaker (called by room owner).
Mutes/Unmutes a seat (called by room owner).
Blocks/Unblocks a seat (called by room owner).

Local audio APIs

API
Description
Starts mic capturing.
Stops mic capturing.
Sets audio quality.
Mutes/Unmutes local audio.
Sets whether to use the device speaker or receiver to play audio.
Sets mic capturing volume.
Sets playback volume.
Enables/Disables in-ear monitoring.

Remote audio APIs

API
Description
Mutes/Unmutes a specified member.
Mutes/Unmutes all members.

Background music and audio effect APIs

API
Description
Gets the background music and audio effect management object TXAudioEffectManager.

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.

Invitation signaling APIs

API
Description
Sends an invitation.
Accepts an invitation.
Declines an invitation.
Cancels an invitation.


TRTCKaraokeRoomDelegate 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.
The user volume.

Seat list change callback APIs

API
Description
All seat changes.
A user became a speaker or was made a speaker by the room owner.
A user became a listener or was made a listener by the room owner.
The room owner muted a seat.
Whether a user’s mic is muted.
The room owner blocked a seat.

Callback APIs for room entry/exit by listener

API
Description
A listener entered the room.
A listener exited the room.

Message event callback APIs

API
Description
A text chat message was received.
A custom message was received.

Signaling Event Callback APIs

API
Description
Receipt of an invitation.
Invitation accepted by invitee.
Invitation declined by invitee.
The inviter canceled the invitation.

Song event callback APIs

API
Description
Music playback progress.
Music playback is ready.
Music playback was completed.

Basic SDK APIs



sharedInstance

This API is used to get a TRTCKaraokeRoom singleton object.
public static synchronized TRTCKaraokeRoom 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

This API is used to terminate a TRTCKaraokeRoom singleton object.
Note
After the instance is terminated, the externally cached TRTCKaraokeRoom 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 set the event callbacks of TRTCKaraokeRoom. You can use TRTCKaraokeRoomDelegate to get different status notifications of TRTCKaraokeRoom.
public abstract void setDelegate(TRTCKaraokeRoomDelegate delegate);
Note
setDelegate is the delegate callback of TRTCKaraokeRoom.

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
The status notifications of TRTCKaraokeRoom are sent to the handler thread you specify.

login

Login
public abstract void login(int sdkAppId,
String userId, String userSig,
TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
sdkAppId
int
You can view the SDKAppID via Application Management > Application Info in the TRTC console.
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.
callback
ActionCallback
The callback for login. The code is 0 if login succeeds.

logout

Log out
public abstract void logout(TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
callback
ActionCallback
The 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, TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
userName
String
The username.
avatar
String
The address of the profile photo.
callback
ActionCallback
The callback for profile configuration. The code is 0 if the operation succeeds.

Room APIs

createRoom

This API is used to create a room (called by room owner).
public abstract void createRoom(int roomId, TRTCKaraokeRoomDef.RoomParam roomParam, TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
roomId
int
The room ID. You need to assign and manage room IDs in a centralized manner. Multiple roomID values can be aggregated into a karaoke room list. Currently, Tencent Cloud does not provide management services for karaoke room lists. Please manage your own room lists.
roomParam
TRTCCreateRoomParam
Room information, such as room name, seat list information, and cover information. To manage seats, you must enter the number of seats in the room.
callback
ActionCallback
The callback for room creation. The code is 0 if the operation succeeds.
The process of creating a karaoke room and becoming a speaker is as follows:
1. A user calls createRoom to create a karaoke room, passing in room attributes (i.e., room ID, whether listeners need room owner’s permission to speak, number of seats).
2. After creating the room, the user calls enterSeat to become a speaker.
3. The user will receive an onSeatListChanget notification about the change of the seat list, and can update the change to the UI.
4. The user will also receive an onAnchorEnterSeat notification that someone became a speaker, and mic capturing will be enabled automatically.

destroyRoom

This API is used to terminate a room (called by room owner).
public abstract void destroyRoom(TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
callback
ActionCallback
The callback for room termination. The code is 0 if the operation succeeds.

enterRoom

This API is used to enter a room (called by listener).
public abstract void enterRoom(int roomId, TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
roomId
int
The room ID.
callback
ActionCallback
The callback for room entry. The code is 0 if the operation succeeds.
The process of entering a room as a listener is as follows:
1. A user gets the latest karaoke room list from your server. The list may contain the roomId and room information of multiple karaoke rooms.
2. The user selects a room, and enters the room by calling enterRoom with the room ID passed in.
3. After entering the room, the user receives an onRoomInfoChange notification about room attribute change from the component. The attributes can be recorded, and corresponding changes can be made to the UI, including room name, whether room owner’s permission is required for listeners to speak, etc.
4. The user will receive an onSeatListChange notification about the change of the seat list and can update the change to the UI.
5. The user will also receive an onAnchorEnterSeat notification that someone became a speaker.

exitRoom

Leave room
public abstract void exitRoom(TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
callback
ActionCallback
The callback for room exit. The code is 0 if the operation succeeds.

getRoomInfoList

This API is used to get room list details. The room name and cover are set by the room owner via roomInfo when calling createRoom().
Note
You don’t need this API if both the room list and room information are managed on your server.
public abstract void getRoomInfoList(List<Integer> roomIdList, TRTCKaraokeRoomCallback.RoomInfoCallback callback);
The parameters are described below:
Parameter
Type
Description
roomIdList
List<Integer>
The list of room IDs.
callback
RoomInfoCallback
The callback of room details.

getUserInfoList

This API is used to get the user information of a specified userId.
public abstract void getUserInfoList(List<String> userIdList, TRTCKaraokeRoomCallback.UserListCallback userlistcallback);
The parameters are described below:
Parameter
Type
Description
userIdList
List<String>
The IDs of the users to query. If this parameter is null, the information of all users in the room is queried.
userlistcallback
UserListCallback
The callback of user details.

Music Playback APIs

startPlayMusic

This API is used to play music (called after becoming a speaker).
Note
After music playback starts, you will receive an onMusicPrepareToPlay notification.
During music playback, all members in the room will continuously receive an onMusicProgressUpdate notification.
After music playback stops, you will receive an onMusicCompletePlaying notification.
public abstract void startPlayMusic(int musicID, String originalUrl, String accompanyUrl);
The parameters are described below:
Parameter
Type
Description
musicID
int
The music ID.
originalUrl
String
The absolute path of the vocal track.
accompanyUrl
String
The absolute path of the instrumental track.
After this API is called, the song that is currently playing will stop.

stopPlayMusic

This API is used to stop music (called during music playback).
Note
After music playback stops, you will receive an onMusicCompletePlaying notification.
public abstract void stopPlayMusic();

pausePlayMusic

This API is used to pause music (called during music playback).
Note
The onMusicProgressUpdate notification will be paused.
No onMusicCompletePlaying notification will be received.
public abstract void pausePlayMusic();

resumePlayMusic

This API is used to resume music (called after music playback is paused).
Note
No onMusicPrepareToPlay notification will be received.
public abstract void resumePlayMusic();

Seat Management APIs

enterSeat

This API is used to become a speaker (called by room owner or listener).
Note
After a user becomes a speaker, all users in the room will receive an onSeatListChange notification and an onAnchorEnterSeat notification.
public abstract void enterSeat(int seatIndex, TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
seatIndex
int
The number of the seat to be taken.
callback
ActionCallback
The callback for the operation.
Calling this API will immediately modify the seat list. In cases where listeners need the room owner’s permission to take a seat, you can call sendInvitation first to send a request and, after receiving onInvitationAccept, call this API.

leaveSeat

This API is used to become a listener (called by speaker).
Note
After a speaker becomes a listener, all members in the room will receive an onSeatListChange notification and an onAnchorLeaveSeat notification.
public abstract void leaveSeat(TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
callback
ActionCallback
The callback for the operation.

pickSeat

This API is used to place a user in a seat (called by room owner).
Note
After the room owner makes someone a speaker, all members in the room will receive an onSeatListChange notification and an onAnchorEnterSeat notification.
public abstract void pickSeat(int seatIndex, String userId, TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
seatIndex
int
The number of the seat to place the listener in.
userId
String
The user ID.
callback
ActionCallback
The callback for the operation.
Calling this API will immediately modify the seat list. In cases where the room owner needs listeners’ permission to make them speakers, you can call sendInvitation first to send a request and, after receiving onInvitationAccept, call pickSeat.

kickSeat

This API is used to remove a speaker (called by room owner).
Note
After a speaker is removed from a seat, all members in the room will receive an onSeatListChange notification and an onAnchorLeaveSeat notification.
public abstract void kickSeat(int seatIndex, TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
seatIndex
int
The number of the seat to remove the speaker from.
callback
ActionCallback
The callback for the operation.
Calling this API will immediately modify the seat list.

muteSeat

This API is used to mute/unmute a seat (called by room owner).
Note
After a seat is muted/unmuted, all members in the room will receive an onSeatListChange notification and an onSeatMute notification.
public abstract void muteSeat(int seatIndex, boolean isMute, TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
seatIndex
int
The number of the seat to mute/unmute.
isMute
boolean
true: Mute; false: Unmute
callback
ActionCallback
The callback for the operation.
Calling this API will immediately modify the seat list. The speaker on the seat specified by seatIndex will call muteAudio to mute/unmute his or her audio.

closeSeat

This API is used to block/unblock a seat (called by room owner).
Note
After a seat is blocked/unblocked, all members in the room will receive an onSeatListChange notification and an onSeatClose notification.
public abstract void closeSeat(int seatIndex, boolean isClose, TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
seatIndex
int
The number of the seat to block/unblock.
isClose
boolean
true: Block; false: Unblock
callback
ActionCallback
The callback for the operation.
Calling this API will immediately modify the seat list. The speaker on the seat specified by seatIndex will leave the seat.

Local Audio APIs

startMicrophone

This API is used to start mic capturing.
public abstract void startMicrophone();

stopMicrophone

This API is used to stop mic capturing.
public abstract void stopMicrophone();

setAudioQuality

This API is used to set audio quality.
public abstract void setAudioQuality(int quality);
The parameters are described below:
Parameter
Type
Description
quality
int
The audio quality. For more information, see setAudioQuality().

muteLocalAudio

This API is used to mute/unmute local audio.
public abstract void muteLocalAudio(boolean mute);
The parameters are described below:
Parameter
Type
Description
mute
boolean
Whether to mute or unmute audio. For more information, see muteLocalAudio().

setSpeaker

This API is used to set whether to play sound from the device’s speaker or receiver.
public abstract void setSpeaker(boolean useSpeaker);
The parameters are described below:
Parameter
Type
Description
useSpeaker
boolean
true: Speaker; false: Receiver

setAudioCaptureVolume

This API is used to set the mic capturing volume.
public abstract void setAudioCaptureVolume(int volume);
The parameters are described below:
Parameter
Type
Description
volume
int
The capturing volume. Value range: 0-100 (default: 100)

setAudioPlayoutVolume

This API is used to set the playback volume.
public abstract void setAudioPlayoutVolume(int volume);
The parameters are described below:
Parameter
Type
Description
volume
int
The playback volume. Value range: 0-100 (default: 100)

muteRemoteAudio

This API is used to mute/unmute a specified user.
public abstract void muteRemoteAudio(String userId, boolean mute);
The parameters are described below:
Parameter
Type
Description
userId
String
The user ID.
mute
boolean
true: Mute; false: Unmute

muteAllRemoteAudio

This API is used to mute/unmute all users.
public abstract void muteAllRemoteAudio(boolean mute);
The parameters are described below:
Parameter
Type
Description
mute
boolean
true: Mute; false: Unmute

setVoiceEarMonitorEnable

This API is used to enable/disable in-ear monitoring.
public abstract void setVoiceEarMonitorEnable(boolean enable);
The parameters are described below:
Parameter
Type
Description
enable
boolean
true: Enable; false: Disable

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();

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, TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
message
String
A text chat message.
callback
ActionCallback
The callback for the operation.

sendRoomCustomMsg

This API is used to send a custom text message.
public abstract void sendRoomCustomMsg(String cmd, String message, TRTCKaraokeRoomCallback.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
A text chat message.
callback
ActionCallback
The callback for the operation.

Invitation Signaling APIs

sendInvitation

This API is used to send an invitation.
public abstract String sendInvitation(String cmd, String userId, String content, TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
cmd
String
Custom command of business
userId
String
The user ID of the invitee.
content
String
The content of the invitation.
callback
ActionCallback
The callback for the operation.
Response parameters:
Parameter
Type
Description
inviteId
String
The invitation ID.

acceptInvitation

This API is used to accept an invitation.
public abstract void acceptInvitation(String id, TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
id
String
The invitation ID.
callback
ActionCallback
The callback for the operation.

rejectInvitation

This API is used to decline an invitation.
public abstract void rejectInvitation(String id, TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
id
String
Invitation ID
callback
ActionCallback
The callback for the operation.

cancelInvitation

This API is used to cancel an invitation.
public abstract void cancelInvitation(String id, TRTCKaraokeRoomCallback.ActionCallback callback);
The parameters are described below:
Parameter
Type
Description
id
String
The invitation ID.
callback
ActionCallback
The callback for the operation.


TRTCKaraokeRoomDelegate Event Callback APIs

Common Event Callback APIs

onError

Callback for error.
This callback indicates that the SDK encountered an unrecoverable error. Such errors must be listened for, and UI reminders should be sent to users depending if necessary.
void onError(int code, String message);
The parameters are described below:
Parameter
Type
Description
code
int
The error code.
message
String
The error message.

onWarning

Callback for warning.
void onWarning(int code, String message);
The parameters are described below:
Parameter
Type
Description
code
int
The error code.
message
String
The 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. When the owner terminates the room, all users in the room will receive this callback.
void onRoomDestroy(String roomId);
The parameters are described below:
Parameter
Type
Description
roomId
String
The room ID.

onRoomInfoChange

Callback for change of room information. This callback is sent after successful room entry. The information in roomInfo is passed in by the room owner during room creation.
void onRoomInfoChange(TRTCKaraokeRoomDef.RoomInfo roomInfo);
The parameters are described below:
Parameter
Type
Description
roomInfo
RoomInfo
Room information.

onUserMicrophoneMute

Callback of whether a user’s mic is muted. When a user calls muteLocalAudio, all members in the room will receive this callback.
void onUserMicrophoneMute(String userId, boolean mute);

The parameters are described below:
Parameter
Type
Description
userId
String
The user ID.
mute
boolean
The volume level. Value range: 0-100

onUserVolumeUpdate

Notification to all members of the volume after the volume reminder is enabled.
void onUserVolumeUpdate(List<TRTCCloudDef.TRTCVolumeInfo> userVolumes, int totalVolume);

The parameters are described below:
Parameter
Type
Description
userVolumes
List
List of user volumes.
totalVolume
int
The total volume. Value range: 0-100

Seat Callback APIs

onSeatListChange

Callback for all seat changes.
void onSeatListChange(List<SeatInfo> seatInfoList);
The parameters are described below:
Parameter
Type
Description
seatInfoList
List<SeatInfo>
The full seat list.

onAnchorEnterSeat

Someone became a speaker or was made a speaker by the owner.
void onAnchorEnterSeat(int index, TRTCKaraokeRoomDef.UserInfo user);
The parameters are described below:
Parameter
Type
Description
index
int
The seat taken.
user
UserInfo
The details of the user who took the seat.

onAnchorLeaveSeat

A speaker became a listener or was made a listener by the room owner.
void onAnchorLeaveSeat(int index, TRTCKaraokeRoomDef.UserInfo user);
The parameters are described below:
Parameter
Type
Description
index
int
The seat previously occupied by the speaker.
user
UserInfo
The details of the user who became a listener.

onSeatMute

The room owner muted/unmuted a seat.
void onSeatMute(int index, boolean isMute);
The parameters are described below:
Parameter
Type
Description
index
int
The seat muted/unmuted.
isMute
boolean
true: Muted; false: Unmuted

onSeatClose

The room owner blocked/unblocked a seat.
void onSeatClose(int index, boolean isClose);
The parameters are described below:
Parameter
Type
Description
index
int
The seat blocked/unblocked.
isClose
boolean
true: Blocked; false: Unblocked

Callback APIs for Room Entry/Exit by Listener

onAudienceEnter

A listener entered the room.
void onAudienceEnter(TRTCKaraokeRoomDef.UserInfo userInfo);
The parameters are described below:
Parameter
Type
Description
userInfo
UserInfo
The information of the listener who entered the room.

onAudienceExit

A listener exited the room.
void onAudienceExit(TRTCKaraokeRoomDef.UserInfo userInfo);
The parameters are described below:
Parameter
Type
Description
userInfo
UserInfo
The information of the listener who exited the room.

Message Event Callback APIs

onRecvRoomTextMsg

Callback for receiving a text chat message.
void onRecvRoomTextMsg(String message, TRTCKaraokeRoomDef.UserInfo userInfo);
The parameters are described below:
Parameter
Type
Description
message
String
A text chat message.
userInfo
UserInfo
Information of the sender.

onRecvRoomCustomMsg

A custom message was received.
void onRecvRoomCustomMsg(String cmd, String message, TRTCKaraokeRoomDef.UserInfo userInfo);
The parameters are described below:
Parameter
Type
Description
command
String
A custom command word used to distinguish between different message types.
message
String
A text chat message.
userInfo
UserInfo
Information of the sender.

Invitation Signaling Callback APIs

onReceiveNewInvitation

An invitation was received.
void onReceiveNewInvitation(String id, String inviter, String cmd, String content);
The parameters are described below:
Parameter
Type
Description
id
String
The invitation ID.
inviter
String
The user ID of the inviter.
cmd
String
A custom command word specified by business.
content
String
Content specified by business

onInviteeAccepted

The invitee accepted the invitation.
void onInviteeAccepted(String id, String invitee);
The parameters are described below:
Parameter
Type
Description
id
String
The invitation ID.
invitee
String
The user ID of the invitee.

onInviteeRejected

The invitee declined the invitation.
void onInviteeRejected(String id, String invitee);
The parameters are described below:
Parameter
Type
Description
id
String
The invitation ID.
invitee
String
The user ID of the invitee.

onInvitationCancelled

The inviter canceled the invitation.
void onInvitationCancelled(String id, String inviter);
The parameters are described below:
Parameter
Type
Description
id
String
The invitation ID.
inviter
String
The user ID of the inviter.

Music Playback Status Callback APIs

onMusicPrepareToPlay

Music playback is ready.
void onMusicPrepareToPlay(int musicID);
The parameters are described below:
Parameter
Type
Description
musicID
int
The musicID passed in for playback.

onMusicProgressUpdate

Music playback progress.
void onMusicProgressUpdate(int musicID, long progress, long total);
The parameters are described below:
Parameter
Type
Description
musicID
int
The musicID passed in for playback.
progress
long
The current playback progress in ms.
total
long
The total duration in ms.

onMusicCompletePlaying

Music playback was completed.
void onMusicCompletePlaying(int musicID);
The parameters are described below:
Parameter
Type
Description
musicID
int
The musicID passed in for playback.