会议监控

This commit is contained in:
yj 2024-08-28 10:58:17 +08:00
parent 1a5a0ada94
commit 31eb6a4ba7
6 changed files with 82 additions and 55 deletions

View File

@ -1,7 +1,7 @@
// // 在 preload 脚本中。 // // 在 preload 脚本中。
const { default: createAgoraRtcEngine } = require('agora-electron-sdk') const { default: createAgoraRtcEngine } = require('agora-electron-sdk')
const { ipcRenderer } = require('electron') const { ipcRenderer } = require('electron')
let rtcEngine = createAgoraRtcEngine() let rtcEngine;
window.electron = { window.electron = {
// 设置窗口大小 // 设置窗口大小
setMainWindowSize: (config) => { setMainWindowSize: (config) => {
@ -71,7 +71,15 @@ window.electron = {
closeMonitorWindow: () => { closeMonitorWindow: () => {
ipcRenderer.invoke('closeMonitorWindow') ipcRenderer.invoke('closeMonitorWindow')
}, },
getrtcEngine: () => { // 获取rtcEngine
getRtcEngine: () => {
return rtcEngine return rtcEngine
}, },
// 设置rtcEngine
setRtcEngine: () => {
rtcEngine = createAgoraRtcEngine();
rtcEngine.initialize({
appId: 'dcfc466a6ecb4a1f972630065dfb1e75',
});
},
} }

View File

@ -150,7 +150,7 @@ const JoinSetting = forwardRef((_props: any, ref: any) => {
setJoinRoomSettingForm(list) setJoinRoomSettingForm(list)
if (index === 1) { if (index === 1) {
if (list[index].active) { if (list[index].active) {
agora.startPreview('videoPreview', Number(user.account)) agora.startPreview('videoPreview', Number(user.screenShareId))
} }
} }
} else { } else {

View File

@ -166,7 +166,7 @@ const VideoComponents = () => {
}) })
if (setting.videoDeviceId && list.length) { if (setting.videoDeviceId && list.length) {
await agora.setVideoDeviceManager(setting.videoDeviceId) await agora.setVideoDeviceManager(setting.videoDeviceId)
await agora.startPreview('videoPreview', Number(userInfo.account)) await agora.startPreview('videoPreview', Number(userInfo.screenShareId))
} }
}) })
} }

View File

@ -85,13 +85,13 @@ const Meeting: React.FC = () => {
active: false, active: false,
select: false, select: false,
}, },
// { {
// title: '会议监控', title: '会议监控',
// icon: ImageUrl.icon48, icon: ImageUrl.icon48,
// iconSelect: ImageUrl.icon48Select, iconSelect: ImageUrl.icon48Select,
// active: false, active: false,
// select: false, select: false,
// }, },
{ {
title: '录制', title: '录制',
icon: ImageUrl.icon27, icon: ImageUrl.icon27,
@ -188,6 +188,7 @@ const Meeting: React.FC = () => {
agora.init(true) agora.init(true)
agora.registerEventHandler({ agora.registerEventHandler({
onJoinChannelSuccess: async (info: any, _elapsed: any) => { onJoinChannelSuccess: async (info: any, _elapsed: any) => {
if (info.channelId === state.channelId) {
if (String(info.localUid).length !== 9) { if (String(info.localUid).length !== 9) {
await getJoin(state.enableMicr, state.enableCamera) await getJoin(state.enableMicr, state.enableCamera)
setTimeout(async () => { setTimeout(async () => {
@ -200,8 +201,10 @@ const Meeting: React.FC = () => {
getShowUser(); getShowUser();
}, 1000); }, 1000);
} }
}
}, },
onUserJoined: async (info: any, remoteUid: any, _elapsed: any) => { onUserJoined: async (info: any, remoteUid: any, _elapsed: any) => {
if (info.channelId === state.channelId) {
if (String(remoteUid).length === 9) { if (String(remoteUid).length === 9) {
setIsShare(remoteUid) setIsShare(remoteUid)
} else { } else {
@ -213,8 +216,10 @@ const Meeting: React.FC = () => {
}) })
}, 1000); }, 1000);
} }
}
}, },
onUserOffline: async (info: any, remoteUid: any, _reason: any) => { onUserOffline: async (info: any, remoteUid: any, _reason: any) => {
if (info.channelId === state.channelId) {
if (String(remoteUid).length === 9) { if (String(remoteUid).length === 9) {
setIsShare(null) setIsShare(null)
renderVideo() renderVideo()
@ -230,6 +235,7 @@ const Meeting: React.FC = () => {
} }
return res return res
}) })
}
}, },
onAudioVolumeIndication: async (speakers: any) => { onAudioVolumeIndication: async (speakers: any) => {
speakers.forEach((item: any) => { speakers.forEach((item: any) => {
@ -241,11 +247,15 @@ const Meeting: React.FC = () => {
}); });
} }
}) })
if (state.enableCamera) {
agora.startCameraCapture() agora.startCameraCapture()
}
agora.setJoinChannel({ agora.setJoinChannel({
channelId: state.channelId, channelId: state.channelId,
uid: userInfo.uid, uid: userInfo.uid,
screenShareId: userInfo.screenShareId,
token: state.token, token: state.token,
tokenA: state.tokenA,
}) })
storage.setItem('noViewChatList', 0) storage.setItem('noViewChatList', 0)
window.addEventListener('customStorageChange', handleCustomStorageChange); window.addEventListener('customStorageChange', handleCustomStorageChange);
@ -465,6 +475,18 @@ const Meeting: React.FC = () => {
pauseOnHover: false, pauseOnHover: false,
}); });
break; break;
// 管理员查看随机用户
case 'Watch':
if (userInfo.roleId !== '1') {
let userId = item.watchUids.find((uid: any) => uid === userInfo.uid)
if (userId) {
await agora.startCameraCapture()
} else {
await agora.stopCameraCapture();
}
agora.updateChannelMediaOptionsEx(userId ? true : false)
}
break;
} }
}) })
return () => { return () => {
@ -915,7 +937,7 @@ const Meeting: React.FC = () => {
break; break;
case '会议监控': case '会议监控':
window.electron.oepnWindow({ window.electron.oepnWindow({
url: location.origin + '/#/userVideo' url: location.origin + `/#/userVideo?channelId=${state.channelId + '1'}&token=${state.tokenA}`
}) })
break; break;
} }

3
src/render.d.ts vendored
View File

@ -16,8 +16,9 @@ export interface IElectronAPI {
quitAndInstall: (callBack: Function) => void; quitAndInstall: (callBack: Function) => void;
getVersion: () => Promise<string>; getVersion: () => Promise<string>;
oepnWindow: (data: any) => any; oepnWindow: (data: any) => any;
getRtcEngine: () => any;
setRtcEngine: () => any;
getrtcEngine: () => any;
closeMonitorWindow: () => void closeMonitorWindow: () => void
} }

View File

@ -1,5 +1,4 @@
import { import {
createAgoraRtcEngine,
ClientRoleType, ClientRoleType,
VideoSourceType, VideoSourceType,
VideoViewSetupMode, VideoViewSetupMode,
@ -10,7 +9,6 @@ import {
import { GetRoomRtcToken } from "@/api/Home/Index"; import { GetRoomRtcToken } from "@/api/Home/Index";
import { storage } from '@/utils'; import { storage } from '@/utils';
const option: any = { const option: any = {
appId: 'dcfc466a6ecb4a1f972630065dfb1e75',
token: '', token: '',
tokenA: '', tokenA: '',
channelId: '', channelId: '',
@ -21,10 +19,8 @@ let rtcEngine: any = '';
export const agora = { export const agora = {
// 初始化 // 初始化
init: async (bool: boolean = false) => { init: async (bool: boolean = false) => {
rtcEngine = createAgoraRtcEngine(); await window.electron.setRtcEngine()
await rtcEngine.initialize({ rtcEngine = window.electron.getRtcEngine()
appId: option.appId,
});
await agora.setDeviceManager(bool) await agora.setDeviceManager(bool)
}, },
// 获取rtcEngine // 获取rtcEngine