1.优化鸿蒙手机监控/视频对讲动画转动问题
This commit is contained in:
parent
ae62d3f820
commit
9a76dcd232
@ -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();
|
||||||
|
|||||||
@ -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} 毫秒');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user