TUIRoom
is an open-source audio/video UI component. After integrating it into your project, you can add features such as screen sharing, beauty filter, and low-latency video call to your application simply by writing a few lines of code. It also supports the Android, Windows, and macOS platforms. Its basic features are as shown below:
![]() |
![]() |
![]() |
TUIRoom
componentTo import the component through CocoaPods, follow the steps below:
Note:To implement the screen sharing feature, download
TXLiteAVSDK_ReplayKitExt.framework
here, add it to your project, and create the "Broadcast Upload Extension" target. You can refer to the demo project for implementation.
Resources
, SDK
, and Source
folders and the TUIRoom.podspec
file in the iOS
directory to your project.Podfile
and run pod install
to complete the import.# TXLiteAVSDK
pod 'TXLiteAVSDK_TRTC'
# :path => "Points to the relative path of the directory of `TXAppBasic.podspec`"
pod 'TXAppBasic', :path => "../SDK/TXAppBasic/"
# :path => "Points to the relative path of the directory of `TCBeautyKit.podspec`"
pod 'TCBeautyKit', :path => "../SDK/TCBeautyKit/"
# :path => "Points to the relative path of the directory of `TUIRoom.podspec`"
pod 'TUIRoom', :path => "../", :subspecs => ["TRTC"]
Note:The
Source
andResources
folders and theTUIRoom.podspec
file must be in the same directory.
TXAppBasic.podspec
is in theTXAppBasic
folder.TCBeautyKit.podspec
is in theTCBeautyKit
folder.
To use the audio/video features, you need to grant mic and camera permissions. Add the two items below to Info.plist
of your application. Their content is what users see in the mic and camera access pop-up windows.
TUILogin
in TUICore
to log in as shown below:TUILogin.initWithSdkAppID(Int32("Your sdkAppID"))
TUILogin.login("Your userId", userSig: "Your userSig", succ: {
debugPrint("login success")
}, fail: { code, errorDes in
debugPrint("login failed, code:\(code), error: \(errorDes ?? "nil")")
})
Parameter description
SDKAppID
is as shown 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 or calculate it on your own by referring to the demo project. For more information, see UserSig.The room owner creates a group audio/video interaction room through TUIRoomCore#createRoom.
let roomId = 123
TUIRoomCore.shareInstance().createRoom("\(roomId)",speechMode: .freeSpeech,callback: { [weak self] code, message in
if code == 0 {
debugPrint("create room success")
} else {
}
})
Other users enter the audio/video room through TUIRoomCore#enterRoom.
let roomId = 123
TUIRoomCore.shareInstance().enterRoom("\(roomId)", callback: { [weak self] code, message in
if code == 0 {
debugPrint("enter room success")
} else {
}
})
Implement room exit.
onDestroyRoom
callback message that notifies them of group dismissal and exit the TRTC room.onRemoteUserLeave
callback message that notifies them of the room exit by the member.if isHomeowner {
TUIRoomCore.shareInstance().destroyRoom { [weak self] _, _ in
guard let self = self else { return }
self.navigationController?.popViewController(animated: true)
}
} else {
TUIRoomCore.shareInstance().leaveRoom { [weak self] _, _ in
guard let self = self else { return }
self.navigationController?.popViewController(animated: true)
}
}
Implement screen sharing through TUIRoomCore#startScreenCapture.
startScreenCapture
of TUIRoomCore
to share the screen.onRemoteUserScreenVideoAvailable
event notification.// Click the button to enable screen sharing
if #available(iOS 12.0, *) {
// Start screen sharing
let params = TRTCVideoEncParam()
params.videoResolution = TRTCVideoResolution._1280_720
params.resMode = TRTCVideoResolutionMode.portrait
params.videoFps = 10
params.enableAdjustRes = false
params.videoBitrate = 1500
TUIRoomCore.shareInstance().startScreenCapture(params)
TUIRoomBroadcastExtensionLauncher.launch()
} else {
view.window?.makeToast(.versionLowToastText)
}
Enter the following command in a terminal window (you need to install Ruby on your Mac first):
sudo gem install cocoapods
Note:If you have any requirements or feedback, contact colleenyu@tencent.com.
Was this page helpful?