This commit is contained in:
yj 2024-07-17 11:47:29 +08:00
parent 05fb261275
commit fc4cbb13d8
2 changed files with 9 additions and 8 deletions

View File

@ -14,7 +14,6 @@ import StupWizard from '@/components/StupWizard';
import { onInvoke, onSignalr } from '@/utils/package/signalr'; import { onInvoke, onSignalr } from '@/utils/package/signalr';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import durationPlugin from 'dayjs/plugin/duration'; import durationPlugin from 'dayjs/plugin/duration';
import { VideoSourceType } from 'agora-electron-sdk';
dayjs.extend(durationPlugin); dayjs.extend(durationPlugin);
const { Column } = Table const { Column } = Table
const Meeting: React.FC = () => { const Meeting: React.FC = () => {
@ -112,13 +111,13 @@ const Meeting: React.FC = () => {
let [currentSeconds, setCurrentSeconds] = useState(0) let [currentSeconds, setCurrentSeconds] = useState(0)
const [currentEffective, setCurrentEffective] = useState(0) const [currentEffective, setCurrentEffective] = useState(0)
const [list] = useState<number[]>([1, 2, 3, 4, 5, 6, 7])
const [open, setOpen] = useState(false) const [open, setOpen] = useState(false)
useEffect(() => { useEffect(() => {
let time = null as any; let time = null as any;
if (isInit) { if (isInit) {
let userInfo = JSON.parse(storage.getItem('user') as string) let userInfo = JSON.parse(storage.getItem('user') as string)
agora.init() agora.init()
agora.setCameraCapture(VideoSourceType.VideoSourceCameraPrimary)
agora.setJoinChannel({ agora.setJoinChannel({
channelId: state.channelId, channelId: state.channelId,
userid: userInfo.account, userid: userInfo.account,
@ -188,7 +187,7 @@ const Meeting: React.FC = () => {
}, []) }, [])
useEffect(() => { useEffect(() => {
console.log(currentVideoId);
}, [currentVideoId]) }, [currentVideoId])
// 加入房间时间 // 加入房间时间
@ -224,7 +223,7 @@ const Meeting: React.FC = () => {
setIsSharedScreenModal(true) setIsSharedScreenModal(true)
break; break;
case '停止共享': case '停止共享':
agora.setCameraCapture(VideoSourceType.VideoSourceCameraPrimary) agora.stopScreenCapture()
footerListTemplate[itemIndex][rowIndex].title = '共享屏幕' footerListTemplate[itemIndex][rowIndex].title = '共享屏幕'
break; break;
case '关闭声音': case '关闭声音':
@ -289,7 +288,7 @@ const Meeting: React.FC = () => {
const footerListTemplate = [...footerList] const footerListTemplate = [...footerList]
footerListTemplate[footerListIndex.itemIndex][footerListIndex.rowIndex].title = '停止共享' footerListTemplate[footerListIndex.itemIndex][footerListIndex.rowIndex].title = '停止共享'
setIsSharedScreenModal(false) setIsSharedScreenModal(false)
agora.setDesktopCapturerVideo(sharedScreenItem, VideoSourceType.VideoSourceScreen) agora.setDesktopCapturerVideo(sharedScreenItem)
} else { } else {
message.error('请选择应用!') message.error('请选择应用!')
} }

View File

@ -153,14 +153,16 @@ const agora = {
rtcEngine.muteLocalVideoStream(mute) rtcEngine.muteLocalVideoStream(mute)
}, },
// 摄像头采集 // 摄像头采集
setCameraCapture:async (sourceType: number) => { setCameraCapture: () => {
await rtcEngine.startCameraCapture(VideoSourceType.VideoSourceCamera, {}) rtcEngine.startCameraCapture(VideoSourceType.VideoSourceCamera, {})
agora.joinChannel(false)
}, },
// 加入频道 // 加入频道
setJoinChannel: (data: any) => { setJoinChannel: (data: any) => {
option.token = data.token; option.token = data.token;
option.channelId = data.channelId; option.channelId = data.channelId;
option.userid = Number(data.userid); option.userid = Number(data.userid);
rtcEngine.startCameraCapture(VideoSourceType.VideoSourceCamera, {})
agora.joinChannel(false) agora.joinChannel(false)
}, },
// 桌面捕获音频和视频的媒体源的信息 // 桌面捕获音频和视频的媒体源的信息
@ -168,7 +170,7 @@ const agora = {
return rtcEngine.getScreenCaptureSources({ width: 300, height: 300 }, { width: 300, height: 300 }, true); return rtcEngine.getScreenCaptureSources({ width: 300, height: 300 }, { width: 300, height: 300 }, true);
}, },
// 共享屏幕采集 // 共享屏幕采集
setDesktopCapturerVideo: (targetSource: any, sourceType: number) => { setDesktopCapturerVideo: (targetSource: any) => {
// rtcEngine.stopCameraCapture(VideoSourceType.VideoSourceCamera); // rtcEngine.stopCameraCapture(VideoSourceType.VideoSourceCamera);
agora.stopScreenCapture(); agora.stopScreenCapture();
if ( if (