Live Streaming | Interactive co-guest | Live Information | Live Interactive |
![]() |
![]() | ![]() | ![]() |
TUILiveKit trial version or activate the paid version.YourAudienceViewController, initialize and add AudienceView for audience streaming:import UIKitimport SnapKitimport TUILiveKit// YourAudienceViewController represents the audience viewing page controllerclass YourAudienceViewController: UIViewController {// 1. Declare audienceView as a member variableprivate let audienceView: AudienceView// 2. Add a convenience initializer:// - roomId: Live room IDpublic init(roomId: String) {// 3. Initialize the AudienceView componentself.audienceView = AudienceView(roomId: roomId)super.init(nibName: nil, bundle: nil)}@available(*, unavailable)required init?(coder: NSCoder) {fatalError("init(coder:) has not been implemented")}public override func viewDidLoad() {super.viewDidLoad()// 4. Add audienceView to the view hierarchyview.addSubview(audienceView)audienceView.snp.makeConstraints { make inmake.edges.equalToSuperview()}}}
Extension Point | Type | Description |
delegate | AudienceViewDelegate | Listen for audience page events, such as live view creation/display/hide, floating window actions, live end, and more. |
dataSource | AudienceViewDataSource | Customize live stream list retrieval logic. By default, AudienceView uses TUILiveKit’s built-in list; set this to use your own APIs. |
rotateScreenDelegate | RotateScreenDelegate | Monitor audience page orientation changes to synchronize your UI layout with device rotation. |
import UIKitimport SnapKitimport TUILiveKitimport AtomicXCoreclass YourAudienceViewController: UIViewController {private let audienceView: AudienceViewpublic init(roomId: String) {self.audienceView = AudienceView(roomId: roomId)super.init(nibName: nil, bundle: nil)// Set callbacks and data sourceaudienceView.delegate = selfaudienceView.dataSource = selfaudienceView.rotateScreenDelegate = self}@available(*, unavailable)required init?(coder: NSCoder) {fatalError("init(coder:) has not been implemented")}public override func viewDidLoad() {super.viewDidLoad()view.addSubview(audienceView)audienceView.snp.makeConstraints { make inmake.edges.equalToSuperview()}}}// MARK: - AudienceViewDelegateextension YourAudienceViewController: AudienceViewDelegate {// Called when the live room playback view is created; overlay custom UI here if neededfunc audienceView(_ audienceView: AudienceView, onCreateLiveView liveView: AudienceLiveView, for liveInfo: LiveInfo) {}// Called when the audience swipes to a live room and its playback view appears on screenfunc audienceView(_ audienceView: AudienceView, liveViewDidAppear liveView: AudienceLiveView, for liveInfo: LiveInfo) {}// Called when the audience leaves a live room and its playback view is removed from the screenfunc audienceView(_ audienceView: AudienceView, liveViewDidDisappear liveView: AudienceLiveView, for liveInfo: LiveInfo) {}// Called when the user clicks the floating windowfunc onClickFloatWindow() {FloatWindow.shared.showFloatWindow(controller: self, provider: audienceView)}// Called when the live stream ends (host stops streaming, room is closed, etc.)func onLiveEnded(roomId: String, ownerName: String, ownerAvatarUrl: String) {// Display the live end summary page (includes host avatar/nickname, "Live Ended" prompt, etc.)let endView = AudienceEndStatisticsView(roomId: roomId, avatarUrl: ownerAvatarUrl, userName: ownerName)endView.delegate = selfview.addSubview(endView)endView.snp.makeConstraints { make inmake.edges.equalToSuperview()}}}// MARK: - RotateScreenDelegateextension YourAudienceViewController: RotateScreenDelegate {// isPortrait: true if portrait mode, false if landscape modefunc rotateScreen(isPortrait: Bool) {}}
// 1. Instantiate your audience viewing view controllerlet audienceVC =YourAudienceViewController(roomId: "Your live streaming room id")audienceVC.modalPresentationStyle = .fullScreen// 2. Navigate to your audience viewing view controllerpresent(audienceVC, animated: false)
AudienceView Feature Area.xcstrings) format, introduced in Xcode 15, to manage the text displayed in the UI. You can modify the string resources using Xcode's graphical interface:
TUILiveKit.xcassets to manage the image resources for the UI. You can quickly modify the custom icons using Xcode's graphical tools.
Feature | Description | Integration Guide |
Host Streaming | The complete workflow for a host to start a stream, including pre-stream setup and various in-stream interactions. | |
Live Stream List | Display the live stream list interface and features, including the live stream list and room information display. | |
Gift System | Support custom gift asset configuration, billing system integration, and gift-sending in PK scenarios. |

Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários