|
|
|
@ -1,13 +1,18 @@ |
|
|
|
import 'dart:async'; |
|
|
|
import 'dart:convert'; |
|
|
|
|
|
|
|
import 'package:agora_rtc_engine/agora_rtc_engine.dart'; |
|
|
|
import 'package:agora_token_generator/agora_token_generator.dart'; |
|
|
|
import 'package:dating_touchme_app/rtc/rtm_manager.dart'; |
|
|
|
import 'package:flutter/foundation.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
|
|
|
|
|
import '../controller/discover/room_controller.dart'; |
|
|
|
import '../controller/message/call_controller.dart'; |
|
|
|
import '../generated/assets.dart'; |
|
|
|
import '../pages/discover/live_room_page.dart'; |
|
|
|
import '../service/live_chat_message_service.dart'; |
|
|
|
|
|
|
|
@ -117,6 +122,9 @@ class RTCManager { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Timer? _zeroTimer; |
|
|
|
bool isShow = false; |
|
|
|
|
|
|
|
/// 注册事件处理器 |
|
|
|
void _registerEventHandlers() { |
|
|
|
if (_engine == null) return; |
|
|
|
@ -339,6 +347,78 @@ class RTCManager { |
|
|
|
List<int> vecDistance, |
|
|
|
int numFaces){ |
|
|
|
print("当前人脸数:$numFaces"); |
|
|
|
if (numFaces > 0) { |
|
|
|
// 只要不是0就取消计时 |
|
|
|
_zeroTimer?.cancel(); |
|
|
|
_zeroTimer = null; |
|
|
|
} else { |
|
|
|
// value == 0 |
|
|
|
// 如果还没开始计时,则开始 |
|
|
|
if (_zeroTimer == null && !isShow) { |
|
|
|
_zeroTimer = Timer(const Duration(minutes: 2), () { |
|
|
|
isShow = true; |
|
|
|
// 隐藏 overlay |
|
|
|
SmartDialog.dismiss(); |
|
|
|
|
|
|
|
SmartDialog.show( |
|
|
|
onDismiss: (){ |
|
|
|
isShow = false; |
|
|
|
}, |
|
|
|
builder: (context) { |
|
|
|
return ClipRRect( |
|
|
|
borderRadius: BorderRadius.all(Radius.circular(16.w)), |
|
|
|
child: Material( |
|
|
|
color: Colors.white, |
|
|
|
child: Container( |
|
|
|
width: 311.w, |
|
|
|
height: 298.w, |
|
|
|
padding: EdgeInsets.symmetric( |
|
|
|
vertical: 25.w, |
|
|
|
horizontal: 25.w |
|
|
|
), |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
Image.asset( |
|
|
|
Assets.imagesWarningIcon, |
|
|
|
width: 102.w, |
|
|
|
height: 102.w, |
|
|
|
), |
|
|
|
SizedBox(height: 12.w,), |
|
|
|
Text( |
|
|
|
"系统检测到您2分钟内没有露脸,请露脸直播。多次违规后,取消当日前面直播时长,并且关闭直播间。", |
|
|
|
textAlign: TextAlign.center, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.w |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 7.w,), |
|
|
|
Container( |
|
|
|
width: 188.w, |
|
|
|
height: 40.w, |
|
|
|
decoration: BoxDecoration( |
|
|
|
borderRadius: BorderRadius.all(Radius.circular(12.w)), |
|
|
|
color: const Color.fromRGBO(117, 98, 249, 1) |
|
|
|
), |
|
|
|
child: Center( |
|
|
|
child: Text( |
|
|
|
"确认", |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.w, |
|
|
|
color: Colors.white |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
) |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
}, |
|
|
|
); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
onError: (ErrorCodeType err, String msg) { |
|
|
|
print('RTC Engine 错误:$err,消息:$msg'); |
|
|
|
@ -506,8 +586,9 @@ class RTCManager { |
|
|
|
moduleCount: 1 |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
await _engine?.enableFaceDetection(true); |
|
|
|
if (role == ClientRoleType.clientRoleBroadcaster) { |
|
|
|
await _engine?.enableFaceDetection(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// 离开频道 |
|
|
|
|