fix:增加对讲时的通话计时、调整对讲时画布旋转逻辑

This commit is contained in:
liyi 2025-01-20 16:23:01 +08:00
parent 9527f8e019
commit 9504a97bde
3 changed files with 47 additions and 15 deletions

View File

@ -50,7 +50,6 @@ class TalkViewLogic extends BaseGetXController {
int audioFrameIntervalMs = 20; // 4522FPS int audioFrameIntervalMs = 20; // 4522FPS
int minFrameIntervalMs = 30; // 33 FPS int minFrameIntervalMs = 30; // 33 FPS
int maxFrameIntervalMs = 100; // 1 FPS int maxFrameIntervalMs = 100; // 1 FPS
// int maxFrameIntervalMs = 100; // 10 FPS
/// ///
void _initFlutterPcmSound() { void _initFlutterPcmSound() {
@ -118,6 +117,17 @@ class TalkViewLogic extends BaseGetXController {
case TalkStatus.end: case TalkStatus.end:
_handleInvalidTalkStatus(); _handleInvalidTalkStatus();
break; break;
case TalkStatus.answeredSuccessfully:
state.oneMinuteTimeTimer?.cancel(); //
state.oneMinuteTimeTimer ??=
Timer.periodic(const Duration(seconds: 1), (Timer t) {
state.oneMinuteTime.value++;
if (state.oneMinuteTime.value >= 60) {
t.cancel(); //
state.oneMinuteTime.value = 0;
}
});
break;
default: default:
// //
break; break;
@ -160,12 +170,6 @@ class TalkViewLogic extends BaseGetXController {
/// ///
void _adjustFrameInterval() { void _adjustFrameInterval() {
int newFrameIntervalMs = frameIntervalMs; int newFrameIntervalMs = frameIntervalMs;
if (state.networkStatus.value == NetworkStatus.lagging) {
bufferSize = 60; //
} else {
bufferSize = 40; //
}
if (state.videoBuffer.length < 10 && frameIntervalMs < maxFrameIntervalMs) { if (state.videoBuffer.length < 10 && frameIntervalMs < maxFrameIntervalMs) {
// //
frameIntervalMs += 5; frameIntervalMs += 5;
@ -442,7 +446,8 @@ class TalkViewLogic extends BaseGetXController {
_syncTimer = null; // _syncTimer = null; //
_audioTimer?.cancel(); _audioTimer?.cancel();
_audioTimer = null; // _audioTimer = null; //
state.oneMinuteTimeTimer?.cancel();
state.oneMinuteTimeTimer = null;
stopProcessingAudio(); stopProcessingAudio();
super.onClose(); super.onClose();
} }

View File

@ -107,13 +107,13 @@ class _TalkViewPageState extends State<TalkViewPage>
canPop: false, canPop: false,
child: RepaintBoundary( child: RepaintBoundary(
key: state.globalKey, key: state.globalKey,
child: Transform.rotate( child: SizedBox.expand(
angle: child: RotatedBox(
state.rotateAngle.value * (pi / 180), // 90 quarterTurns: -1,
child: Transform.scale(
scale: scale, //
child: Image.memory( child: Image.memory(
state.listData.value, state.listData.value,
width: ScreenUtil().scaleWidth,
height: ScreenUtil().scaleHeight,
gaplessPlayback: true, gaplessPlayback: true,
fit: BoxFit.cover, fit: BoxFit.cover,
filterQuality: FilterQuality.high, filterQuality: FilterQuality.high,
@ -139,6 +139,34 @@ class _TalkViewPageState extends State<TalkViewPage>
style: TextStyle(color: Colors.black, fontSize: 26.sp), style: TextStyle(color: Colors.black, fontSize: 26.sp),
)) ))
: Container()), : Container()),
Obx(
() => state.listData.value.isNotEmpty
? Positioned(
top: ScreenUtil().statusBarHeight + 75.h,
width: 1.sw,
child: Obx(
() {
final String sec = (state.oneMinuteTime.value % 60)
.toString()
.padLeft(2, '0');
final String min = (state.oneMinuteTime.value ~/ 60)
.toString()
.padLeft(2, '0');
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'$min:$sec',
style: TextStyle(
fontSize: 26.sp, color: Colors.white),
),
],
);
},
),
)
: Container(),
),
Positioned( Positioned(
bottom: 10.w, bottom: 10.w,
child: Container( child: Container(

View File

@ -37,8 +37,7 @@ class TalkViewState {
RxList<int> listAudioData = <int>[].obs; // RxList<int> listAudioData = <int>[].obs; //
GlobalKey globalKey = GlobalKey(); GlobalKey globalKey = GlobalKey();
late Timer oneMinuteTimeTimer = Timer? oneMinuteTimeTimer; // 60
Timer(const Duration(seconds: 1), () {}); // 60
RxInt oneMinuteTime = 0.obs; // RxInt oneMinuteTime = 0.obs; //
// 10 // 10