双人连线 | 多人连线 |
![]() | ![]() |
点击连线按钮 | 选择主播发起连线 | 连线成功 | 断开连线 |
![]() | ![]() | ![]() | ![]() |
主播收到邀请 | 主播接受邀请 |
![]() | ![]() |
// 文件位置: 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); } }); }
// 文件位置:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/view/liveroom/view/anchor/component/livestreaming/connection/├── AnchorConnectionManagePanel.java // 连线面板视图├── AnchorRecommendedAdapter.java // 推荐列表└── AnchorConnectingAdapter.java // 已连线列表
//
文件位置: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);// 请在livekit_video_view.xml中修改UI布局// 在此修改您的UI交互逻辑}}
LiveService
实现的,在LiveService
中,您可通过 mTUIRoomEngine.getLiveConnectionManager()
获取到连线管理类对象,进而调用连线相关 API 函数,实现连线功能。以主播 A,B连线为例,具体交互时序可参考下图。requestConnection
发起连线,在参数 roomIdList中传入需要连线的主播 B房间id。// 文件位置: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
接收连线请求回调。// 文件位置: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); }
connectionService.accept(roomId)
接受连线请求。// 文件位置: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
回调,收到接收连线列表发生变化通知。 // 文件位置: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
退出连线。// 文件位置:Android/tuilivekit/src/main/java/com/trtc/uikit/livekit/service/impl/LiveServiceImpl.javapublic void disconnect(TUIRoomDefine.ActionCallback callback) { mTUILiveConnectionManager.disconnect(callback); }
onConnectionUserListChanged
回调,收到接收连线列表发生变化通知。 // 文件位置: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); }
本页内容是否解决了您的问题?