远程遥控视频的显示bug修复;恢复远程遥控中的前置推送检查和动态实时信息的展示。

This commit is contained in:
2026-09-04 15:02:43 +08:00
parent db81816b78
commit b468e577a6
4 changed files with 128 additions and 16 deletions

View File

@@ -2,6 +2,7 @@ import 'package:cc_ui_kit/cc_ui_kit.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
import '../bloc/remote_control_cubit.dart';
@@ -115,6 +116,13 @@ class CenterControlArea extends StatelessWidget {
void _handleSliderAction(String deviceKey, String action, BuildContext context) {
debugPrint('🎯 [Slider 业务] deviceKey: $deviceKey, action: $action');
// 🔥 门槛检查:与摇杆一致,未收到 TCP 0x02 推送时禁止操作并提示。
// 胶囊 Toast 全局去重、自动消失,适配 StatelessWidget 无实例状态。
if (!context.read<RemoteControlCubit>().isStatusPushActive()) {
CapsuleToast.show('暂未收到该机器的推送,不能控制', showCheck: false);
return;
}
// 🔥 使用deviceKey进行判断,不依赖显示文本
switch (deviceKey) {
case 'chassis':

View File

@@ -71,6 +71,11 @@ class _WebRTCLocalPlayerState extends State<WebRTCLocalPlayer> {
void _updateLoadState(WebRTCLoadState state) {
if (_loadState == state) return;
_loadState = state;
// 🔥 自身状态变化必须触发重建:未传 onLoadingStateChanged 的调用方
// (如远程遥控页)否则无法从"视频加载中"切到 playing/error 界面
if (mounted) {
setState(() {});
}
widget.onLoadingStateChanged?.call(state);
}
@@ -404,19 +409,34 @@ class _WebRTCLocalPlayerState extends State<WebRTCLocalPlayer> {
// 🔥 在真正渲染出视频帧(playing 态)之前,始终显示加载指示器
// 避免出现"track 已收到但画面是黑的"黑屏情况
if (_loadState != WebRTCLoadState.playing) {
// 🔥 区分 loading 与 error:error 态显示明确失败提示,不再一直转圈
final bool isError = _loadState == WebRTCLoadState.error;
return Container(
color: Colors.black,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const CircularProgressIndicator(color: Colors.white),
const SizedBox(height: 12),
Text(
'视频加载中...',
style: TextStyle(color: Colors.white70, fontSize: 14),
),
],
children: isError
? [
const Icon(
Icons.videocam_off,
size: 48,
color: Colors.white38,
),
const SizedBox(height: 12),
const Text(
'视频加载失败,请检查设备是否在线或重试',
style: TextStyle(color: Colors.white70, fontSize: 14),
),
]
: [
const CircularProgressIndicator(color: Colors.white),
const SizedBox(height: 12),
const Text(
'视频加载中...',
style: TextStyle(color: Colors.white70, fontSize: 14),
),
],
),
),
);