two-way connection | multi-way connection |
![]() | ![]() |
Click Co-Host Button | Select Host for Co-Host | Co-Host successful | Disconnect |
![]() | ![]() | ![]() | ![]() |
Receives the invitation | Accepts the invitation |
![]() | ![]() |
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.// File Path: java/com/trtc/uikit/livekit/manager/controller/ConnectionController.javapublic 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); } }); }
// 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
//
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}
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.requestConnection
and passing in the room id of anchor B to be connected in the parameter roomIdList.// File Path:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/service/impl/LiveServiceImpl.javapublic void requestConnection(List<String> roomIdList, int timeoutSeconds, String extensionInfo, TUILiveConnectionManager.ConnectionRequestCallback callback) { mTUILiveConnectionManager.requestConnection(roomIdList, timeoutSeconds, extensionInfo, callback); }
onConnectionRequestAccept
.onConnectionRequestReceived
.// File Path:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/manager/observer/LiveConnectionManagerObserver.javapublic void onConnectionRequestReceived(TUILiveConnectionManager.ConnectionUser inviter, List<TUILiveConnectionManager.ConnectionUser> inviteeList, String extensionInfo) { mConnectionController.onConnectionRequestReceived(inviter, inviteeList, extensionInfo); }
accept
.// File Path:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/service/impl/LiveServiceImpl.javapublic void accept(String roomId, TUIRoomDefine.ActionCallback callback) { mTUILiveConnectionManager.acceptConnection(roomId, callback); }
onConnectionUserListChanged
callback and are notified of changes to the co-host list.// File Path:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/manager/observer/LiveConnectionManagerObserver.javapublic void onConnectionUserListChanged(List<TUILiveConnectionManager.ConnectionUser> connectedList, List<TUILiveConnectionManager.ConnectionUser> joinedList, List<TUILiveConnectionManager.ConnectionUser> leavedList) { mConnectionController.onConnectionUserListChanged(connectedList, joinedList, leavedList); }
disconnect
to exit the co-host.// File Path:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/service/impl/LiveServiceImpl.javapublic void disconnect(TUIRoomDefine.ActionCallback callback) { mTUILiveConnectionManager.disconnect(callback); }
onConnectionUserListChanged
callback and are notified of changes to the co-host list.// File Path:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/manager/observer/LiveConnectionManagerObserver.javapublic void onConnectionUserListChanged(List<TUILiveConnectionManager.ConnectionUser> connectedList, List<TUILiveConnectionManager.ConnectionUser> joinedList, List<TUILiveConnectionManager.ConnectionUser> leavedList) { mConnectionController.onConnectionUserListChanged(connectedList, joinedList, leavedList); }
Was this page helpful?