Compare commits

...

2 Commits

Author SHA1 Message Date
fuenmao 8d4979b484 视频逻辑重新梳理 2024-12-10 08:29:03 +08:00
fuenmao 3b1fbc837c 麦克风逻辑重新梳理 2024-12-09 16:48:06 +08:00
2 changed files with 34 additions and 47 deletions

View File

@ -95,7 +95,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
void getMeetingRoomAllUser(List<MeetingRoomUser> meetingRoomUsers) async {
state.users.value = meetingRoomUsers;
state.cacheUsers.value = meetingRoomUsers;
doHttpGetTvAnchor();
// doHttpGetTvAnchor();
}
///
@ -144,49 +144,23 @@ 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("观众");
setMicrophoneOpen(false);
setCameraOpen(false);
setScreenShareOpen(false);
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;
for(var i = 0; i < state.cacheUsers.value.length; i++){
if(state.cacheUsers.value[i].uid == UserStore.to.userInfoEntity.value!.uid){
state.cacheUsers.value[i].enableMicr = isOpen;
}
}
state.users.value = state.cacheUsers.value;
doHttpSetMicr();
Future<void> doHttpSetMicr(bool isOpenMicrophone) async {
await getClient().setMicr(state.roomNumber.value, isOpenMicrophone, UserStore.to.userInfoEntity.value!.uid);
}
/// -------------------------------------------------------------------------------
///
Future<void> doHttpSetCamer() async {
await getClient().setCamera(state.roomNumber.value, state.isOpenCamera.value, UserStore.to.userInfoEntity.value!.uid);
Future<void> doHttpSetCamer(bool isOpenCamera) async {
await getClient().setCamera(state.roomNumber.value, isOpenCamera, UserStore.to.userInfoEntity.value!.uid);
}
///
void setCameraOpen(bool isOpen){
state.isOpenCamera.value = isOpen;
doHttpSetCamer();
}
///
void hangUpVideo(){
stopPreview();
state.isOpenCamera.value = false;
changePageState(0);
doHttpSetCamer();
}
///
@ -280,6 +254,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
if(UserStore.to.userInfoEntity.value!.uid == meetingRoomUser.uid){
state.isSpeak.value = true;
state.isOpenMicrophone.value = true;
// SDK角色为主播
setClientRole("主播");
debugPrint("wgs输出===Socket-开启发言权限:主播");
}
@ -296,14 +271,22 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
state.isSpeak.value = false;
state.isOpenMicrophone.value = false;
state.isOpenCamera.value = false;
// SDK角色为观众
setClientRole("观众");
//
muteLocalVideoStream(true);
//
stopPreview();
//
state.floating.value?.close();
changePageState(0);
state.isSelf.value = false;
state.remoteUid.value = "";
debugPrint("wgs输出===Socket-关闭发言权限:观众");
}
}
doHttpSetMicr();
doHttpSetCamer();
update();
});
/// ------------------------------------------------------------------------------
@ -319,7 +302,6 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
}
state.users.value = state.cacheUsers.value;
state.isOpenMicrophone.value = e?[0];
doHttpSetMicr();
});
///
@ -329,7 +311,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
var listDynamic = jsonDecode(jsonStr);
MeetingRoomUser meetingRoomUser = MeetingRoomUser.fromJson(listDynamic);
if(meetingRoomUser.enableMicr == true){
debugPrint("wgs输出===Socket-用户单独开麦");
debugPrint("wgs输出===Socket-用户单独开麦${meetingRoomUser.uid}-${meetingRoomUser.userName}");
for(MeetingRoomUser mru in state.cacheUsers.value){
if(mru.uid == meetingRoomUser.uid){
mru.enableMicr = true;
@ -342,7 +324,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
muteLocalAudioStream(false);
}
}else{
debugPrint("wgs输出===Socket-用户单独闭麦");
debugPrint("wgs输出===Socket-用户单独闭麦${meetingRoomUser.uid}-${meetingRoomUser.userName}");
for(MeetingRoomUser mru in state.cacheUsers.value){
if(mru.uid == meetingRoomUser.uid){
mru.enableMicr = false;
@ -378,6 +360,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
for(var j = 0; j < state.cacheUsers.value.length; j++){
if(state.cacheUsers.value[j].uid == uidStr){
state.cacheUsers.value.removeAt(j);
doHttpGetTvAnchor();
}
}
}
@ -453,6 +436,12 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
if(meetingRoomUser.uid == UserStore.to.userInfoEntity.value!.uid){
state.isOpenCamera.value = false;
//
if(state.isSelf.value == true){
changePageState(0);
state.isSelf.value = false;
}
//
muteLocalVideoStream(true);
//

View File

@ -448,9 +448,9 @@ class MeetingMainPageState extends State<MeetingMainPage> {
applySpeakPermissionBottomSheet(context));
} else {
if (state.isOpenMicrophone.value == false) {
logic.setMicrophoneOpen(true);
logic.doHttpSetMicr(true);
} else {
logic.setMicrophoneOpen(false);
logic.doHttpSetMicr(false);
}
}
},
@ -484,9 +484,9 @@ class MeetingMainPageState extends State<MeetingMainPage> {
onTap: () {
if (state.isSpeak.value == true) {
if (state.isOpenCamera.value == true) {
logic.setCameraOpen(false);
logic.doHttpSetCamer(false);
} else {
logic.setCameraOpen(true);
logic.doHttpSetCamer(true);
}
}
},
@ -1530,7 +1530,7 @@ class MeetingMainPageState extends State<MeetingMainPage> {
),
)
: const CircularProgressIndicator(),
Positioned(
/*Positioned(
bottom: 110,
child: GestureDetector(
child: Image.asset(
@ -1539,10 +1539,9 @@ class MeetingMainPageState extends State<MeetingMainPage> {
height: 50.h,
),
onTap: () {
},
),
),
),*/
Positioned(
top: 16,
right: 16,
@ -1710,7 +1709,7 @@ class MeetingMainPageState extends State<MeetingMainPage> {
canvas: const VideoCanvas(uid: 0, setupMode: VideoViewSetupMode.videoViewSetupAdd),
),
),
Positioned(
/*Positioned(
bottom: 110,
child: GestureDetector(
child: Image.asset(
@ -1719,10 +1718,9 @@ class MeetingMainPageState extends State<MeetingMainPage> {
height: 50.h,
),
onTap: () {
},
),
),
),*/
Positioned(
top: 16,
right: 16,