1.优化鸿蒙手机监控/视频对讲动画转动问题
This commit is contained in:
parent
ae62d3f820
commit
9a76dcd232
@ -50,6 +50,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
print("LockDetailPage initState");
|
||||
state.animationController = AnimationController(duration: const Duration(seconds: 1), vsync: this);
|
||||
state.animationController?.repeat();
|
||||
@ -63,7 +64,6 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
state.animationController?.forward();
|
||||
}
|
||||
});
|
||||
super.initState();
|
||||
|
||||
state.pageController.addListener(() {
|
||||
state.currentPage.value = state.pageController.page!.round();
|
||||
|
||||
@ -239,14 +239,7 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
|
||||
// 异步设置帧渲染监听器
|
||||
VideoDecodePlugin.setOnFrameRenderedListener((textureId) {
|
||||
AppLog.log('已经开始渲染=======');
|
||||
// 只有真正渲染出首帧时才关闭loading
|
||||
Future.microtask(() {
|
||||
state.isLoading.value = false;
|
||||
// 添加停止动画的代码
|
||||
if (state.animationController.isAnimating) {
|
||||
state.animationController.stop();
|
||||
}
|
||||
});
|
||||
Future.microtask(() => state.isLoading.value = false);
|
||||
});
|
||||
} else {
|
||||
AppLog.log('视频解码器初始化失败或超时, 耗时: ${duration}ms');
|
||||
@ -588,7 +581,6 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
|
||||
|
||||
/// 从缓冲区处理下一帧 - 优化版:简化逻辑和动态调整
|
||||
Future<void> _processNextFrameFromBuffer() async {
|
||||
final stopwatch = Stopwatch()..start();
|
||||
_monitorFrameProcessingPerformance();
|
||||
final startTime = DateTime.now().microsecondsSinceEpoch;
|
||||
|
||||
@ -774,8 +766,6 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
|
||||
AppLog.log('帧处理耗时过长: ${durationMs.toStringAsFixed(2)} ms, 缓冲区长度: ${state.h264FrameBuffer.length}');
|
||||
}
|
||||
}
|
||||
stopwatch.stop();
|
||||
print('执行耗时: ${stopwatch.elapsedMilliseconds} 毫秒');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -39,32 +39,23 @@ class _TalkViewNativeDecodePageState extends State<TalkViewNativeDecodePage> wit
|
||||
final TalkViewNativeDecodeState state = Get.find<TalkViewNativeDecodeLogic>().state;
|
||||
final startChartManage = StartChartManage();
|
||||
|
||||
late AnimationController _animationController; // 改为本地变量
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_animationController = AnimationController( // 使用本地变量
|
||||
vsync: this,
|
||||
state.animationController = AnimationController(
|
||||
vsync: this, // 确保使用的TickerProvider是当前Widget
|
||||
duration: const Duration(seconds: 1),
|
||||
);
|
||||
|
||||
state.animationController = _animationController; // 同步到状态
|
||||
|
||||
_animationController.repeat();
|
||||
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
_animationController.duration = const Duration(milliseconds: 500);
|
||||
});
|
||||
|
||||
_animationController.addStatusListener((AnimationStatus status) {
|
||||
state.animationController.repeat();
|
||||
//动画开始、结束、向前移动或向后移动时会调用StatusListener
|
||||
state.animationController.addStatusListener((AnimationStatus status) {
|
||||
if (status == AnimationStatus.completed) {
|
||||
_animationController.reset();
|
||||
_animationController.forward();
|
||||
state.animationController.reset();
|
||||
state.animationController.forward();
|
||||
} else if (status == AnimationStatus.dismissed) {
|
||||
_animationController.reset();
|
||||
_animationController.forward();
|
||||
state.animationController.reset();
|
||||
state.animationController.forward();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -521,10 +512,6 @@ class _TalkViewNativeDecodePageState extends State<TalkViewNativeDecodePage> wit
|
||||
@override
|
||||
void dispose() {
|
||||
CallTalk().finishAVData();
|
||||
|
||||
// 只处理本地的 animation controller
|
||||
_animationController.dispose();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user