
Source、Resources、TXAppBasic文件夹和 TUIKaraoke.podspec文件到您的工程中,并完成如下导入动作:Podfile 文件内添加导入命令,参考如下:pod 'TUIKaraoke', :path => "./", :subspecs => ["TRTC"]pod 'TXLiteAVSDK_TRTC'pod 'TXAppBasic', :path => "TXAppBasic/"
Podfile 文件所在目录下执行安装命令,参考如下:pod install
<key>NSMicrophoneUsageDescription</key><string>Karaoke 需要访问您的麦克风权限</string>
// 1.初始化let karaokeRoom = TRTCKaraokeRoom.shared()karaokeRoom.setDelegate(delegate: self)// 2.登录karaokeRoom.login(SDKAppID: Int32(SDKAppID), UserId: UserId, UserSig: ProfileManager.shared.curUserSig()) { code, message inif code == 0 {//登录成功}}

int roomId = "房间ID";let param = RoomParam.init()param.roomName = "房间名称";param.needRequest = false; // 上麦是否需要房主确认param.seatCount = 8; // 房间座位数,一共8个座位param.coverUrl = "房间封面图URL";karaokeRoom.createRoom(roomID: Int32(roomInfo.roomID), roomParam: param) { [weak self] (code, message) inguard let `self` = self else { return }if code == 0 {//创建成功}}
karaokeRoom.enterRoom(roomID: roomInfo.roomID) { [weak self] (code, message) inguard let `self` = self else { return }if code == 0 {//进房成功}}
// 1.听众调用上麦int seatIndex = 1;karaokeRoom.enterSeat(seatIndex: seatIndex) { [weak self] (code, message) inguard let `self` = self else { return }if code == 0 {//上麦成功}}// 2.收到 onSeatListChange 回调,刷新麦位列表func onSeatListChange(seatInfoList: [SeatInfo]) {}
//播放音乐karaokeRoom.startPlayMusic(musicID: musicID, originalUrl: muscicLocalPath, accompanyUrl: accompanyLocalPath);//停止音乐karaokeRoom.stopPlayMusic();
// 发送端:发送文本消息karaokeRoom.sendRoomTextMsg(message: message) { [weak self] (code, message) inif code == 0 {//发送成功}}// 接收端:监听文本消息karaokeRoom.setDelegate(delegate: self)func onRecvRoomTextMsg(message: String, userInfo: UserInfo) {debugPrint("收到来自:" + userInfo.userName + "的消息:" + message)}
// 发送端:通过自定义 "IMCMD_GIFT" 来区分礼物消息karaokeRoom.sendRoomCustomMsg(cmd: kSendGiftCmd, message: message) { code, msg inif (code == 0) {//发送成功}}// 接收端:监听礼物消息karaokeRoom.setDelegate(delegate: self)func onRecvRoomCustomMsg(cmd: String, message: String, userInfo: UserInfo) {if cmd == kSendGiftCmd {debugPrint("收到来自:" + userInfo.userName + "的礼物:" + message)}}
文档反馈