装备 完善
This commit is contained in:
34
src/components/droneplayer.jsx
Normal file
34
src/components/droneplayer.jsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import VERTC, { RoomProfileType, StreamIndex } from "@volcengine/rtc";
|
||||
|
||||
let engine;
|
||||
|
||||
export async function joinRoom(container, appId, roomId, token, userId) {
|
||||
console.info('joinRoom...');
|
||||
|
||||
const engine = VERTC.createEngine(appId);
|
||||
|
||||
await engine.joinRoom(token, roomId, { userId }, {
|
||||
isAutoPublish: true,
|
||||
isAutoSubscribeAudio: true,
|
||||
isAutoSubscribeVideo: true,
|
||||
roomProfileType: RoomProfileType.meeting,
|
||||
});
|
||||
|
||||
engine.on(VERTC.events.onUserPublishStream, async (e) => {
|
||||
if (!container) return;
|
||||
|
||||
// 清空旧内容
|
||||
container.innerHTML = '';
|
||||
|
||||
await engine.setUserVisibility(false);
|
||||
engine.setRemoteVideoPlayer(StreamIndex.STREAM_INDEX_MAIN, {
|
||||
userId: e.userId,
|
||||
renderDom: container,
|
||||
visible: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function leaveRoom() {
|
||||
if (engine) await engine.leaveRoom();
|
||||
}
|
||||
Reference in New Issue
Block a user