
Source and Debug directories in the Android directory to your project, and complete the following import operations:setting.gradle as shown below:include ':Source'include ':Debug'
TUIKaraoke to the build.gradle file in app:api project(':Source')
TRTC SDK and IM SDK to the build.gradle file in the root directory:ext {liteavSdk = "com.tencent.liteav:LiteAVSDK_TRTCl:latest.release"imSdk = "com.tencent.imsdk:imsdk-plus:latest.release"}
AndroidManifest.xml. The SDKs need the following permissions (on Android 6.0 and later, the mic access and storage read permission must be requested at runtime):<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> // Use case: This permission is required for the floating window<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.RECORD_AUDIO" /><uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /><uses-permission android:name="android.permission.BLUETOOTH" /> // Use case: This permission is required when a Bluetooth headset is used
proguard-rules.pro file, add the SDK classes to the "do not obfuscate" list.-keep class com.tencent.** { *;}
// 1. InitializeTRTCKaraokeRoom mTRTCKaraokeRoom = TRTCKaraokeRoom.sharedInstance(this);mTRTCKaraokeRoom.setDelegate(this);// 2. Log inmTRTCKaraokeRoom.login(SDKAppID, UserID, UserSig, new TRTCKaraokeRoomCallback.ActionCallback() {@Overridepublic void onCallback(int code, String msg) {if (code == 0) {// Logged in}}});
SDKAppID information is as shown in the figure below:

SDKAppID. On the Application Management page in the TRTC console, the SecretKey is as shown below:SDKAppID, userId, and Secretkey. You can click here to directly generate a debugging userSig online. For more information, see UserSig.int roomId = "Room ID";TRTCKaraokeRoomDef.RoomParam roomParam = new TRTCKaraokeRoomDef.RoomParam();roomParam.roomName = "Room name";roomParam.needRequest = false; // Whether your consent is required for listeners to speakroomParam.seatCount = 8; // Number of seats in the room. Set it to `8`roomParam.coverUrl = "URL of room cover image";mTRTCKaraokeRoom.createRoom(roomId, roomParam, new TRTCKaraokeRoomCallback.ActionCallback() {@Overridepublic void onCallback(int code, String msg) {if (code == 0) {// Room created successfully}}});
mTRTCKaraokeRoom.enterRoom(roomId, new TRTCKaraokeRoomCallback.ActionCallback() {@Overridepublic void onCallback(int code, String msg) {if (code == 0) {// Entered room successfully}}});
// 1. A listener calls an API to mic onint seatIndex = 1;mTRTCKaraokeRoom.enterSeat(seatIndex, new TRTCKaraokeRoomCallback.ActionCallback() {@Overridepublic void onCallback(int code, String msg) {if (code == 0) {// Mic turned on successfully}}});// 2. The listener receives the `onSeatListChange` callback and refreshes the seat list@Overridepublic void onSeatListChange(final List<TRTCKaraokeRoomDef.SeatInfo> seatInfoList) {}
// Play back the musicmTRTCKaraokeRoom.startPlayMusic(musicID,url);// Stop the musicmTRTCKaraokeRoom.stopPlayMusic();
// Sender: Sends text messagesmTRTCKaraokeRoom.sendRoomTextMsg("Hello Word!", new TRTCKaraokeRoomCallback.ActionCallback() {@Overridepublic void onCallback(int code, String msg) {if (code == 0) {// Sent successfully}}});// Receiver: Listens for text messagesmTRTCKaraokeRoom.setDelegate(new TRTCKaraokeRoomDelegate() {@Overridepublic void onRecvRoomTextMsg(String message, TRTCKaraokeRoomDef.UserInfo userInfo) {Log.d(TAG, "Received a message from" + userInfo.userName + ": " + message);}});
// Sender: Customize `CMD_GIFT` to distinguish between gift messagesmTRTCKaraokeRoom.sendRoomCustomMsg("CMD_GIFT",date, new TRTCKaraokeRoomCallback.ActionCallback() {@Overridepublic void onCallback(int code, String msg) {if (code == 0) {// Sent successfully}}});// Receiver: Listens for gift messagesmTRTCKaraokeRoom.setDelegate(new TRTCKaraokeRoomDelegate() {@Overridepublic void onRecvRoomCustomMsg(String cmd, String message, TRTCKaraokeRoomDef.UserInfo userInfo) {if ("CMD_GIFT".equals(cmd)) {// Received a gift messageLog.d(TAG, "Received a gift from" + userInfo.userName + ": " + message);}}});
TUIKaraoke component support sound effect features such as voice change, tone change, and reverb?Feedback