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

View File

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