无人机声望视频 成功 之前对接的都是火山的
This commit is contained in:
@@ -27,15 +27,28 @@ const client = AgoraRTC.createClient({
|
|||||||
codec: "vp8",
|
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(() =>
|
export default function AgoraRtcRoom({ url = "" }) {
|
||||||
String(
|
const { appId, channel, token, uid } = parseUrlParams(url);
|
||||||
Math.floor(
|
|
||||||
Math.random() * 100000
|
|
||||||
)
|
//const [uid] = useState(() =>
|
||||||
)
|
// String(
|
||||||
);
|
// Math.floor(
|
||||||
|
// Math.random() * 100000
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
//);
|
||||||
|
|
||||||
const [connected, setConnected] =
|
const [connected, setConnected] =
|
||||||
useState(false);
|
useState(false);
|
||||||
@@ -148,10 +161,17 @@ export default function AgoraRtcRoom() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 加入频道
|
// 加入频道
|
||||||
|
//await client.join(
|
||||||
|
// APP_ID,
|
||||||
|
// CHANNEL,
|
||||||
|
// TOKEN,
|
||||||
|
// uid
|
||||||
|
//);
|
||||||
|
|
||||||
await client.join(
|
await client.join(
|
||||||
APP_ID,
|
appId,
|
||||||
CHANNEL,
|
channel,
|
||||||
TOKEN,
|
token,
|
||||||
uid
|
uid
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -246,122 +266,40 @@ export default function AgoraRtcRoom() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<Card
|
|
||||||
title="Agora RTC 音视频测试"
|
|
||||||
|
|
||||||
|
|
||||||
|
<div
|
||||||
style={{
|
style={{
|
||||||
width: 1000,
|
display: "flex",
|
||||||
margin:
|
gap: 20,
|
||||||
"20px auto",
|
width: "100%",
|
||||||
|
height: '100%'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
||||||
<Space
|
|
||||||
direction="vertical"
|
|
||||||
|
|
||||||
|
<div
|
||||||
|
ref={
|
||||||
|
remoteVideoRef
|
||||||
|
}
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
|
height: '100%',
|
||||||
|
background:
|
||||||
|
"#000",
|
||||||
|
borderRadius: 8,
|
||||||
|
overflow:
|
||||||
|
"hidden",
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
|
|
||||||
<div>
|
|
||||||
当前 UID:{uid}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Badge
|
</div>
|
||||||
color={
|
|
||||||
connected
|
|
||||||
? "green"
|
|
||||||
: "red"
|
|
||||||
}
|
|
||||||
text={
|
|
||||||
connected
|
|
||||||
? "RTC 已连接"
|
|
||||||
: "RTC 未连接"
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Badge
|
|
||||||
color={
|
|
||||||
published
|
|
||||||
? "green"
|
|
||||||
: "orange"
|
|
||||||
}
|
|
||||||
text={
|
|
||||||
published
|
|
||||||
? "已推流"
|
|
||||||
: "未推流"
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { ReloadOutlined } from '@ant-design/icons';
|
|||||||
import DroneLivePlayer from '../VolcRtcPlayer.jsx';
|
import DroneLivePlayer from '../VolcRtcPlayer.jsx';
|
||||||
import { changeCameragateway, changeCameraPlane } from '../../api/device.ts';
|
import { changeCameragateway, changeCameraPlane } from '../../api/device.ts';
|
||||||
import utils from '../../lib/utils';
|
import utils from '../../lib/utils';
|
||||||
|
import AgoraRtcRoom from '../AgoraRtc.tsx';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
@@ -245,10 +246,18 @@ const DroneVideoPlayer: React.FC<DroneVideoPlayerProps> = ({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 视频内容 */}
|
|
||||||
{streamData ? (
|
{streamData ? (
|
||||||
<DroneLivePlayer streamData={streamData}
|
streamData?.url_type == "volc" ? (
|
||||||
/>
|
<DroneLivePlayer
|
||||||
|
key={streamData.url}
|
||||||
|
streamData={streamData}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<AgoraRtcRoom
|
||||||
|
key={streamData.url}
|
||||||
|
url={streamData.url}
|
||||||
|
/>
|
||||||
|
)
|
||||||
) : (
|
) : (
|
||||||
<div style={{
|
<div style={{
|
||||||
color: '#ccc',
|
color: '#ccc',
|
||||||
|
|||||||
Reference in New Issue
Block a user