tencent cloud

Feedback

Last updated: 2024-08-22 11:16:54

    Component Introduction

    TUILiveKit already supports the room list UI component (TUILiveListFragment), which can help you display all the live broadcasts and voice chat rooms in the current application. After you access the room list UI component, you only need to click on a live broadcast room in the list to watch the live broadcast content of the current anchor in real time. After entering the live broadcast room, you can also interact with the anchor in real time through barrage, gifts, microphone connection and other functions.
    Room List Component
    Watch Live
    Connect with the host
    
    
    
    
    
    
    
    
    

    Prerequisites

    Before using the room list function provided by TUILiveKit, you need to complete the relevant configuration and login of TUILiveKit component access. For details, see Quick Access.

    Access room list

    Note:
    It's important to make sure you've followed Quick Access to complete the login. Only after you log in to TUILogin.login can you enter the live preview screen normally.
    1. Create a new file named app_activity_main.xml (Default path: app/src/main/res/layout/app_activity_main.xml).
    <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/fl_live_list" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout>
    2. Create a new file named MainActivity.java and register in the AndroidManifest.xml. By loading TUILiveKit TUILiveListFragment page, you can Present a list of rooms
    Java
    public class MainActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.app_activity_main);
    
    FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); TUILiveListFragment listFragment = new TUILiveListFragment(); fragmentTransaction.add(R.id.fl_live_list, listFragment); fragmentTransaction.commit(); } }
    Register MainActivity in AndroidManifest.xml of the app Project (please use the actual package name of your MainActivity):
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <application>
    ...
    <!-- Example: To register MainActivity, please use your actual package name -->
    <activity
    android:name="com.trtc.uikit.livekit.example.view.main.MainActivity"
    android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"/>
    ...
    </application>
    </manifest>
    Note:
    Since MainActivity inherited from AppCompatActivity, MainActivity was given a Theme.AppCompattheme. You can modify it to your own Theme.AppCompat theme.
    If you encounter problems with Theme.AppCompat, please refer to Activity Theme Questions.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support