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

View File

@ -107,13 +107,13 @@ class _TalkViewPageState extends State<TalkViewPage>
canPop: false,
child: RepaintBoundary(
key: state.globalKey,
child: Transform.rotate(
angle:
state.rotateAngle.value * (pi / 180), // 90
child: Transform.scale(
scale: scale, //
child: SizedBox.expand(
child: RotatedBox(
quarterTurns: -1,
child: Image.memory(
state.listData.value,
width: ScreenUtil().scaleWidth,
height: ScreenUtil().scaleHeight,
gaplessPlayback: true,
fit: BoxFit.cover,
filterQuality: FilterQuality.high,
@ -139,6 +139,34 @@ class _TalkViewPageState extends State<TalkViewPage>
style: TextStyle(color: Colors.black, fontSize: 26.sp),
))
: 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(
bottom: 10.w,
child: Container(

View File

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