1.优化鸿蒙手机监控/视频对讲动画转动问题

This commit is contained in:
sky.min 2025-12-29 08:57:36 +08:00
parent ae62d3f820
commit 9a76dcd232
3 changed files with 11 additions and 34 deletions

View File

@ -50,6 +50,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
@override @override
void initState() { void initState() {
super.initState();
print("LockDetailPage initState"); print("LockDetailPage initState");
state.animationController = AnimationController(duration: const Duration(seconds: 1), vsync: this); state.animationController = AnimationController(duration: const Duration(seconds: 1), vsync: this);
state.animationController?.repeat(); state.animationController?.repeat();
@ -63,7 +64,6 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
state.animationController?.forward(); state.animationController?.forward();
} }
}); });
super.initState();
state.pageController.addListener(() { state.pageController.addListener(() {
state.currentPage.value = state.pageController.page!.round(); state.currentPage.value = state.pageController.page!.round();

View File

@ -239,14 +239,7 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
// //
VideoDecodePlugin.setOnFrameRenderedListener((textureId) { VideoDecodePlugin.setOnFrameRenderedListener((textureId) {
AppLog.log('已经开始渲染======='); AppLog.log('已经开始渲染=======');
// loading Future.microtask(() => state.isLoading.value = false);
Future.microtask(() {
state.isLoading.value = false;
//
if (state.animationController.isAnimating) {
state.animationController.stop();
}
});
}); });
} else { } else {
AppLog.log('视频解码器初始化失败或超时, 耗时: ${duration}ms'); AppLog.log('视频解码器初始化失败或超时, 耗时: ${duration}ms');
@ -588,7 +581,6 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
/// - /// -
Future<void> _processNextFrameFromBuffer() async { Future<void> _processNextFrameFromBuffer() async {
final stopwatch = Stopwatch()..start();
_monitorFrameProcessingPerformance(); _monitorFrameProcessingPerformance();
final startTime = DateTime.now().microsecondsSinceEpoch; final startTime = DateTime.now().microsecondsSinceEpoch;
@ -774,8 +766,6 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
AppLog.log('帧处理耗时过长: ${durationMs.toStringAsFixed(2)} ms, 缓冲区长度: ${state.h264FrameBuffer.length}'); AppLog.log('帧处理耗时过长: ${durationMs.toStringAsFixed(2)} ms, 缓冲区长度: ${state.h264FrameBuffer.length}');
} }
} }
stopwatch.stop();
print('执行耗时: ${stopwatch.elapsedMilliseconds} 毫秒');
} }

View File

@ -39,32 +39,23 @@ class _TalkViewNativeDecodePageState extends State<TalkViewNativeDecodePage> wit
final TalkViewNativeDecodeState state = Get.find<TalkViewNativeDecodeLogic>().state; final TalkViewNativeDecodeState state = Get.find<TalkViewNativeDecodeLogic>().state;
final startChartManage = StartChartManage(); final startChartManage = StartChartManage();
late AnimationController _animationController; //
@override @override
void initState() { void initState() {
super.initState(); super.initState();
state.animationController = AnimationController(
_animationController = AnimationController( // 使 vsync: this, // 使TickerProvider是当前Widget
vsync: this,
duration: const Duration(seconds: 1), duration: const Duration(seconds: 1),
); );
state.animationController = _animationController; // state.animationController.repeat();
//StatusListener
_animationController.repeat(); state.animationController.addStatusListener((AnimationStatus status) {
SchedulerBinding.instance.addPostFrameCallback((_) {
_animationController.duration = const Duration(milliseconds: 500);
});
_animationController.addStatusListener((AnimationStatus status) {
if (status == AnimationStatus.completed) { if (status == AnimationStatus.completed) {
_animationController.reset(); state.animationController.reset();
_animationController.forward(); state.animationController.forward();
} else if (status == AnimationStatus.dismissed) { } else if (status == AnimationStatus.dismissed) {
_animationController.reset(); state.animationController.reset();
_animationController.forward(); state.animationController.forward();
} }
}); });
} }
@ -521,10 +512,6 @@ class _TalkViewNativeDecodePageState extends State<TalkViewNativeDecodePage> wit
@override @override
void dispose() { void dispose() {
CallTalk().finishAVData(); CallTalk().finishAVData();
// animation controller
_animationController.dispose();
super.dispose(); super.dispose();
} }
} }