
TUIKaraoke componentSource, Resources, and TXAppBasic folders and the TUIKaraoke.podspec file in the iOS directory to your project, and complete the following import operations:Podfile:pod 'TUIKaraoke', :path => "./", :subspecs => ["TRTC"]pod 'TXLiteAVSDK_TRTC'pod 'TXAppBasic', :path => "TXAppBasic/"
Podfile:pod install
info.plist file of your project. The SDKs need the following permissions (on iOS, the mic access must be requested at runtime):<key>NSMicrophoneUsageDescription</key><string>`TUIKaraoke` needs to access your mic.</string>
// 1. Initializelet karaokeRoom = TRTCKaraokeRoom.shared()karaokeRoom.setDelegate(delegate: self)// 2. Log inkaraokeRoom.login(SDKAppID: Int32(SDKAppID), UserId: UserId, UserSig: ProfileManager.shared.curUserSig()) { code, message inif code == 0 {// Logged in}}
SDKAppID information is as shown in the figure below:

SDKAppID. You can view your application’s secret key on the Application Management page of the TRTC console.SDKAppID, userId, and Secretkey. You can click here to directly generate a debugging userSig online. For more information, see UserSig.int roomId = "Room ID";let param = RoomParam.init()param.roomName = "Room name";param.needRequest = false; // Whether permission is required for listeners to speak.param.seatCount = 8; // Number of seats in the room. Set it to `8`.param.coverUrl = "URL of room cover image";karaokeRoom.createRoom(roomID: Int32(roomInfo.roomID), roomParam: param) { [weak self] (code, message) inguard let `self` = self else { return }if code == 0 {// Room created successfully}}
karaokeRoom.enterRoom(roomID: roomInfo.roomID) { [weak self] (code, message) inguard let `self` = self else { return }if code == 0 {// Entered room successfully}}
// 1. A listener calls an API to mic onint seatIndex = 1;karaokeRoom.enterSeat(seatIndex: seatIndex) { [weak self] (code, message) inguard let `self` = self else { return }if code == 0 {// Mic turned on successfully}}// 2. The listener receives the `onSeatListChange` callback and refreshes the seat listfunc onSeatListChange(seatInfoList: [SeatInfo]) {}
// Play back the musickaraokeRoom.startPlayMusic(musicID: musicID, originalUrl: muscicLocalPath, accompanyUrl: accompanyLocalPath);// Stop the musickaraokeRoom.stopPlayMusic();
// Sender: Sends text chat messageskaraokeRoom.sendRoomTextMsg(message: message) { [weak self] (code, message) inif code == 0 {// Sent successfully}}// Receiver: Listens for text chat messageskaraokeRoom.setDelegate(delegate: self)func onRecvRoomTextMsg(message: String, userInfo: UserInfo) {debugPrint("Received a message from" + userInfo.userName + ": " + message)}
// Sender: Customize `IMCMD_GIFT` to distinguish between gift messageskaraokeRoom.sendRoomCustomMsg(cmd: kSendGiftCmd, message: message) { code, msg inif (code == 0) {// Sent successfully}}// Receiver: Listens for gift messageskaraokeRoom.setDelegate(delegate: self)func onRecvRoomCustomMsg(cmd: String, message: String, userInfo: UserInfo) {if cmd == kSendGiftCmd {debugPrint("Received a gift from" + userInfo.userName + ": " + message)}}
TUIKaraoke component support sound effect features such as voice change, tone change, and reverb?Feedback