无人机声望视频 成功 之前对接的都是火山的

This commit is contained in:
mmc
2026-06-03 16:09:11 +08:00
parent bb130f3525
commit 14970f7296
2 changed files with 67 additions and 120 deletions

View File

@@ -27,15 +27,28 @@ const client = AgoraRTC.createClient({
codec: "vp8",
});
export default function AgoraRtcRoom() {
const parseUrlParams = (url) => {
const params = new URLSearchParams(url);
return {
appId: params.get("app_id") || "",
channel: params.get("channel") || "",
token: params.get("token") || "",
uid: params.get("uid") || String(Math.floor(Math.random() * 100000)),
sn: params.get("sn") || "",
};
};
const [uid] = useState(() =>
String(
Math.floor(
Math.random() * 100000
)
)
);
export default function AgoraRtcRoom({ url = "" }) {
const { appId, channel, token, uid } = parseUrlParams(url);
//const [uid] = useState(() =>
// String(
// Math.floor(
// Math.random() * 100000
// )
// )
//);
const [connected, setConnected] =
useState(false);
@@ -148,10 +161,17 @@ export default function AgoraRtcRoom() {
);
// 加入频道
//await client.join(
// APP_ID,
// CHANNEL,
// TOKEN,
// uid
//);
await client.join(
APP_ID,
CHANNEL,
TOKEN,
appId,
channel,
token,
uid
);
@@ -246,122 +266,40 @@ export default function AgoraRtcRoom() {
return (
<Card
title="Agora RTC 音视频测试"
<div
style={{
width: 1000,
margin:
"20px auto",
display: "flex",
gap: 20,
width: "100%",
height: '100%'
}}
>
<Space
direction="vertical"
<div
ref={
remoteVideoRef
}
style={{
width: "100%",
height: '100%',
background:
"#000",
borderRadius: 8,
overflow:
"hidden",
}}
>
/>
<div>
当前 UID:{uid}
</div>
<Badge
color={
connected
? "green"
: "red"
}
text={
connected
? "RTC 已连接"
: "RTC 未连接"
}
/>
<Badge
color={
published
? "green"
: "orange"
}
text={
published
? "已推流"
: "未推流"
}
/>
</div>
<Button
type="primary"
onClick={
startPublish
}
disabled={
!joined ||
published
}
>
开始音视频推流
</Button>
<div
style={{
display: "flex",
gap: 20,
marginTop: 20,
}}
>
<div>
<h3>
本地视频
</h3>
<div
ref={
localVideoRef
}
style={{
width: 400,
height: 300,
background:
"#000",
borderRadius: 8,
overflow:
"hidden",
}}
/>
</div>
<div>
<h3>
远端视频
</h3>
<div
ref={
remoteVideoRef
}
style={{
width: 400,
height: 300,
background:
"#000",
borderRadius: 8,
overflow:
"hidden",
}}
/>
</div>
</div>
</Space>
</Card>
);
}

View File

@@ -4,6 +4,7 @@ import { ReloadOutlined } from '@ant-design/icons';
import DroneLivePlayer from '../VolcRtcPlayer.jsx';
import { changeCameragateway, changeCameraPlane } from '../../api/device.ts';
import utils from '../../lib/utils';
import AgoraRtcRoom from '../AgoraRtc.tsx';
const { Text } = Typography;
@@ -245,10 +246,18 @@ const DroneVideoPlayer: React.FC<DroneVideoPlayerProps> = ({
)}
</div>
{/* 视频内容 */}
{streamData ? (
<DroneLivePlayer streamData={streamData}
/>
streamData?.url_type == "volc" ? (
<DroneLivePlayer
key={streamData.url}
streamData={streamData}
/>
) : (
<AgoraRtcRoom
key={streamData.url}
url={streamData.url}
/>
)
) : (
<div style={{
color: '#ccc',