单人连麦 | 多人连麦 |
| |
点击连麦请求按钮 | 选择连麦方式 | 发送连麦请求,等待主播同意 | 主播同意后,连麦成功 |
| | | |
收到观众的连麦请求 | 点击连麦用户,打开连麦面板 | 点击同意后,连麦成功 |
| | |
val userId = "anchorUserId";val timeout = 60;liveCoreView.requestIntraRoomConnection(userId, 10, null)
String userId = "anchorUserId";int timeout = 60;liveCoreView.requestIntraRoomConnection(userId, timeout, true, null);
let timeout = 60// 发起连麦请求时,userId传空字符串即可liveCoreView.requestIntraRoomConnection(userId: "", timeOut: timeOut, openCamera: true) {} onError: { code, message in}
NSInteger timeout = 60;// 发起连麦请求时,userId传空字符串即可[liveCoreView requestIntraRoomConnection:""timeOut:timeoutonSuccess:^(void) {} onError:^(NSInteger code, NSString * _Nonnull message) {}];
// 文件位置:Flutter/lib/service/impl/room_engine_service.dart@overrideTUIRequest takeSeat(int seatIndex, int timeout, TUIRequestCallback? requestCallback) {return roomEngine.takeSeat(seatIndex, timeout, requestCallback);}
override fun onUserConnectionRequest(inviterUser: UserInfo) {Log.i(TAG, "收到观众连线请求:${inviterUser.userId}")}
@Overridepublic void onUserConnectionRequest(LiveStreamDefine.LiveUser inviterUser) {Log.i(TAG, "收到观众连线请求:" + inviterUser.userId);}
func onUserConnectionRequest(inviterUser: TUIUserInfo) {print("收到观众连线请求:\\(inviterUser.userId)")}
- (void)onUserConnectionRequest:(TUIUserInfo *)inviterUser {NSLog(@"收到观众连线请求:%@", hostUser.userId);}
RTCRoomEngine
的onRequestReceived
回调中收到观众 B 的连麦请求。// 文件位置:Flutter/lib/manager/observer/live_observer.dartsuper.onRequestReceived = (request) {LiveKitLogger.info("$tag onRequestReceived:[request:$request");liveController.seatController.onRequestReceived(request);};
// 主播同意连麦liveCoreView.respondIntraRoomConnection(audienceBUserId, true, null)
// 主播同意连麦liveCoreView.respondIntraRoomConnection(userId, true, null);// 主播拒绝连麦liveCoreView.respondIntraRoomConnection(userId, false, null);
// 主播同意连麦liveCoreView.respondIntraRoomConnection(userId: audienceBUserId, isAccepted: true) {} onError: { code, message in}
// 主播同意连麦[liveCoreView respondIntraRoomConnection:audienceBUserIdisAccepted:YESonSuccess:^(void) {} onError:^(NSInteger code, NSString * _Nonnull message) {}];
// 文件位置:Flutter/lib/service/impl/room_engine_service.dartmTUIRoomEngine.responseRemoteRequest(requestId, true, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {}@Overridepublic void onError(TUICommonDefine.Error error, String message) {}});
override fun onUserConnectionAccepted(inviterUser: UserInfo) {Log.i(TAG, "观众同意连线:${inviterUser.userId}")}
@Overridepublic void onUserConnectionAccepted(LiveStreamDefine.LiveUser liveUser) {Log.i(TAG, "观众同意连线:" + liveUser.userId);}@Overridepublic void onUserConnectionRejected(LiveStreamDefine.LiveUser liveUser) {Log.i(TAG, "观众拒绝连线:" + liveUser.userId);}
func onUserConnectionAccepted(userId: String) {print("观众同意连线:\\(userId)")}
- (void)onUserConnectionAccepted:(NSString *)userId {NSLog(@"观众同意连线:%@", userId);}
takeSeat
接口中的requestCallback
给出。具体示例可以参考以下代码:// 文件位置:Flutter/lib/manager/controller/seat_controller.dartTUIRequest request = liveService.takeSeat(index,timeout,TUIRequestCallback(onAccepted: (String requestId, String userId) { // 连麦申请被同意},onRejected: (String requestId, String userId, String message) { // 连麦申请被拒绝},onCancelled: (String requestId, String userId) { // 连麦申请取消},onTimeout: (String requestId, String userId) { // 连麦申请超时},onError: (String requestId, String userId, TUIError error, String message) { // 错误回调},));
override fun onConnectedUsersUpdated(inviterUser: UserInfo) {Log.i(TAG, "连麦用户列表发生变化")}
@Overridepublic void onConnectedUsersUpdated(List<UserInfo> userList, List<UserInfo> joinList, List<UserInfo> leaveList) {Log.i(TAG, "连麦用户列表发生变化");}
func onConnectedUsersUpdated(userList: [TUIUserInfo], joinList: [TUIUserInfo], leaveList: [TUIUserInfo]) {print("连麦用户列表发生变化")}
- (void)onConnectedUsersUpdated:(NSArray<TUIUserInfo *> *)userListjoinList:(NSArray<TUIUserInfo *> *)joinListleaveList:(NSArray<TUIUserInfo *> *)leaveList {NSLog(@"连麦用户列表发生变化"); // 如果需要,您可以在这里处理 userList、joinList 和 leaveList}
// 文件位置:Flutter/lib/manager/observer/live_observer.dartsuper.onSeatListChanged = (seatList, seatedList, leftList) {LiveKitLogger.info("$tag($hashCode) onSeatListChanged:[seatList:$seatList ,seatedList:$seatedList,leftList:$leftList]");liveController.target?.seatController.onSeatListChanged(seatList, seatedList, leftList);};
val userId = "audienceBUserId"liveCoreView.disconnectUser(userId, null)
String userId = "audienceUserId";liveCoreView.disconnectUser(userId, null);
let userId = "audienceBUserId"liveCoreView.disconnectUser(userId: userId) {} onError: { code, message in}
NSString *userId = @"audienceBUserId";[liveCoreView disconnectUser:userIdonSuccess:^{} onError:^(NSInteger code, NSString * _Nonnull message) {}];
// 文件位置:Flutter/lib/service/impl/room_engine_service.dartmLiveService.kickUserOffSeatByAdmin(0, userId, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {}@Overridepublic void onError(TUICommonDefine.Error error, String message) {}});
override fun onUserConnectionTerminated(inviterUser: UserInfo) {Log.i(TAG, "主播关闭连线")}
@Overridepublic void onUserConnectionTerminated() {Log.i(TAG, "主播关闭连线");}
func onUserConnectionTerminated() {print("主播关闭连线")}
- (void)onUserConnectionTerminated {NSLog(@"主播关闭连线");}
RTCRoomEngine
的onKickedOffSea
t回调。// 文件位置:Flutter/lib/manager/observer/live_observer.dartsuper.onKickedOffSeat = (seatIndex, userInfo) {LiveKitLogger.info("$tag($hashCode) onKickedOffSeat:[seatIndex:$seatIndex,userInfo:$userInfo");liveController.target?.seatController.onKickedOffSeat(seatIndex, userInfo);};
liveCoreView.terminateIntraRoomConnection()
liveCoreView.terminateIntraRoomConnection();
liveCoreView.terminateIntraRoomConnection()
[liveCoreView terminateIntraRoomConnection]
// 文件位置:Flutter/lib/service/impl/room_engine_service.dartmLiveService.leaveSeat(new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {}@Overridepublic void onError(TUICommonDefine.Error error, String message) {}});
override fun onUserConnectionExited(inviterUser: LiveStreamDefine.LiveUser) {Log.i(TAG, "观众退出连线")}
@Overridepublic void onUserConnectionExited(UserInfo liveUser) {Log.i(TAG, "观众退出连线:${liveUser.userId}");}
func onUserConnectionExited(userInfo: TUIUserInfo) {print("观众退出连线")}
- (void)onUserConnectionExited:(TUIUserInfo *)userInfo {NSLog(@"观众退出连线");}
onSeatListChanged
回调给出的leftList
中,查看断开连麦的观众。// 文件位置:Flutter/lib/manager/observer/live_observer.dartsuper.onSeatListChanged = (seatList, seatedList, leftList) {LiveKitLogger.info("$tag($hashCode) onSeatListChanged:[seatList:$seatList ,seatedList:$seatedList,leftList:$leftList]");liveController.target?.seatController.onSeatListChanged(seatList, seatedList, leftList);};
本页内容是否解决了您的问题?