commit
1c0a2a9034
|
|
@ -1,7 +1,5 @@
|
||||||
// // 在 preload 脚本中。
|
// // 在 preload 脚本中。
|
||||||
const { default: createAgoraRtcEngine } = require('agora-electron-sdk')
|
|
||||||
const { ipcRenderer } = require('electron')
|
const { ipcRenderer } = require('electron')
|
||||||
let rtcEngine = createAgoraRtcEngine()
|
|
||||||
window.electron = {
|
window.electron = {
|
||||||
// 设置窗口大小
|
// 设置窗口大小
|
||||||
setMainWindowSize: (config) => {
|
setMainWindowSize: (config) => {
|
||||||
|
|
@ -70,8 +68,5 @@ window.electron = {
|
||||||
// 关闭会议监控窗口
|
// 关闭会议监控窗口
|
||||||
closeMonitorWindow: () => {
|
closeMonitorWindow: () => {
|
||||||
ipcRenderer.invoke('closeMonitorWindow')
|
ipcRenderer.invoke('closeMonitorWindow')
|
||||||
},
|
}
|
||||||
getrtcEngine: () => {
|
|
||||||
return rtcEngine
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
@ -185,68 +185,7 @@ const Meeting: React.FC = () => {
|
||||||
}
|
}
|
||||||
}, 1000)
|
}, 1000)
|
||||||
setMeetingMode('StandardMode');
|
setMeetingMode('StandardMode');
|
||||||
agora.init(true)
|
agoraInit()
|
||||||
agora.registerEventHandler({
|
|
||||||
onJoinChannelSuccess: async (info: any, _elapsed: any) => {
|
|
||||||
if (String(info.localUid).length !== 9) {
|
|
||||||
await getJoin(state.enableMicr, state.enableCamera)
|
|
||||||
setTimeout(async () => {
|
|
||||||
await agora.setupLocalVideo({
|
|
||||||
uid: Number(info.localUid),
|
|
||||||
view: document.getElementById(`video-${info.localUid}`),
|
|
||||||
channelId: info.channelId,
|
|
||||||
sourceType: VideoSourceType.VideoSourceCameraPrimary,
|
|
||||||
})
|
|
||||||
getShowUser();
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onUserJoined: async (info: any, remoteUid: any, _elapsed: any) => {
|
|
||||||
if (String(remoteUid).length === 9) {
|
|
||||||
setIsShare(remoteUid)
|
|
||||||
} else {
|
|
||||||
setTimeout(async () => {
|
|
||||||
await agora.setupRemoteVideoJoin({
|
|
||||||
uid: Number(remoteUid),
|
|
||||||
view: document.getElementById(`video-${remoteUid}`),
|
|
||||||
channelId: info.channelId,
|
|
||||||
})
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onUserOffline: async (info: any, remoteUid: any, _reason: any) => {
|
|
||||||
if (String(remoteUid).length === 9) {
|
|
||||||
setIsShare(null)
|
|
||||||
renderVideo()
|
|
||||||
}
|
|
||||||
await agora.setupRemoteVideo({
|
|
||||||
uid: Number(remoteUid),
|
|
||||||
view: null,
|
|
||||||
channelId: info.channelId,
|
|
||||||
});
|
|
||||||
setCurrentVideoId((res: any) => {
|
|
||||||
if (Number(res) === remoteUid) {
|
|
||||||
getShowUser();
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
},
|
|
||||||
onAudioVolumeIndication: async (speakers: any) => {
|
|
||||||
speakers.forEach((item: any) => {
|
|
||||||
let dom = document.getElementById(`micr-${item.uid ? item.uid : userInfo.uid}`);
|
|
||||||
if (dom) {
|
|
||||||
const percentage = (item.volume / 255) * 100
|
|
||||||
dom.style.width = `${percentage}%`
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
agora.startCameraCapture()
|
|
||||||
agora.setJoinChannel({
|
|
||||||
channelId: state.channelId,
|
|
||||||
uid: userInfo.uid,
|
|
||||||
token: state.token,
|
|
||||||
})
|
|
||||||
storage.setItem('noViewChatList', 0)
|
storage.setItem('noViewChatList', 0)
|
||||||
window.addEventListener('customStorageChange', handleCustomStorageChange);
|
window.addEventListener('customStorageChange', handleCustomStorageChange);
|
||||||
window.addEventListener('online', handleNetworkChange);
|
window.addEventListener('online', handleNetworkChange);
|
||||||
|
|
@ -465,6 +404,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 () => {
|
||||||
|
|
@ -520,6 +471,81 @@ const Meeting: React.FC = () => {
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}, [isClicked]);
|
}, [isClicked]);
|
||||||
|
|
||||||
|
// 声网初始化
|
||||||
|
const agoraInit = async () => {
|
||||||
|
await agora.init(true)
|
||||||
|
agora.registerEventHandler({
|
||||||
|
onJoinChannelSuccess: async (info: any, _elapsed: any) => {
|
||||||
|
if (info.channelId === state.channelId) {
|
||||||
|
if (String(info.localUid).length !== 9) {
|
||||||
|
await getJoin(state.enableMicr, state.enableCamera)
|
||||||
|
setTimeout(async () => {
|
||||||
|
await agora.setupLocalVideo({
|
||||||
|
uid: Number(info.localUid),
|
||||||
|
view: document.getElementById(`video-${info.localUid}`),
|
||||||
|
channelId: info.channelId,
|
||||||
|
sourceType: VideoSourceType.VideoSourceCameraPrimary,
|
||||||
|
})
|
||||||
|
getShowUser();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onUserJoined: async (info: any, remoteUid: any, _elapsed: any) => {
|
||||||
|
if (info.channelId === state.channelId) {
|
||||||
|
if (String(remoteUid).length === 9) {
|
||||||
|
setIsShare(remoteUid)
|
||||||
|
} else {
|
||||||
|
setTimeout(async () => {
|
||||||
|
await agora.setupRemoteVideoJoin({
|
||||||
|
uid: Number(remoteUid),
|
||||||
|
view: document.getElementById(`video-${remoteUid}`),
|
||||||
|
channelId: info.channelId,
|
||||||
|
})
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onUserOffline: async (info: any, remoteUid: any, _reason: any) => {
|
||||||
|
if (info.channelId === state.channelId) {
|
||||||
|
if (String(remoteUid).length === 9) {
|
||||||
|
setIsShare(null)
|
||||||
|
renderVideo()
|
||||||
|
}
|
||||||
|
await agora.setupRemoteVideo({
|
||||||
|
uid: Number(remoteUid),
|
||||||
|
view: null,
|
||||||
|
channelId: info.channelId,
|
||||||
|
});
|
||||||
|
setCurrentVideoId((res: any) => {
|
||||||
|
if (Number(res) === remoteUid) {
|
||||||
|
getShowUser();
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onAudioVolumeIndication: async (speakers: any) => {
|
||||||
|
speakers.forEach((item: any) => {
|
||||||
|
let dom = document.getElementById(`micr-${item.uid ? item.uid : userInfo.uid}`);
|
||||||
|
if (dom) {
|
||||||
|
const percentage = (item.volume / 255) * 100
|
||||||
|
dom.style.width = `${percentage}%`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (state.enableCamera) {
|
||||||
|
agora.startCameraCapture()
|
||||||
|
}
|
||||||
|
agora.setJoinChannel({
|
||||||
|
channelId: state.channelId,
|
||||||
|
uid: userInfo.uid,
|
||||||
|
screenShareId: userInfo.screenShareId,
|
||||||
|
token: state.token,
|
||||||
|
// tokenA: state.tokenA,
|
||||||
|
})
|
||||||
|
}
|
||||||
// 状态更新
|
// 状态更新
|
||||||
const changeAgoraDevice = () => {
|
const changeAgoraDevice = () => {
|
||||||
setRoomUserList((res: any) => {
|
setRoomUserList((res: any) => {
|
||||||
|
|
@ -915,7 +941,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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ export interface IElectronAPI {
|
||||||
getVersion: () => Promise<string>;
|
getVersion: () => Promise<string>;
|
||||||
oepnWindow: (data: any) => any;
|
oepnWindow: (data: any) => any;
|
||||||
|
|
||||||
getrtcEngine: () => any;
|
|
||||||
closeMonitorWindow: () => void
|
closeMonitorWindow: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue