diff --git a/lib/controller/home/home_controller.dart b/lib/controller/home/home_controller.dart index a682176..a9ee598 100644 --- a/lib/controller/home/home_controller.dart +++ b/lib/controller/home/home_controller.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:convert'; +import 'dart:math'; import 'package:dating_touchme_app/config/env_config.dart'; import 'package:dating_touchme_app/controller/discover/room_controller.dart'; @@ -116,7 +117,7 @@ class HomeController extends GetxController { if (Get.isRegistered()) { final roomController = Get.find(); if(data["data"]["illegalHandle"] == 1){ - RTCManager.instance.publishAudio(); + // RTCManager.instance.closeCamera(); // 隐藏 overlay if(!roomController.isDialogShowing.value){ @@ -185,6 +186,7 @@ class HomeController extends GetxController { ), ).onTap(() { + // RTCManager.instance.reOpenCamera(); // 隐藏 overlay SmartDialog.dismiss(); roomController.setDialogDismiss(false); @@ -313,7 +315,9 @@ class HomeController extends GetxController { onError: (error) { print("SSE Error: $error"); sseClient.close(connectionId: "connectionId"); - Future.delayed(Duration(seconds: 3), () async { + final random = Random(); + int value = random.nextInt(8) + 3; + Future.delayed(Duration(seconds: value), () async { openSSE(); }); diff --git a/lib/rtc/rtc_manager.dart b/lib/rtc/rtc_manager.dart index a907550..07f4d89 100644 --- a/lib/rtc/rtc_manager.dart +++ b/lib/rtc/rtc_manager.dart @@ -372,6 +372,21 @@ class RTCManager { print("当前人脸数:$numFaces"); }, + onRemoteVideoStateChanged: ( + RtcConnection connection, + int remoteUid, + RemoteVideoState state, + RemoteVideoStateReason reason, + int elapsed + ){ + print("$remoteUid,$state"); + print("变化变化"); + if(state == RemoteVideoState.remoteVideoStateStopped){ + + } else { + + } + }, onError: (ErrorCodeType err, String msg) { print('RTC Engine 错误:$err,消息:$msg'); if (onError != null) { @@ -385,6 +400,7 @@ class RTCManager { ); } }, + ), ); } @@ -773,4 +789,20 @@ class RTCManager { }), ); } + + closeCamera() async { + await _engine?.enableLocalVideo(false); + } + + reOpenCamera() async { + await _engine?.enableLocalVideo(true); + await _engine?.updateChannelMediaOptions(ChannelMediaOptions( + channelProfile: ChannelProfileType.channelProfileLiveBroadcasting, + clientRoleType: _clientRole, + autoSubscribeAudio: true, + autoSubscribeVideo: true, + publishCameraTrack: true, + publishMicrophoneTrack: true, + )); + } }