功能结束

This commit is contained in:
fuenmao 2024-12-04 14:24:07 +08:00
parent 674a5f8a53
commit ded1698f63
6 changed files with 89 additions and 48 deletions

View File

@ -74,6 +74,14 @@ abstract class RetrofitClient {
@Query("roomNum") String roomNum, @Query("roomNum") String roomNum,
); );
///
@POST("/room/show-user")
Future<BaseStructureResult> setTvAnchor(
@Query("roomNum") String roomNum,
@Query("uid") String uid,
@Query("uname") String uname,
);
/// ///
@GET("/room/oper-micr") @GET("/room/oper-micr")
Future<BaseStructureResult<String>> setMicr( Future<BaseStructureResult<String>> setMicr(

View File

@ -135,25 +135,26 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
/// ///
Future<void> doHttpApplySpeak() async { Future<void> doHttpApplySpeak() async {
BaseStructureResult res = await getClient().applySpeak(state.roomNumber.value); await getClient().applySpeak(state.roomNumber.value);
} }
/// ///
Future<void> doHttpSetMicr() async { Future<void> doHttpSetMicr() async {
BaseStructureResult res = await getClient().setMicr(state.roomNumber.value, state.isOpenMicrophone.value, UserStore.to.userInfoEntity.value!.uid); await getClient().setMicr(state.roomNumber.value, state.isOpenMicrophone.value, UserStore.to.userInfoEntity.value!.uid);
} }
/// ///
Future<void> doHttpSetCamer() async { Future<void> doHttpSetCamer() async {
BaseStructureResult res = await getClient().setCamera(state.roomNumber.value, state.isOpenCamera.value, UserStore.to.userInfoEntity.value!.uid); await getClient().setCamera(state.roomNumber.value, state.isOpenCamera.value, UserStore.to.userInfoEntity.value!.uid);
} }
/// ///
Future<void> doHttpCancelSpeak() async { Future<void> doHttpCancelSpeak() async {
BaseStructureResult res = 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("观众"); setClientRole("观众");
setMicrophoneOpen(false); setMicrophoneOpen(false);
setCameraOpen(false); setCameraOpen(false);
setScreenShareOpen(false);
changePageState(0); changePageState(0);
} }
@ -200,33 +201,48 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
/// ///
Future<void> doHttpGetTvAnchor() async { Future<void> doHttpGetTvAnchor() async {
BaseStructureResult res = await getClient().getTvAnchor(state.roomNumber.value); BaseStructureResult res = await getClient().getTvAnchor(state.roomNumber.value);
/*var s = 2;
if(res.data!.toString().length != 9){
if(s == 2){
state.remoteUid.value = "18";
setEnableVideo();
changePageState(1);
state.isOpenCamera.value = true;
setEnableVideo();
setClientRole("主播");
changePageState(1);
*//*var isSaveLive = false;
for(MeetingRoomUser mru in state.cacheUsers.value){
if(mru.uid == state.remoteUid.value){
isSaveLive = true;
}
}
if(isSaveLive == true){
changePageState(1);
}*//*
}*/
state.remoteUid.value = res.data!.toString(); state.remoteUid.value = res.data!.toString();
if(res.data!.toString().length != 9){ if(res.data!.toString().length != 9){
Future.delayed(const Duration(milliseconds: 1000), () { if(state.remoteUid.value != UserStore.to.userInfoEntity.value!.uid) {
changePageState(1); Future.delayed(const Duration(milliseconds: 1000), () {
}); changePageState(1);
});
}
}else{
if(state.remoteUid.value != UserStore.to.userInfoEntity.value!.screenShareId){
Future.delayed(const Duration(milliseconds: 1000), () {
changePageState(2);
});
}
}
}
///
Future<void> setScreenShareOpen(bool isOpen) async {
state.isOpenShare.value = isOpen;
if(isOpen == true){
await getClient().setTvAnchor(
state.roomNumber.value,
UserStore.to.userInfoEntity.value!.screenShareId,
UserStore.to.userInfoEntity.value!.userName
);
await state.rctEngine.value?.startScreenCapture(const ScreenCaptureParameters2(captureAudio: true, captureVideo: true));
await state.rctEngine.value?.joinChannelEx(
token: state.meetingToken.value,
connection: RtcConnection(channelId: state.roomNumber.value, localUid: int.tryParse(UserStore.to.userInfoEntity.value!.screenShareId)),
options: const ChannelMediaOptions(
publishScreenCaptureAudio: true,
publishScreenCaptureVideo: true,
clientRoleType: ClientRoleType.clientRoleBroadcaster,
));
}else{
await state.rctEngine.value?.stopScreenCapture();
await state.rctEngine.value?.leaveChannelEx(
connection: RtcConnection(channelId: state.roomNumber.value, localUid: int.tryParse(UserStore.to.userInfoEntity.value!.screenShareId)),
options: const LeaveChannelOptions(
stopMicrophoneRecording: false,
stopAllEffect: false
));
} }
} }

View File

@ -61,6 +61,8 @@ class MeetingMainState {
late RxBool isOpenCamera = false.obs; late RxBool isOpenCamera = false.obs;
/// ID /// ID
late RxString remoteUid = "".obs; late RxString remoteUid = "".obs;
///
late RxBool isOpenShare = false.obs;
/// ///
late RxList<MeetingRoomMsg> meetingRoomMsgs = RxList([]); late RxList<MeetingRoomMsg> meetingRoomMsgs = RxList([]);

View File

@ -201,7 +201,13 @@ class MeetingMainPage extends StatelessWidget {
// //
Visibility( Visibility(
visible: state.pageState.value == 2, visible: state.pageState.value == 2,
child: MeetingMainShareComponent() child: null != state.rctEngine.value
? MeetingMainShareComponent(
rtcEngine: state.rctEngine.value!,
channelId: state.roomNumber.value,
remoteUid: state.remoteUid.value,
)
: Container()
), ),
GestureDetector( GestureDetector(
@ -357,7 +363,7 @@ class MeetingMainPage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Image.asset( Image.asset(
'assets/images/meeting_main_share_default.png', state.isSpeak.value == true ? state.isOpenShare.value == true ? 'assets/images/meeting_main_share_open.png' : 'assets/images/meeting_main_share_default.png' : 'assets/images/meeting_main_share_close.png',
width: 22.w, width: 22.w,
height: 22.h, height: 22.h,
), ),
@ -371,7 +377,13 @@ class MeetingMainPage extends StatelessWidget {
], ],
), ),
onTap: (){ onTap: (){
ToastUtils.getErrFluttertoast(context: context, msg: '开启共享...'); if(state.isSpeak.value == true){
if(state.isOpenShare.value == true){
logic.setScreenShareOpen(false);
}else{
logic.setScreenShareOpen(true);
}
}
}, },
), ),

View File

@ -1,3 +1,4 @@
import 'package:agora_rtc_engine/agora_rtc_engine.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -7,7 +8,11 @@ import 'meeting_main_share_logic.dart';
import 'meeting_main_share_state.dart'; import 'meeting_main_share_state.dart';
class MeetingMainShareComponent extends StatelessWidget { class MeetingMainShareComponent extends StatelessWidget {
MeetingMainShareComponent({Key? key}) : super(key: key); MeetingMainShareComponent({super.key, required this.rtcEngine, required this.channelId, required this.remoteUid});
final RtcEngine rtcEngine;
final String channelId;
final String remoteUid;
final MeetingMainShareLogic logic = Get.put(MeetingMainShareLogic()); final MeetingMainShareLogic logic = Get.put(MeetingMainShareLogic());
final MeetingMainShareState state = Get.find<MeetingMainShareLogic>().state; final MeetingMainShareState state = Get.find<MeetingMainShareLogic>().state;
@ -18,15 +23,13 @@ class MeetingMainShareComponent extends StatelessWidget {
child: Stack( child: Stack(
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
Container( AgoraVideoView(
decoration: BoxDecoration( controller: VideoViewController.remote(
image: DecorationImage( rtcEngine: rtcEngine,
fit: BoxFit.fill, canvas: VideoCanvas(uid: int.tryParse(remoteUid)),
image: NetworkImage( connection: RtcConnection(channelId: channelId),
"https://tse4-mm.cn.bing.net/th/id/OIP-C.acWMNnQ04Ks6Bh2b9Zq8XwHaKF?rs=1&pid=ImgDetMain", ),
), ),
),
)),
Positioned( Positioned(
bottom: 110, bottom: 110,
child: Image.asset( child: Image.asset(

View File

@ -20,12 +20,12 @@ class MeetingMainVideoComponent extends StatefulWidget {
required this.onHangUpTap, required this.onHangUpTap,
required this.users}); required this.users});
RtcEngine rtcEngine; final RtcEngine rtcEngine;
String channelId; final String channelId;
String remoteUid; final String remoteUid;
bool isOpenCamera; final bool isOpenCamera;
List<MeetingRoomUser> users; final List<MeetingRoomUser> users;
Function onHangUpTap; final Function onHangUpTap;
@override @override
State<MeetingMainVideoComponent> createState() => _MeetingMainVideoComponentState(); State<MeetingMainVideoComponent> createState() => _MeetingMainVideoComponentState();