增加推拉流播放和停止
This commit is contained in:
@@ -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={
|
||||
<Button
|
||||
size="small"
|
||||
icon={isVideoPlaying ? <PauseOutlined /> : <PlayCircleOutlined />}
|
||||
onClick={toggleVideoPlay}
|
||||
>
|
||||
{isVideoPlaying ? '停止' : '播放'}
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<Space style={{ marginBottom: 8, }} align="start" >
|
||||
<Button type={mowerView === 'front' ? 'primary' : 'default'} onClick={() => setMowerView('front')}>前视</Button>
|
||||
@@ -1208,7 +1239,7 @@ export default function DeviceStatusPage() {
|
||||
</div>
|
||||
)
|
||||
) : (
|
||||
<div style={{ color: '#ccc', margin: 'auto' }}>视频加载中...</div>
|
||||
<div style={{ color: '#ccc', margin: 'auto', fontSize: 40 }}>视频加载中...</div>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user