功能结束

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,
);
///
@POST("/room/show-user")
Future<BaseStructureResult> setTvAnchor(
@Query("roomNum") String roomNum,
@Query("uid") String uid,
@Query("uname") String uname,
);
///
@GET("/room/oper-micr")
Future<BaseStructureResult<String>> setMicr(

View File

@ -135,25 +135,26 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
///
Future<void> doHttpApplySpeak() async {
BaseStructureResult res = await getClient().applySpeak(state.roomNumber.value);
await getClient().applySpeak(state.roomNumber.value);
}
///
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 {
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 {
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("观众");
setMicrophoneOpen(false);
setCameraOpen(false);
setScreenShareOpen(false);
changePageState(0);
}
@ -200,34 +201,49 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
///
Future<void> doHttpGetTvAnchor() async {
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();
if(res.data!.toString().length != 9){
if(state.remoteUid.value != UserStore.to.userInfoEntity.value!.uid) {
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
));
}
}
/// --------------------------signalR Socket相关

View File

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

View File

@ -201,7 +201,13 @@ class MeetingMainPage extends StatelessWidget {
//
Visibility(
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(
@ -357,7 +363,7 @@ class MeetingMainPage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
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,
height: 22.h,
),
@ -371,7 +377,13 @@ class MeetingMainPage extends StatelessWidget {
],
),
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_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
@ -7,7 +8,11 @@ import 'meeting_main_share_logic.dart';
import 'meeting_main_share_state.dart';
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 MeetingMainShareState state = Get.find<MeetingMainShareLogic>().state;
@ -18,15 +23,13 @@ class MeetingMainShareComponent extends StatelessWidget {
child: Stack(
alignment: Alignment.center,
children: [
Container(
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: NetworkImage(
"https://tse4-mm.cn.bing.net/th/id/OIP-C.acWMNnQ04Ks6Bh2b9Zq8XwHaKF?rs=1&pid=ImgDetMain",
AgoraVideoView(
controller: VideoViewController.remote(
rtcEngine: rtcEngine,
canvas: VideoCanvas(uid: int.tryParse(remoteUid)),
connection: RtcConnection(channelId: channelId),
),
),
)),
Positioned(
bottom: 110,
child: Image.asset(

View File

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