Host Live Streaming

The TUILiveKit Host Live Streaming Page provides an full-featured UI for live streaming scenarios. It supports the rapid deployment of core host capabilities, allowing you to efficiently integrate the live streaming workflow without worrying about complex UI and logic implementation.

Feature Overview

Pre-stream Setup: Supports various personalized configurations before the host goes live, including room name, background, video preview, beauty filters (beauty effects) debugging, audio effects debugging, and layout templates.
Co-Host Interaction: Supports real-time interaction (co-hosting) with viewers or other hosts during the live stream.
Audience Interaction: Supports rich interaction forms such as barrage (bullet screen) and gifts.
Live Room Management: Supports displaying the online user list and various management operations within the room, such as muting (banning) and kicking users.
Pre-stream Setup
Co-Host Interaction
Audience Interaction
Live Room Management














Quick Start

Step 1. Activate the Service

Refer to the Activate Service document to enable the Free trial or official package.

Step 2. Code Integration

Refer to Preparations guide to integrate the TUILiveKit SDK.

Step 3. Add the Pre-stream Setup view

The AnchorPrepareView component already has built-in features for camera preview, audio effects settings, layout settings, and other functional configurations. You need to create and load AnchorPrepareView. The specific example code is as follows:
Kotlin
Java
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.trtc.uikit.livekit.features.anchorprepare.AnchorPrepareView

class YourActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// 1. Create and initialize AnchorPrepareView
val anchorPrepareView = AnchorPrepareView(this)
anchorPrepareView.init("live_1236666", null)
// 2. Add AnchorPrepareView to the UI
setContentView(anchorPrepareView)
}
}
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.trtc.uikit.livekit.features.anchorprepare.AnchorPrepareView;

public class YourActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 1. Create and initialize AnchorPrepareView
AnchorPrepareView anchorPrepareView = new AnchorPrepareView(this);
anchorPrepareView.init("live_1236666", null);

// 2. Add AnchorPrepareView to the UI
setContentView(anchorPrepareView);
}
}

Step 4. Add the Host Streaming view

The AnchorView component has built-in features for audio/video pushing (streaming), viewer co-hosting, live interaction, and live room management. You only need to create and load AnchorView. The specific example code is as follows:
Kotlin
Java
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.tencent.cloud.tuikit.engine.extension.TUILiveListManager
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine
import com.trtc.uikit.livekit.features.anchorboardcast.AnchorView
import com.trtc.uikit.livekit.features.anchorboardcast.AnchorViewDefine.RoomBehavior
import com.trtc.uikit.livekit.features.anchorprepare.AnchorPrepareViewDefine.LiveStreamPrivacyStatus.PUBLIC

class YourActivity : AppCompatActivity() {
lateinit var anchorPrepareView: AnchorPrepareView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
anchorPrepareView = AnchorPrepareView(this)
anchorPrepareView.init("live_1236666", null)
setContentView(anchorPrepareView)
}

// Call this code after going live
fun initAnchorView() {
// 1. Create AnchorView
val anchorView = AnchorView(this)

// 2. Initialize AnchorView, where liveInfo is live room information and anchorPrepareView is your preparation page before going live
val liveInfo = TUILiveListManager.LiveInfo()
liveInfo.roomInfo = TUIRoomDefine.RoomInfo();
liveInfo.roomInfo.roomId = "live_1236666"
liveInfo.roomInfo.name = anchorPrepareView.state?.roomName?.getValue()
liveInfo.isPublicVisible = anchorPrepareView.state?.liveMode?.getValue() == PUBLIC
liveInfo.coverUrl = anchorPrepareView.state?.coverURL?.getValue()
liveInfo.seatLayoutTemplateId = anchorPrepareView.state.coGuestTemplateId.getValue()!!
// Room entry action:
// RoomBehavior.CREATE_ROOM: broadcaster creates a room
// RoomBehavior.ENTER_ROOM: Audience Enters Room
anchorView.init(liveInfo, anchorPrepareView?.coreView, RoomBehavior.CREATE_ROOM, null)


// 3. Add AnchorView to the UI
setContentView(anchorView)
}
}
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.tencent.cloud.tuikit.engine.extension.TUILiveListManager;
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
import com.trtc.uikit.livekit.features.anchorboardcast.AnchorView;
import com.trtc.uikit.livekit.features.anchorboardcast.AnchorViewDefine;
import com.trtc.uikit.livekit.features.anchorprepare.AnchorPrepareViewDefine;

public class YourActivity extends AppCompatActivity {

AnchorPrepareView anchorPrepareView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
anchorPrepareView = new AnchorPrepareView(this);
anchorPrepareView.init("live_123456", null);
setContentView(anchorPrepareView);
}

// Call this code after going live
private void initAnchorView() {
// 1. Create AnchorView
AnchorView anchorView = new AnchorView(this);

// 2. Initialize AnchorView, where liveInfo is live room information and anchorPrepareView is your preparation page before going live
TUILiveListManager.LiveInfo liveInfo = new TUILiveListManager.LiveInfo();
liveInfo.roomInfo = new TUIRoomDefine.RoomInfo();
liveInfo.roomInfo.roomId = "live_1236666";
liveInfo.roomInfo.name = anchorPrepareView.getState().roomName.getValue();
liveInfo.isPublicVisible = anchorPrepareView.getState().liveMode.getValue() == AnchorPrepareViewDefine.LiveStreamPrivacyStatus.PUBLIC;
liveInfo.coverUrl = anchorPrepareView.getState().coverURL.getValue();
// Room entry action:
// RoomBehavior.CREATE_ROOM: broadcaster creates a room
// RoomBehavior.ENTER_ROOM: Audience Enters Room
anchorView.init(liveInfo, anchorPrepareView.getCoreView(), AnchorViewDefine.RoomBehavior.CREATE_ROOM);

// 3. Add AnchorView to the UI
setContentView(anchorView);
}
}

Step 5. Transition from Pre-stream Setup to Host Streaming

Combine this with Step 3 to implement the delegate events of the AnchorPrepareView component, completing the transition to the host streaming page. The specific example code is as follows:
Kotlin
Java
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.trtc.uikit.livekit.features.anchorprepare.AnchorPrepareView
import com.trtc.uikit.livekit.features.anchorprepare.AnchorPrepareViewDefine.AnchorPrepareViewListener

class YourActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val anchorPrepareView = AnchorPrepareView(this)
anchorPrepareView.init("live_1236666", null)

// 1. Add preview page click event listening
anchorPrepareView.addAnchorPrepareViewListener(object : AnchorPrepareViewListener {
override fun onClickStartButton() {
// Handle the click event, switch the page to your broadcaster stream page, see the initAnchorView method in procedure 4
initAnchorView()
}
override fun onClickBackButton() {
finish()
}
})

// 2. Add AnchorPrepareView to the UI
setContentView(anchorPrepareView)
}
}
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.trtc.uikit.livekit.features.anchorprepare.AnchorPrepareView;
import com.trtc.uikit.livekit.features.anchorprepare.AnchorPrepareViewDefine;

public class YourActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AnchorPrepareView anchorPrepareView = new AnchorPrepareView(this);
anchorPrepareView.init("live_123456", null);
// 1. Add preview page click event listening
anchorPrepareView.addAnchorPrepareViewListener(new AnchorPrepareViewDefine.AnchorPrepareViewListener() {
@Override
public void onClickStartButton() {
// Handle the click event, switch the page to your broadcaster stream page, see the initAnchorView method in procedure 4
initAnchorView()
}

@Override
public void onClickBackButton() {
finish();
}
});
// 2. Add AnchorPrepareView to the UI
setContentView(anchorPrepareView);
}
}

Customize Your UI Layout

TUILiveKit supports flexible customization of the host setup and live pages, allowing you to adjust the layout and hide/show functional modules based on your business requirements.

Live Layout Template Selection

TUILiveKit provides 4 live layout templates. You can select the appropriate style in the "Layout" UI interaction entry on the host setup page:


Layout Template Overview

Name
dynamic grid layout
dynamic float layout
static grid layout
static float layout
Template ID
600
601
800
801
Description
The default layout; grid size adjusts dynamically based on the number of co-hosts.
Co-hosts are displayed in floating small windows.
The number of co-hosts is fixed, and each co-host occupies a fixed grid cell.
The number of co-hosts is fixed, and co-hosts are displayed in fixed small windows.
Preview













Customize AnchorPrepareView Feature Area

By calling the API of prepareView created in Step 3, you can customize and hide the operation area or specific features on the host setup page:
Kotlin
Java
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.trtc.uikit.livekit.features.anchorprepare.AnchorPrepareView

class YourActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val anchorPrepareView = AnchorPrepareView(this)
anchorPrepareView.init("live_1236666", null)

// 1. Custom function area - Example: Hide the entire feature area
anchorPrepareView.disableFeatureMenu(true)
setContentView(anchorPrepareView)
}
}
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.trtc.uikit.livekit.features.anchorprepare.AnchorPrepareView;

public class YourActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AnchorPrepareView anchorPrepareView = new AnchorPrepareView(this);
anchorPrepareView.init("live_1236666", null);
// 1. Custom function area - Example: Hide the entire feature area
anchorPrepareView.disableFeatureMenu(true);

setContentView(anchorPrepareView);
}
}
API
Description
disableFeatureMenu(true)
Hide Entire Feature Area
disableMenuBeautyButton(true)
Hide Beauty Effect Button
disableMenuAudioEffectButton(true)
Hide Sound Effect Button
disableMenuSwitchCameraButton(true)
Hide Camera Toggle Button


Customize AnchorView Feature Area

By calling the API of anchorView created in Step 4, you can customize and hide the operation area or specific features on the host live page:
Kotlin
Java
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.tencent.cloud.tuikit.engine.extension.TUILiveListManager
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine
import com.trtc.uikit.livekit.features.anchorboardcast.AnchorView
import com.trtc.uikit.livekit.features.anchorboardcast.AnchorViewDefine.RoomBehavior
import com.trtc.uikit.livekit.features.anchorprepare.AnchorPrepareViewDefine.LiveStreamPrivacyStatus.PUBLIC

class YourActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val anchorView = AnchorView(this)
val liveInfo = TUILiveListManager.LiveInfo()
liveInfo.roomInfo = TUIRoomDefine.RoomInfo();
liveInfo.roomInfo.roomId = "live_1236666"
liveInfo.roomInfo.name = anchorPrepareView.state?.roomName?.getValue()
liveInfo.isPublicVisible = anchorPrepareView.state?.liveMode?.getValue() == PUBLIC
liveInfo.coverUrl = anchorPrepareView.state?.coverURL?.getValue()
liveInfo.seatLayoutTemplateId = anchorPrepareView.state.coGuestTemplateId.getValue()!!
anchorView.init(liveInfo, anchorPrepareView?.coreView, RoomBehavior.CREATE_ROOM, null)

// 1. Custom function area - Example: Hide the anchor connection feature
anchorView.disableFooterCoHost(true)

setContentView(anchorView)
}
}
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.tencent.cloud.tuikit.engine.extension.TUILiveListManager;
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
import com.trtc.uikit.livekit.features.anchorboardcast.AnchorView;
import com.trtc.uikit.livekit.features.anchorboardcast.AnchorViewDefine;
import com.trtc.uikit.livekit.features.anchorprepare.AnchorPrepareViewDefine;

public class YourActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AnchorView anchorView = new AnchorView(this);
TUILiveListManager.LiveInfo liveInfo = new TUILiveListManager.LiveInfo();
liveInfo.roomInfo = new TUIRoomDefine.RoomInfo();
liveInfo.roomInfo.roomId = "live_1236666";
liveInfo.roomInfo.name = anchorPrepareView.getState().roomName.getValue();
liveInfo.isPublicVisible = anchorPrepareView.getState().liveMode.getValue() == AnchorPrepareViewDefine.LiveStreamPrivacyStatus.PUBLIC;
liveInfo.coverUrl = anchorPrepareView.getState().coverURL.getValue();
anchorView.init(liveInfo, anchorPrepareView.getCoreView(), AnchorViewDefine.RoomBehavior.CREATE_ROOM);

// 1. Custom function area - Example: Hide the anchor connection feature
anchorView.disableFooterCoHost(true);
setContentView(anchorView);
}
}
API
Description
disableHeaderVisitorCnt(true)
Hide Top Audience List Feature
disableFooterCoGuest(true)
Hide Bottom Audience Mic Connection Feature
disableFooterCoHost(true)
Hide Bottom Anchor Connection Feature
disableFooterBattle(true)
Hide Bottom Anchor PK Function


Text Customization (String Resources)

TUILiveKit uses standard Android XML resource files to manage the text displayed in the UI. You can directly modify the strings that need adjustment via the XML file:


Icon Customization (Drawable Resources)

TUILiveKit uses the standard Android drawable resource folder to manage the image resources for the UI. You can quickly change the custom icons by replacing the resource files. When replacing, ensure that the new file names are consistent with the original file names.


Next Steps

Congratulations! You have successfully integrated the Host Live Streaming component. Next, you can implement features such as viewer watching and the live stream list. Please refer to the table below:
Feature
Description
Integration Guide
Audience Viewing
Audience can watch live streaming after entering the anchor's live streaming room, with features like audience mic connection, live room information, online audience, and bullet screen display.
Live Stream List
Display the live stream list interface and features, including the live stream list and room information display.

FAQs

Why is there no video feed after starting the stream?

Please go to App Info > Permissions > Camera and check if the camera permission is enabled. Refer to the image below:


Why does clicking the "Start Stream" button fail with a "Not Logged In" prompt?

Refer to Complete Login to confirm that you have completed the login feature integration.