parent
cc268cc00d
commit
5d194ad054
|
|
@ -133,12 +133,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
}
|
||||
}
|
||||
|
||||
/// 用户开闭摄像头
|
||||
Future<void> doHttpSetCamer() async {
|
||||
await getClient().setCamera(state.roomNumber.value, state.isOpenCamera.value, UserStore.to.userInfoEntity.value!.uid);
|
||||
}
|
||||
|
||||
/// --------------------------发言权限
|
||||
/// ------------------------------------------------------------------------------发言权限
|
||||
/// 申请发言权限
|
||||
Future<void> doHttpApplySpeak() async {
|
||||
await getClient().applySpeak(state.roomNumber.value);
|
||||
|
|
@ -147,14 +142,19 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
/// 关闭发言权限
|
||||
Future<void> doHttpCancelSpeak() async {
|
||||
await getClient().cancelSpeak(state.meetingRoomInfo.value!.id, state.meetingRoomInfo.value!.roomNum, UserStore.to.userInfoEntity.value!.uid);
|
||||
setClientRole("观众");
|
||||
/*setClientRole("观众");
|
||||
setMicrophoneOpen(false);
|
||||
setCameraOpen(false);
|
||||
setScreenShareOpen(false);
|
||||
changePageState(0);
|
||||
changePageState(0);*/
|
||||
}
|
||||
|
||||
/// ------------------------------------------------------------------------------麦克风相关(操作)
|
||||
/// 用户开闭麦
|
||||
Future<void> doHttpSetMicr() async {
|
||||
await getClient().setMicr(state.roomNumber.value, state.isOpenMicrophone.value, UserStore.to.userInfoEntity.value!.uid);
|
||||
}
|
||||
|
||||
/// --------------------------麦克风相关(操作)
|
||||
/// 设置麦克风是否开启
|
||||
Future<void> setMicrophoneOpen(bool isOpen) async{
|
||||
state.isOpenMicrophone.value = isOpen;
|
||||
|
|
@ -167,39 +167,27 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
doHttpSetMicr();
|
||||
}
|
||||
|
||||
/// 用户开闭麦
|
||||
Future<void> doHttpSetMicr() async {
|
||||
await getClient().setMicr(state.roomNumber.value, state.isOpenMicrophone.value, UserStore.to.userInfoEntity.value!.uid);
|
||||
/// ------------------------------------------------------------------------------视频-屏幕相关(操作)
|
||||
/// 用户开闭摄像头
|
||||
Future<void> doHttpSetCamer() async {
|
||||
await getClient().setCamera(state.roomNumber.value, state.isOpenCamera.value, UserStore.to.userInfoEntity.value!.uid);
|
||||
}
|
||||
|
||||
/// 设置视频是否打开
|
||||
/// 设置视频是否开启
|
||||
void setCameraOpen(bool isOpen){
|
||||
if(isOpen == true){
|
||||
state.isOpenCamera.value = true;
|
||||
setEnableVideo();
|
||||
setStartPreview();
|
||||
setClientRole("主播");
|
||||
changePageState(1);
|
||||
}else{
|
||||
state.isOpenCamera.value = false;
|
||||
setDisablePreview();
|
||||
}
|
||||
if(state.isOpenMicrophone.value == false){
|
||||
setMicrophoneOpen(isOpen);
|
||||
}
|
||||
state.isOpenCamera.value = isOpen;
|
||||
doHttpSetCamer();
|
||||
}
|
||||
|
||||
/// 挂断视频
|
||||
void hangUpVideo(){
|
||||
setDisableVideo();
|
||||
setDisablePreview();
|
||||
stopPreview();
|
||||
state.isOpenCamera.value = false;
|
||||
changePageState(0);
|
||||
doHttpSetCamer();
|
||||
}
|
||||
|
||||
/// 获取当前全员观看视频主播
|
||||
/// 获取当前全员观看主播
|
||||
Future<void> doHttpGetTvAnchor() async {
|
||||
BaseStructureResult res = await getClient().getTvAnchor(state.roomNumber.value);
|
||||
state.remoteUid.value = res.data!.toString();
|
||||
|
|
@ -247,7 +235,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
}
|
||||
}
|
||||
|
||||
/// --------------------------signalR Socket相关
|
||||
/// ------------------------------------------------------------------------------signalR Socket相关
|
||||
/// Socket长连接
|
||||
Future<void> signalRSocket() async {
|
||||
state.hubConnection.value = HubConnectionBuilder()
|
||||
|
|
@ -263,7 +251,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
|
||||
joinMeetingToSocket();
|
||||
|
||||
/// --------------------------发言权限相关回调
|
||||
/// ------------------------------------------------------------------------------发言权限相关回调
|
||||
/// 开启关闭发言权限
|
||||
state.hubConnection.value?.on("ManagerRefresh", (e){
|
||||
// var jsonStr = const Utf8Decoder().convert(json.encode(e?[0]).runes.toList());
|
||||
|
|
@ -297,15 +285,17 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
if(UserStore.to.userInfoEntity.value!.uid == meetingRoomUser.uid){
|
||||
state.isSpeak.value = false;
|
||||
state.isOpenMicrophone.value = false;
|
||||
state.isOpenCamera.value = false;
|
||||
setClientRole("观众");
|
||||
debugPrint("wgs输出===:Socket-关闭发言权限:观众");
|
||||
}
|
||||
}
|
||||
doHttpSetMicr();
|
||||
doHttpSetCamer();
|
||||
update();
|
||||
});
|
||||
|
||||
/// --------------------------麦克风相关回调
|
||||
/// ------------------------------------------------------------------------------麦克风相关回调
|
||||
/// 所有用户开闭麦回调
|
||||
state.hubConnection.value?.on("OperAllMicr", (e){
|
||||
if(e?[0] == true){
|
||||
|
|
@ -338,7 +328,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
state.isOpenMicrophone.value = true;
|
||||
|
||||
// 恢复发布音频流
|
||||
state.rctEngine.value?.muteLocalAudioStream(false);
|
||||
muteLocalAudioStream(false);
|
||||
}
|
||||
}else{
|
||||
debugPrint("wgs输出===:Socket-用户单独闭麦");
|
||||
|
|
@ -351,12 +341,12 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
state.isOpenMicrophone.value = false;
|
||||
|
||||
// 取消发布音频流
|
||||
state.rctEngine.value?.muteLocalAudioStream(true);
|
||||
muteLocalAudioStream(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/// --------------------------会议室进出相关回调
|
||||
/// ------------------------------------------------------------------------------会议室进出相关回调
|
||||
/// 远端用户或主播加入会议室回调
|
||||
state.hubConnection.value?.on("UserJoined", (e){
|
||||
// var jsonStr = const Utf8Decoder().convert(json.encode(user).runes.toList());
|
||||
|
|
@ -400,7 +390,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
ToastUtils.showSuccess("会议已结束");
|
||||
});
|
||||
|
||||
/// --------------------------会议室聊天相关回调
|
||||
/// ------------------------------------------------------------------------------会议室聊天相关回调
|
||||
/// 会议室接收消息回调
|
||||
state.hubConnection.value?.on("ReceiveMessage", (e){
|
||||
// var jsonStr = const Utf8Decoder().convert(json.encode(e).runes.toList());
|
||||
|
|
@ -415,7 +405,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
debugPrint("wgs输出===:Socket-会议室接收消息:$jsonStr");
|
||||
});
|
||||
|
||||
/// --------------------------摄像头或者屏幕相关回调
|
||||
/// ------------------------------------------------------------------------------摄像头或者屏幕相关回调
|
||||
/// 单独用户开闭摄像头回调
|
||||
state.hubConnection.value?.on("OperCamera", (e){
|
||||
// var jsonStr = const Utf8Decoder().convert(json.encode(e?[0]).runes.toList());
|
||||
|
|
@ -423,7 +413,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
var listDynamic = jsonDecode(jsonStr);
|
||||
MeetingRoomUser meetingRoomUser = MeetingRoomUser.fromJson(listDynamic);
|
||||
if(meetingRoomUser.enableCamera == true){
|
||||
debugPrint("wgs输出===:Socket-单独用户开摄像头");
|
||||
debugPrint("wgs输出===:Socket-用户单独开摄像头");
|
||||
for(MeetingRoomUser mru in state.cacheUsers.value){
|
||||
if(mru.uid == meetingRoomUser.uid){
|
||||
mru.enableCamera = true;
|
||||
|
|
@ -431,9 +421,15 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
}
|
||||
if(meetingRoomUser.uid == UserStore.to.userInfoEntity.value!.uid){
|
||||
state.isOpenCamera.value = true;
|
||||
// 恢复发布视频流
|
||||
muteLocalVideoStream(false);
|
||||
// 开始本地预览
|
||||
startPreview();
|
||||
|
||||
changePageState(1);
|
||||
}
|
||||
}else{
|
||||
debugPrint("wgs输出===:Socket-单独用户闭摄像头");
|
||||
debugPrint("wgs输出===:Socket-用户单独闭摄像头");
|
||||
for(MeetingRoomUser mru in state.cacheUsers.value){
|
||||
if(mru.uid == meetingRoomUser.uid){
|
||||
mru.enableCamera = false;
|
||||
|
|
@ -441,6 +437,11 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
}
|
||||
if(meetingRoomUser.uid == UserStore.to.userInfoEntity.value!.uid){
|
||||
state.isOpenCamera.value = false;
|
||||
|
||||
// 取消发布视频流
|
||||
muteLocalVideoStream(true);
|
||||
// 停止本地预览
|
||||
stopPreview();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -483,7 +484,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
await state.hubConnection.value?.invoke("sendChannelMsg", args: [state.roomNumber.value, msg]);
|
||||
}
|
||||
|
||||
/// --------------------------声网SDK相关
|
||||
/// ------------------------------------------------------------------------------声网SDK相关
|
||||
/// 初始化声网SDK
|
||||
Future<void> initRtc() async {
|
||||
// 请求麦克风、摄像头权限
|
||||
|
|
@ -499,8 +500,9 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
channelProfile: ChannelProfileType.channelProfileLiveBroadcasting,
|
||||
));
|
||||
|
||||
// 启用音频模块
|
||||
// await state.rctEngine.value?.enableAudio();
|
||||
// 音频模块默认启动,所以这里不再调用启动方法
|
||||
// 启用视频模块
|
||||
enableVideo();
|
||||
// 设置默认音频路由为听筒
|
||||
await state.rctEngine.value?.setDefaultAudioRouteToSpeakerphone(false);
|
||||
// 打开用户音量回调
|
||||
|
|
@ -646,28 +648,28 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
|
|||
await state.rctEngine.value?.setEnableSpeakerphone(mode == 1 ? false : true);
|
||||
}
|
||||
|
||||
/// 关闭音频模块
|
||||
Future<void> disableAudio() async {
|
||||
await state.rctEngine.value?.disableAudio();
|
||||
}
|
||||
|
||||
/// 设置启用视频模块
|
||||
Future<void> setEnableVideo() async {
|
||||
Future<void> enableVideo() async {
|
||||
await state.rctEngine.value?.enableVideo();
|
||||
}
|
||||
|
||||
/// 设置关闭视频模块
|
||||
Future<void> setDisableVideo() async {
|
||||
await state.rctEngine.value?.disableVideo();
|
||||
/// 取消或恢复发布本地音频流
|
||||
Future<void> muteLocalAudioStream(bool mute) async {
|
||||
await state.rctEngine.value?.muteLocalAudioStream(mute);
|
||||
}
|
||||
|
||||
/// 设置启用本地预览
|
||||
Future<void> setStartPreview() async {
|
||||
/// 取消或恢复发布本地视频流
|
||||
Future<void> muteLocalVideoStream(bool mute) async {
|
||||
await state.rctEngine.value?.muteLocalVideoStream(mute);
|
||||
}
|
||||
|
||||
/// 开始本地预览
|
||||
Future<void> startPreview() async {
|
||||
await state.rctEngine.value?.startPreview();
|
||||
}
|
||||
|
||||
/// 设置关闭本地预览
|
||||
Future<void> setDisablePreview() async {
|
||||
/// 停止本地预览
|
||||
Future<void> stopPreview() async {
|
||||
await state.rctEngine.value?.stopPreview();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue