diff --git a/src/components/devices/DeviceOverviewPage.tsx b/src/components/devices/DeviceOverviewPage.tsx index b4c2246..da12828 100644 --- a/src/components/devices/DeviceOverviewPage.tsx +++ b/src/components/devices/DeviceOverviewPage.tsx @@ -85,7 +85,7 @@ export default function DeviceOverviewPage() { const [currentParamDevice, setCurrentParamDevice] = useState(null); const navigate = useNavigate(); - console.log('stationId', stationId, currentStation); + const [robotPlayActive, setRobotPlayActive] = useState(false); // 获取数据 @@ -415,9 +415,12 @@ export default function DeviceOverviewPage() { }); // 机器人视频 + // 机器人视频:只有 robotPlayActive = true 才真正拉流 const { video: robotVideo, error, ready } = useWebRTCPlayer( - !isUAV ? selectedDevice?.serialNumber || '' : '', - `webrtc://1.95.137.212/live/livestream/${selectedDevice?.serialNumber}`, + (!isUAV && robotPlayActive) ? (selectedDevice?.serialNumber || '') : '', + (!isUAV && robotPlayActive) + ? `webrtc://1.95.137.212/live/livestream/${selectedDevice?.serialNumber}` + : '' ); const getDevivePermisstion = (data) => { @@ -545,6 +548,7 @@ export default function DeviceOverviewPage() { const handleDeviceChange = (id) => { setCurrentSelectedRobot(id); + setRobotPlayActive(false); }; // 获取无人机状态 @@ -867,22 +871,67 @@ export default function DeviceOverviewPage() { onSourceChange={setVideoSource} /> ) : ( - robotVideo ? ( - + robotPlayActive ? ( + robotVideo ? ( + + ) : ( +
+ 视频加载中... +
+ ) ) : ( -
- 视频加载中... + // ========== 未点击播放时:显示播放大按钮 ========== +
setRobotPlayActive(true)} + style={{ + width: '100%', + height: '100%', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + cursor: 'pointer', + background: '#000', + }} + > +
+ ▶ +
) )}
+ {!isUAV && robotPlayActive && ( +
+ +
+ )} + +
diff --git a/src/components/devices/DeviceStatusPage.tsx b/src/components/devices/DeviceStatusPage.tsx index ed3192e..ae0ffbb 100644 --- a/src/components/devices/DeviceStatusPage.tsx +++ b/src/components/devices/DeviceStatusPage.tsx @@ -60,6 +60,7 @@ import { MowerAllView } from './MowerAllView'; import { useMqtt } from '@/hooks/useMqtt'; import envConfig from '../../../env'; import { dataUrlToFile } from '@/lib/utils.ts'; +import { PauseOutlined, PlayCircleOutlined } from '@ant-design/icons'; const { RangePicker } = DatePicker; const { Text } = Typography; @@ -78,6 +79,15 @@ export default function DeviceStatusPage() { const [messageApi, contextHolder] = message.useMessage(); + // 视频播放开关 + const [isVideoPlaying, setIsVideoPlaying] = useState(false); + + const toggleVideoPlay = useCallback(() => { + setIsVideoPlaying(prev => !prev); + }, []); + + + const [isControlled, setIsControlled] = useState(false); const [hasControlRight, setHasControlRight] = useState(false); const [connecting, setConnecting] = useState(false); @@ -192,12 +202,16 @@ export default function DeviceStatusPage() { ); if (target) { setSelectedSn(urlSn); + setIsVideoPlaying(false); + return; } } // url无sn / 没匹配到对应设备:默认选中第一个 const firstDevice = devicesAll[0]; setSelectedSn(firstDevice.device_sn || firstDevice.serialNumber); + setIsVideoPlaying(false); + } }, [devicesAll, urlSn]); @@ -391,9 +405,16 @@ export default function DeviceStatusPage() { }, [device, wsDeviceInfo, isUAV]); const { video: robotVideo, error, ready } = useWebRTCPlayer( - !isUAV ? device?.serialNumber : '', - `webrtc://1.95.137.212/live/livestream/${device?.serialNumber}`, + (!isUAV && isVideoPlaying) ? (device?.serialNumber || '') : '', + (!isUAV && isVideoPlaying) + ? `webrtc://1.95.137.212/live/livestream/${device?.serialNumber}` + : '' ); + + //const { video: robotVideo, error, ready } = useWebRTCPlayer( + // !isUAV ? device?.serialNumber : '', + // `webrtc://1.95.137.212/live/livestream/${device?.serialNumber}`, + //); const getVal = (val) => val === "no_rain" ? "无" : (val || '-'); const realtimePosition = React.useMemo(() => { @@ -1051,6 +1072,16 @@ export default function DeviceStatusPage() { bordered={false} style={{ borderRadius: 12, marginBottom: 8 }} bodyStyle={{ padding: 12, height: 'calc(100vh - 220px)', minHeight: 500 }} + + extra={ + + } > @@ -1208,7 +1239,7 @@ export default function DeviceStatusPage() {
) ) : ( -
视频加载中...
+
视频加载中...
)}