1.7下午1
This commit is contained in:
parent
44180f9924
commit
f5ecc0eb51
|
|
@ -27,11 +27,243 @@ import 'meeting_main_state.dart';
|
|||
|
||||
class MeetingMainLogic extends GetxController with RequestToolMixin {
|
||||
final MeetingMainState state = MeetingMainState();
|
||||
late RtcEngineEventHandler _rtcEngineEventHandler;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
_rtcEngineEventHandler = RtcEngineEventHandler(
|
||||
// 错误回调
|
||||
onError: (ErrorCodeType err, String msg){
|
||||
debugPrint("wgs输出===:RTC-错误回调:${err}---${msg}");
|
||||
},
|
||||
|
||||
// 成功加入会议室回调
|
||||
onJoinChannelSuccess: (RtcConnection connection, int elapsed) {
|
||||
state.isJoinSuccess.value = true;
|
||||
debugPrint("meeting流程====》3加入频道" );
|
||||
debugPrint("wgs输出===:RTC-自己加入会议室,ID:${connection.localUid}");
|
||||
},
|
||||
onRejoinChannelSuccess: (RtcConnection connection, int elapsed) {
|
||||
state.isJoinSuccess.value = true;
|
||||
debugPrint("meeting流程====》4加入频道" );
|
||||
debugPrint("wgs输出===:RTC-自己加入会议室,ID:${connection.localUid}");
|
||||
},
|
||||
// 成功离开会议室回调
|
||||
onLeaveChannel: (RtcConnection connection, RtcStats stats) {
|
||||
debugPrint("wgs输出===:RTC-自己离开会议室,ID:${connection.localUid}");
|
||||
},
|
||||
|
||||
// 远端用户或主播加入当前会议室回调-主播角色才能接收该回调
|
||||
onUserJoined: (RtcConnection connection, int remoteUid, int elapsed) {
|
||||
debugPrint("wgs输出===:RTC-远端用户或主播加入会议室,用户或主机的ID:$remoteUid");
|
||||
},
|
||||
|
||||
// 远端用户或主播离开当前会议室回调-主播角色才能接收该回调
|
||||
onUserOffline: (RtcConnection connection, int remoteUid,
|
||||
UserOfflineReasonType reason) async {
|
||||
// 判断是否用户取消了共享
|
||||
if (remoteUid.toString().length == 9) {
|
||||
for (var i = 0; i < state.cacheUsers.value.length; i++) {
|
||||
if (remoteUid.toString() ==
|
||||
state.cacheUsers.value[i].screenShareId) {
|
||||
state.cacheUsers.value[i].enableShare = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
update();
|
||||
debugPrint("wgs输出===:RTC-远端用户或主播离开会议室,用户或主机的ID:$remoteUid");
|
||||
},
|
||||
|
||||
// 音频路由发生变化回调
|
||||
onAudioRoutingChanged: (int routing) {
|
||||
debugPrint("wgs输出===:RTC-音频路由切换:$routing");
|
||||
state.communicationMode.value = routing;
|
||||
if (routing == 1) {
|
||||
debugPrint("wgs输出===:RTC-音频路由切换为听筒");
|
||||
} else if (routing == 3) {
|
||||
debugPrint("wgs输出===:RTC-音频路由切换为扬声器");
|
||||
} else {
|
||||
debugPrint("wgs输出===:RTC-音频路由切换为外接设备");
|
||||
}
|
||||
},
|
||||
|
||||
// 音频采集开关回调
|
||||
onLocalAudioStateChanged: (RtcConnection connection,
|
||||
LocalAudioStreamState state, LocalAudioStreamReason reason) {
|
||||
debugPrint("wgs输出===:RTC-音频采集开关:$state");
|
||||
},
|
||||
|
||||
// 远端视频状态发生改变回调
|
||||
onRemoteVideoStateChanged: (RtcConnection connection,
|
||||
int remoteUid,
|
||||
RemoteVideoState remoteVideoState,
|
||||
RemoteVideoStateReason remoteVideoStateReason,
|
||||
int elapsed) {
|
||||
debugPrint(
|
||||
"wgs输出===:RTC-远端视频状态发生改变:ID-$remoteUid-状态-$remoteVideoStateReason");
|
||||
if (remoteVideoStateReason ==
|
||||
RemoteVideoStateReason.remoteVideoStateReasonRemoteMuted) {
|
||||
// 远端用户停止发送视频流或远端用户禁用视频模块
|
||||
if (remoteUid.toString().length != 9) {
|
||||
// 摄像头
|
||||
if (remoteUid.toString() == state.remoteUid.value) {
|
||||
// 如果停止发送视频流或禁用视频模块的远端用户是当前全员观看主播
|
||||
doHttpGetTvAnchor();
|
||||
}
|
||||
} else {
|
||||
// 共享屏幕(此版本不做)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 用户音量提示回调
|
||||
onAudioVolumeIndication: (RtcConnection connection,
|
||||
List<AudioVolumeInfo> speakers,
|
||||
int speakerNumber,
|
||||
int totalVolume) {
|
||||
if (speakers.isNotEmpty) {
|
||||
for (AudioVolumeInfo avi in speakers) {
|
||||
if (avi.uid == 0) {
|
||||
// debugPrint("wgs输出===:RTC-本地用户音量提示:${avi.uid}--${avi.volume}");
|
||||
for (MeetingRoomUser mru in state.cacheUsers.value) {
|
||||
if (UserStore.to.userInfoEntity.value!.uid == mru.uid) {
|
||||
mru.volume = CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
state.microphoneVolume.value =
|
||||
CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// debugPrint("wgs输出===:RTC-远端用户音量提示:${avi.uid}--${avi.volume}");
|
||||
for (MeetingRoomUser mru in state.cacheUsers.value) {
|
||||
mru.volume = CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
|
||||
if (avi.volume != 0) {
|
||||
state.spokesman.value = mru.userName;
|
||||
state.spokesmanVolume.value =
|
||||
CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
} else {
|
||||
state.spokesman.value = "";
|
||||
state.spokesmanVolume.value = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*for (MeetingRoomUser mru in state.cacheUsers.value) {
|
||||
// 用于更改语音布局里的用户列表麦克风
|
||||
if (avi.uid == 0) {
|
||||
// debugPrint("wgs输出===:RTC-用户音量提示(自己):${CountMicrophoneVolume.getVolume(avi.volume!)}");
|
||||
mru.volume = CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
state.microphoneVolume.value =
|
||||
CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
} else {
|
||||
debugPrint("wgs输出===:RTC-用户音量提示:${avi.uid}--${mru.uid}");
|
||||
if (avi.uid.toString() == mru.uid) {
|
||||
debugPrint("wgs输出===:RTC-用户音量提示(远端用户):${speakers[0].uid}--${speakers[0].volume}");
|
||||
mru.volume = CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
|
||||
if (avi.volume != 0) {
|
||||
state.spokesman.value = mru.userName;
|
||||
state.spokesmanVolume.value =
|
||||
CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
} else {
|
||||
state.spokesman.value = "";
|
||||
state.spokesmanVolume.value = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 切换用户角色回调
|
||||
onClientRoleChanged: (RtcConnection connection,
|
||||
ClientRoleType oldRole,
|
||||
ClientRoleType newRole,
|
||||
ClientRoleOptions newRoleOptions) {
|
||||
debugPrint(
|
||||
"wgs输出===:RTC-切换用户角色为:${newRole == ClientRoleType.clientRoleBroadcaster ? "主播" : "观众"}");
|
||||
},
|
||||
|
||||
// token即将在30秒内过期回调
|
||||
onTokenPrivilegeWillExpire: (RtcConnection connection, String token) {
|
||||
doHttpGetMeetingToken(false);
|
||||
},
|
||||
|
||||
// 本地视频状态发生改变回调
|
||||
onLocalVideoStateChanged: (VideoSourceType source,
|
||||
LocalVideoStreamState state, LocalVideoStreamReason reason) {
|
||||
debugPrint("wgs输出===:RTC-本地视频状态发生改变:$source--$state--$reason");
|
||||
},
|
||||
|
||||
// 网络连接状态回调
|
||||
onConnectionStateChanged: (RtcConnection connection,
|
||||
ConnectionStateType stateType,
|
||||
ConnectionChangedReasonType reason) {
|
||||
debugPrint("wgs输出===:RTC-网络连接状态发生改变:"
|
||||
"会议室编号(${connection.channelId}),"
|
||||
"网络状态($stateType-${AgoraUtil.getConnectionStateChangedType(stateType)}),"
|
||||
"网络改变原因($reason-${AgoraUtil.getConnectionChangedReasonType(reason)})");
|
||||
if (stateType == ConnectionStateType.connectionStateReconnecting) {
|
||||
if (EasyLoading.isShow == false) {
|
||||
ToastUtils.showLoadingToMask(
|
||||
"网络故障,正在重连...", EasyLoadingMaskType.black);
|
||||
}
|
||||
} else if (stateType ==
|
||||
ConnectionStateType.connectionStateConnected &&
|
||||
reason ==
|
||||
ConnectionChangedReasonType
|
||||
.connectionChangedRejoinSuccess) {
|
||||
ToastUtils.dismiss();
|
||||
if (EasyLoading.isShow == false) {
|
||||
ToastUtils.showSuccessToMask(
|
||||
"重连成功!", EasyLoadingMaskType.black);
|
||||
}
|
||||
} else if (reason ==
|
||||
ConnectionChangedReasonType.connectionChangedLost) {
|
||||
// 和服务器失去连接后,再延迟15秒(和signalR Socket一致),让SDK继续重连,如果重连不上则告知用户需要重新加入
|
||||
Future.delayed(const Duration(milliseconds: 15000), () {
|
||||
ToastUtils.dismiss();
|
||||
if (state.isShowOkAlertDialog.value == false) {
|
||||
showOkAlertDialog(
|
||||
context: Get.context!,
|
||||
title: "提示",
|
||||
message: "网络错误,请重新加入会议室",
|
||||
okLabel: "确定",
|
||||
barrierDismissible: false,
|
||||
).then((OkCancelResult value) {
|
||||
Get.back();
|
||||
Get.back();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 渲染器已接收首帧远端视频回调
|
||||
onFirstRemoteVideoFrame: (RtcConnection connection, int remoteUid,
|
||||
int width, int height, int elapsed) async {
|
||||
debugPrint("wgs输出===:RTC-渲染器已接收首帧远端视频回调:${remoteUid}--${width}--${height}--${elapsed}");
|
||||
|
||||
|
||||
},
|
||||
|
||||
// 已接收到远端视频并完成解码回调
|
||||
onFirstRemoteVideoDecoded: (RtcConnection connection, int remoteUid,
|
||||
int width, int height, int elapsed) {
|
||||
debugPrint("wgs输出===:RTC-已接收到远端视频并完成解码回调:${remoteUid}--${width}--${height}--${elapsed}");
|
||||
}
|
||||
|
||||
// 获取设备权限出错回调
|
||||
/*onPermissionError: (PermissionType permissionType){
|
||||
debugPrint("wgs输出===:RTC-获取设备权限出错:$permissionType");
|
||||
if(permissionType == PermissionType.screenCapture){
|
||||
// 获取共享屏幕出错(此版本不做)
|
||||
state.isOpenShare.value = false;
|
||||
stopScreenCapture();
|
||||
}
|
||||
}*/
|
||||
);
|
||||
// 接收参数
|
||||
var data = Get.arguments;
|
||||
state.roomNumber.value = data["roomNumber"];
|
||||
|
|
@ -64,6 +296,8 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
|
|||
await getClient().getMeetingToken(state.roomNumber.value);
|
||||
state.meetingToken.value = res.data!;
|
||||
|
||||
debugPrint("meeting流程====》1获取token成功" );
|
||||
|
||||
if (isInit) {
|
||||
signalRSocket();
|
||||
} else {
|
||||
|
|
@ -379,6 +613,8 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
|
|||
|
||||
await state.hubConnection.value?.start();
|
||||
|
||||
debugPrint("meeting流程====》2socket链接成功" );
|
||||
|
||||
// 开始重新连接时回调
|
||||
state.hubConnection.value?.onreconnecting((error) {
|
||||
debugPrint("wgs输出===:SignalR Socket-重连$error");
|
||||
|
|
@ -774,7 +1010,9 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
|
|||
/// 初始化声网SDK
|
||||
Future<void> initRtc() async {
|
||||
// 创建 RtcEngine 对象
|
||||
state.rctEngine.value = createAgoraRtcEngineEx();
|
||||
await leaveMeetingToRtc();
|
||||
|
||||
state.rctEngine.value = createAgoraRtcEngine();
|
||||
|
||||
// 初始化 RtcEngine,设置频道场景为 channelProfileLiveBroadcasting(直播场景)
|
||||
await state.rctEngine.value?.initialize(RtcEngineContext(
|
||||
|
|
@ -782,8 +1020,10 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
|
|||
channelProfile: ChannelProfileType.channelProfileLiveBroadcasting,
|
||||
// logConfig:const LogConfig()
|
||||
));
|
||||
state.rctEngine.value?.registerEventHandler(_rtcEngineEventHandler);
|
||||
|
||||
// 音频模块默认启动,所以这里不再调用启动方法
|
||||
|
||||
// 启用视频模块
|
||||
await enableVideo();
|
||||
// 设置默认音频路由为听筒
|
||||
|
|
@ -795,232 +1035,12 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
|
|||
await state.rctEngine.value
|
||||
?.setDualStreamMode(mode: SimulcastStreamMode.enableSimulcastStream);
|
||||
|
||||
// 回调
|
||||
state.rctEngine.value?.registerEventHandler(
|
||||
RtcEngineEventHandler(
|
||||
// 成功加入会议室回调
|
||||
onJoinChannelSuccess: (RtcConnection connection, int elapsed) {
|
||||
state.isJoinSuccess.value = true;
|
||||
debugPrint("wgs输出===:RTC-自己加入会议室,ID:${connection.localUid}");
|
||||
},
|
||||
|
||||
// 成功离开会议室回调
|
||||
onLeaveChannel: (RtcConnection connection, RtcStats stats) {
|
||||
debugPrint("wgs输出===:RTC-自己离开会议室,ID:${connection.localUid}");
|
||||
},
|
||||
|
||||
// 远端用户或主播加入当前会议室回调-主播角色才能接收该回调
|
||||
onUserJoined: (RtcConnection connection, int remoteUid, int elapsed) {
|
||||
debugPrint("wgs输出===:RTC-远端用户或主播加入会议室,用户或主机的ID:$remoteUid");
|
||||
},
|
||||
|
||||
// 远端用户或主播离开当前会议室回调-主播角色才能接收该回调
|
||||
onUserOffline: (RtcConnection connection, int remoteUid,
|
||||
UserOfflineReasonType reason) async {
|
||||
// 判断是否用户取消了共享
|
||||
if (remoteUid.toString().length == 9) {
|
||||
for (var i = 0; i < state.cacheUsers.value.length; i++) {
|
||||
if (remoteUid.toString() ==
|
||||
state.cacheUsers.value[i].screenShareId) {
|
||||
state.cacheUsers.value[i].enableShare = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
update();
|
||||
debugPrint("wgs输出===:RTC-远端用户或主播离开会议室,用户或主机的ID:$remoteUid");
|
||||
},
|
||||
|
||||
// 音频路由发生变化回调
|
||||
onAudioRoutingChanged: (int routing) {
|
||||
debugPrint("wgs输出===:RTC-音频路由切换:$routing");
|
||||
state.communicationMode.value = routing;
|
||||
if (routing == 1) {
|
||||
debugPrint("wgs输出===:RTC-音频路由切换为听筒");
|
||||
} else if (routing == 3) {
|
||||
debugPrint("wgs输出===:RTC-音频路由切换为扬声器");
|
||||
} else {
|
||||
debugPrint("wgs输出===:RTC-音频路由切换为外接设备");
|
||||
}
|
||||
},
|
||||
|
||||
// 音频采集开关回调
|
||||
onLocalAudioStateChanged: (RtcConnection connection,
|
||||
LocalAudioStreamState state, LocalAudioStreamReason reason) {
|
||||
debugPrint("wgs输出===:RTC-音频采集开关:$state");
|
||||
},
|
||||
|
||||
// 远端视频状态发生改变回调
|
||||
onRemoteVideoStateChanged: (RtcConnection connection,
|
||||
int remoteUid,
|
||||
RemoteVideoState remoteVideoState,
|
||||
RemoteVideoStateReason remoteVideoStateReason,
|
||||
int elapsed) {
|
||||
debugPrint(
|
||||
"wgs输出===:RTC-远端视频状态发生改变:ID-$remoteUid-状态-$remoteVideoStateReason");
|
||||
if (remoteVideoStateReason ==
|
||||
RemoteVideoStateReason.remoteVideoStateReasonRemoteMuted) {
|
||||
// 远端用户停止发送视频流或远端用户禁用视频模块
|
||||
if (remoteUid.toString().length != 9) {
|
||||
// 摄像头
|
||||
if (remoteUid.toString() == state.remoteUid.value) {
|
||||
// 如果停止发送视频流或禁用视频模块的远端用户是当前全员观看主播
|
||||
doHttpGetTvAnchor();
|
||||
}
|
||||
} else {
|
||||
// 共享屏幕(此版本不做)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 用户音量提示回调
|
||||
onAudioVolumeIndication: (RtcConnection connection,
|
||||
List<AudioVolumeInfo> speakers,
|
||||
int speakerNumber,
|
||||
int totalVolume) {
|
||||
if (speakers.isNotEmpty) {
|
||||
for (AudioVolumeInfo avi in speakers) {
|
||||
if (avi.uid == 0) {
|
||||
// debugPrint("wgs输出===:RTC-本地用户音量提示:${avi.uid}--${avi.volume}");
|
||||
for (MeetingRoomUser mru in state.cacheUsers.value) {
|
||||
if (UserStore.to.userInfoEntity.value!.uid == mru.uid) {
|
||||
mru.volume = CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
state.microphoneVolume.value =
|
||||
CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// debugPrint("wgs输出===:RTC-远端用户音量提示:${avi.uid}--${avi.volume}");
|
||||
for (MeetingRoomUser mru in state.cacheUsers.value) {
|
||||
mru.volume = CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
|
||||
if (avi.volume != 0) {
|
||||
state.spokesman.value = mru.userName;
|
||||
state.spokesmanVolume.value =
|
||||
CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
} else {
|
||||
state.spokesman.value = "";
|
||||
state.spokesmanVolume.value = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*for (MeetingRoomUser mru in state.cacheUsers.value) {
|
||||
// 用于更改语音布局里的用户列表麦克风
|
||||
if (avi.uid == 0) {
|
||||
// debugPrint("wgs输出===:RTC-用户音量提示(自己):${CountMicrophoneVolume.getVolume(avi.volume!)}");
|
||||
mru.volume = CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
state.microphoneVolume.value =
|
||||
CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
} else {
|
||||
debugPrint("wgs输出===:RTC-用户音量提示:${avi.uid}--${mru.uid}");
|
||||
if (avi.uid.toString() == mru.uid) {
|
||||
debugPrint("wgs输出===:RTC-用户音量提示(远端用户):${speakers[0].uid}--${speakers[0].volume}");
|
||||
mru.volume = CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
|
||||
if (avi.volume != 0) {
|
||||
state.spokesman.value = mru.userName;
|
||||
state.spokesmanVolume.value =
|
||||
CountMicrophoneVolume.getVolume(avi.volume!);
|
||||
} else {
|
||||
state.spokesman.value = "";
|
||||
state.spokesmanVolume.value = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 切换用户角色回调
|
||||
onClientRoleChanged: (RtcConnection connection,
|
||||
ClientRoleType oldRole,
|
||||
ClientRoleType newRole,
|
||||
ClientRoleOptions newRoleOptions) {
|
||||
debugPrint(
|
||||
"wgs输出===:RTC-切换用户角色为:${newRole == ClientRoleType.clientRoleBroadcaster ? "主播" : "观众"}");
|
||||
},
|
||||
|
||||
// token即将在30秒内过期回调
|
||||
onTokenPrivilegeWillExpire: (RtcConnection connection, String token) {
|
||||
doHttpGetMeetingToken(false);
|
||||
},
|
||||
|
||||
// 本地视频状态发生改变回调
|
||||
onLocalVideoStateChanged: (VideoSourceType source,
|
||||
LocalVideoStreamState state, LocalVideoStreamReason reason) {
|
||||
debugPrint("wgs输出===:RTC-本地视频状态发生改变:$source--$state--$reason");
|
||||
},
|
||||
|
||||
// 网络连接状态回调
|
||||
onConnectionStateChanged: (RtcConnection connection,
|
||||
ConnectionStateType stateType,
|
||||
ConnectionChangedReasonType reason) {
|
||||
debugPrint("wgs输出===:RTC-网络连接状态发生改变:"
|
||||
"会议室编号(${connection.channelId}),"
|
||||
"网络状态($stateType-${AgoraUtil.getConnectionStateChangedType(stateType)}),"
|
||||
"网络改变原因($reason-${AgoraUtil.getConnectionChangedReasonType(reason)})");
|
||||
if (stateType == ConnectionStateType.connectionStateReconnecting) {
|
||||
if (EasyLoading.isShow == false) {
|
||||
ToastUtils.showLoadingToMask(
|
||||
"网络故障,正在重连...", EasyLoadingMaskType.black);
|
||||
}
|
||||
} else if (stateType ==
|
||||
ConnectionStateType.connectionStateConnected &&
|
||||
reason ==
|
||||
ConnectionChangedReasonType
|
||||
.connectionChangedRejoinSuccess) {
|
||||
ToastUtils.dismiss();
|
||||
if (EasyLoading.isShow == false) {
|
||||
ToastUtils.showSuccessToMask(
|
||||
"重连成功!", EasyLoadingMaskType.black);
|
||||
}
|
||||
} else if (reason ==
|
||||
ConnectionChangedReasonType.connectionChangedLost) {
|
||||
// 和服务器失去连接后,再延迟15秒(和signalR Socket一致),让SDK继续重连,如果重连不上则告知用户需要重新加入
|
||||
Future.delayed(const Duration(milliseconds: 15000), () {
|
||||
ToastUtils.dismiss();
|
||||
if (state.isShowOkAlertDialog.value == false) {
|
||||
showOkAlertDialog(
|
||||
context: Get.context!,
|
||||
title: "提示",
|
||||
message: "网络错误,请重新加入会议室",
|
||||
okLabel: "确定",
|
||||
barrierDismissible: false,
|
||||
).then((OkCancelResult value) {
|
||||
Get.back();
|
||||
Get.back();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 渲染器已接收首帧远端视频回调
|
||||
onFirstRemoteVideoFrame: (RtcConnection connection, int remoteUid,
|
||||
int width, int height, int elapsed) async {
|
||||
debugPrint("wgs输出===:RTC-渲染器已接收首帧远端视频回调:${remoteUid}--${width}--${height}--${elapsed}");
|
||||
WidgetsBinding.instance.addPostFrameCallback((_)=>joinMeetingToRtc());
|
||||
|
||||
|
||||
},
|
||||
// await joinMeetingToRtc();
|
||||
|
||||
// 已接收到远端视频并完成解码回调
|
||||
onFirstRemoteVideoDecoded: (RtcConnection connection, int remoteUid,
|
||||
int width, int height, int elapsed) {
|
||||
debugPrint("wgs输出===:RTC-已接收到远端视频并完成解码回调:${remoteUid}--${width}--${height}--${elapsed}");
|
||||
}
|
||||
|
||||
// 获取设备权限出错回调
|
||||
/*onPermissionError: (PermissionType permissionType){
|
||||
debugPrint("wgs输出===:RTC-获取设备权限出错:$permissionType");
|
||||
if(permissionType == PermissionType.screenCapture){
|
||||
// 获取共享屏幕出错(此版本不做)
|
||||
state.isOpenShare.value = false;
|
||||
stopScreenCapture();
|
||||
}
|
||||
}*/
|
||||
),
|
||||
);
|
||||
await joinMeetingToRtc();
|
||||
}
|
||||
|
||||
/// 加入会议室
|
||||
|
|
@ -1048,6 +1068,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
|
|||
|
||||
/// 离开会议室
|
||||
Future<void> leaveMeetingToRtc() async {
|
||||
state.rctEngine.value?.unregisterEventHandler(_rtcEngineEventHandler);
|
||||
// 离开
|
||||
await state.rctEngine.value?.leaveChannel();
|
||||
// 释放资源
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class MeetingMainState {
|
|||
|
||||
/// 声网相关
|
||||
final String appId = "4a4f7be64fa1404ebda74784fe9ac381";
|
||||
Rx<RtcEngineEx?> rctEngine = Rx<RtcEngineEx?>(null);
|
||||
Rx<RtcEngine?> rctEngine = Rx<RtcEngine?>(null);
|
||||
/// 是否自动订阅所有视频流
|
||||
late RxBool isAutoSubscribeVideo = false.obs;
|
||||
/// 是否自动订阅所有音频流
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue