tencent cloud

Feedback

Last updated: 2024-08-30 17:15:33

    Component Introduction

    The Co-Host function is a real-time interactive communication method, specially tailored for anchors. It allows anchors from different rooms to achieve real-time interaction and communication during the live broadcast. The connection function of TUILiveKit can support up to 9 people in a single room to connect at the same time, providing powerful technical support for anchor interaction, knowledge sharing, cultural exchange, e-commerce training and other scenarios. It not only provides anchors with a variety of interactive methods, but also brings a richer and deeper viewing experience to the audience, thereby creating more surprises and value for both parties and making live broadcasts more attractive.
    two-way connection
    multi-way connection
    
    
    
    
    
    

    Instructions for Use

    Co-Host a Live

    Click Co-Host Button
    Select Host for Co-Host
    Co-Host successful
    Disconnect
    
    
    
    
    
    
    
    
    
    
    
    

    Invited to Co-Host

    Receives the invitation
    Accepts the invitation
    
    
    
    
    
    

    Custom Functionality

    Replace Recommendation List Source

    The recommended list data source in TUILiveKit by default uses fetchLiveList to retrieve the live stream list. If you need to use a custom recommended list, you can refer to the example code below to replace the corresponding recommended list data.
    java
    // File Path: java/com/trtc/uikit/livekit/manager/controller/ConnectionController.java
    
    public void fetchLiveList() { mLiveService.fetchLiveList(mConnectionState.recommendedCursor, FETCH_LIST_COUNT, new TUILiveListManager.LiveInfoListCallback() { @Override public void onSuccess(TUILiveListManager.LiveInfoListResult result) { handlerFetchLiveListSuccess(result); } @Override public void onError(TUICommonDefine.Error error, String s) { ErrorHandler.onError(error); } }); }

    Custom Co-Host Panel UI

    If you need to customize the Co-Host panel UI, recommendation list UI, or connected list UI, please refer to the following paths for changes.
    // File LocatiPathon:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/view/liveroom/view/anchor/component/livestreaming/connection/
    
    ├── AnchorConnectionManagePanel.java // Co-Host panel
    ├── AnchorRecommendedAdapter.java // recommendation list
    └── AnchorConnectingAdapter.java // connected list

    Custom Video View UI

    If you need to customize the Co-Host video view UI, please refer to the following paths for changes.
    java
    // File Location:view/liveroom/view/common/video/VideoView.java
    
    public class VideoView extends BasicView {
    @Override protected void initView() {
    LayoutInflater.from(mContext).inflate(R.layout.livekit_video_view, this, true);
    // Please modify the UI layout in livekit_video_view.xml
    }
    // Modify your UI interaction logic here
    }

    Key Code

    Co-Host

    The TUILiveKit anchor co-host function is mainly implemented based on LiveService. In LiveService, you can get the connection management class object through mTUIRoomEngine.getLiveConnectionManager(), and then call the connection-related API functions to implement the co-host function. Taking the host between anchors A and B as an example, the specific interaction sequence can be referred to the figure below.
    
    
    

    Anchor A initiates a co-host

    Anchor A initiates a co-host by calling requestConnection and passing in the room id of anchor B to be connected in the parameter roomIdList.
    java
    // File Path:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/service/impl/LiveServiceImpl.java
    public void requestConnection(List<String> roomIdList, int timeoutSeconds, String extensionInfo, TUILiveConnectionManager.ConnectionRequestCallback callback) { mTUILiveConnectionManager.requestConnection(roomIdList, timeoutSeconds, extensionInfo, callback); }
    Anchor A can receive the request approval callback through onConnectionRequestAccept.

    Anchor B receives a co-host request

    Anchor B receives the connection request callback through onConnectionRequestReceived.
    java
    // File Path:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/manager/observer/LiveConnectionManagerObserver.java
    public void onConnectionRequestReceived(TUILiveConnectionManager.ConnectionUser inviter, List<TUILiveConnectionManager.ConnectionUser> inviteeList, String extensionInfo) { mConnectionController.onConnectionRequestReceived(inviter, inviteeList, extensionInfo); }
    Anchor B accepts the connection request by calling accept .
    java
    // File Path:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/service/impl/LiveServiceImpl.java
    public void accept(String roomId, TUIRoomDefine.ActionCallback callback) { mTUILiveConnectionManager.acceptConnection(roomId, callback); }
    Anchor A, B, and the audience in the room receive the onConnectionUserListChanged callback and are notified of changes to the co-host list.
    java
    // File Path:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/manager/observer/LiveConnectionManagerObserver.java
    public void onConnectionUserListChanged(List<TUILiveConnectionManager.ConnectionUser> connectedList, List<TUILiveConnectionManager.ConnectionUser> joinedList, List<TUILiveConnectionManager.ConnectionUser> leavedList) { mConnectionController.onConnectionUserListChanged(connectedList, joinedList, leavedList); }

    Disconnects

    Take the example of host B disconnects, the interaction sequence can be referred to in the figure below.
    
    
    
    Anchor B calls disconnect to exit the co-host.
    java
    // File Path:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/service/impl/LiveServiceImpl.java
    public void disconnect(TUIRoomDefine.ActionCallback callback) { mTUILiveConnectionManager.disconnect(callback); }
    Streamers A, B, and the audience in the room receive the onConnectionUserListChanged callback and are notified of changes to the co-host list.
    java
    // File Path:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/manager/observer/LiveConnectionManagerObserver.java
    public void onConnectionUserListChanged(List<TUILiveConnectionManager.ConnectionUser> connectedList, List<TUILiveConnectionManager.ConnectionUser> joinedList, List<TUILiveConnectionManager.ConnectionUser> leavedList) { mConnectionController.onConnectionUserListChanged(connectedList, joinedList, leavedList); }
    Note:
    The co-host function is implemented based on LiveService. If you need to extend the co-host function, please refer to the TUILiveConnectionManager document.
    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