This commit is contained in:
yj 2024-08-28 15:01:46 +08:00
parent f6539d30f8
commit 5a30d69cc8
2 changed files with 31 additions and 15 deletions

View File

@ -174,6 +174,7 @@ const Meeting: React.FC = () => {
const msgTips = '您不是管理员或发言人,无法开启此功能!' const msgTips = '您不是管理员或发言人,无法开启此功能!'
useEffect(() => { useEffect(() => {
let time: NodeJS.Timeout; let time: NodeJS.Timeout;
let getDesktopCapturerVideoTime: NodeJS.Timeout;
setUser(userInfo) setUser(userInfo)
setTimeout(() => { setTimeout(() => {
if (location.hash.indexOf('/login') === -1) { if (location.hash.indexOf('/login') === -1) {
@ -193,11 +194,28 @@ const Meeting: React.FC = () => {
time = setInterval(() => { time = setInterval(() => {
setCurrentSeconds(currentSeconds++) setCurrentSeconds(currentSeconds++)
}, 1000) }, 1000)
getDesktopCapturerVideoTime = setInterval(() => {
setSharedScreenItem((i: any) => {
if (i) {
agora.getDesktopCapturerVideo({ width: 0, height: 0 }, { width: 0, height: 0 }, false).then(res => {
if (res.length) {
let row = res.find((item: any) => item.sourceId === i.sourceId)
if (!row) {
stopScreenCapture()
setSharedScreenItem('')
}
}
})
}
return i
})
}, 3000)
return () => { return () => {
window.removeEventListener('customStorageChange', handleCustomStorageChange); window.removeEventListener('customStorageChange', handleCustomStorageChange);
window.removeEventListener('online', handleNetworkChange); window.removeEventListener('online', handleNetworkChange);
window.removeEventListener('offline', handleNetworkChange); window.removeEventListener('offline', handleNetworkChange);
clearInterval(time) clearInterval(time)
clearInterval(getDesktopCapturerVideoTime)
}; };
}, []); }, []);
@ -983,8 +1001,7 @@ const Meeting: React.FC = () => {
} }
// 获取桌面可共享屏幕的引用 // 获取桌面可共享屏幕的引用
const getDesktopCapturerVideo = (): void => { const getDesktopCapturerVideo = (): void => {
agora.getDesktopCapturerVideo().then((res: any) => { agora.getDesktopCapturerVideo({ width: 300, height: 300 }, { width: 300, height: 300 }, true).then((res: any) => {
if (sharedScreenList.length !== res.length) {
res.forEach((item: any) => { res.forEach((item: any) => {
if (item.thumbImage.buffer) { if (item.thumbImage.buffer) {
item.thumbnailUrl = thumbImageBufferToBase64(item.thumbImage) item.thumbnailUrl = thumbImageBufferToBase64(item.thumbImage)
@ -994,7 +1011,6 @@ const Meeting: React.FC = () => {
} }
}) })
setSharedScreenList(res) setSharedScreenList(res)
}
}) })
}; };
// 设置全员看谁 // 设置全员看谁

View File

@ -287,8 +287,8 @@ export const agora = {
} }
}, },
// 桌面捕获音频和视频的媒体源的信息 // 桌面捕获音频和视频的媒体源的信息
getDesktopCapturerVideo: async () => { getDesktopCapturerVideo: async (thumbSize: any, iconSize: any, includeScreen: boolean) => {
return rtcEngine.getScreenCaptureSources({ width: 300, height: 300 }, { width: 300, height: 300 }, true); return await rtcEngine.getScreenCaptureSources(thumbSize, iconSize, includeScreen);
}, },
// 共享屏幕采集 // 共享屏幕采集
setDesktopCapturerVideo: async (targetSource: any, isComputerAudio: boolean, isFluencyPriority: boolean) => { setDesktopCapturerVideo: async (targetSource: any, isComputerAudio: boolean, isFluencyPriority: boolean) => {