From 8c4ae7532a409d4fbb5f8b73050a75cc7dff5865 Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Thu, 29 Aug 2024 14:09:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/Meeting/index.tsx | 28 ++++++++++++++++++---------- src/utils/package/agora.ts | 5 +++-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/page/Meeting/index.tsx b/src/page/Meeting/index.tsx index cdea0cf..ca71513 100644 --- a/src/page/Meeting/index.tsx +++ b/src/page/Meeting/index.tsx @@ -425,15 +425,15 @@ const Meeting: React.FC = () => { 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) - } + // 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; } }) @@ -512,7 +512,6 @@ const Meeting: React.FC = () => { } }, onUserJoined: async (info: any, remoteUid: any, _elapsed: any) => { - console.log(info, remoteUid, '远端'); if (info.channelId === state.channelId) { if (String(remoteUid).length === 9) { setIsShare(remoteUid) @@ -525,6 +524,15 @@ const Meeting: React.FC = () => { }) }, 1000); } + } else { + console.log(info, remoteUid, '远端'); + 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) => { diff --git a/src/utils/package/agora.ts b/src/utils/package/agora.ts index 0ced7ae..42e0084 100644 --- a/src/utils/package/agora.ts +++ b/src/utils/package/agora.ts @@ -228,10 +228,11 @@ export const agora = { { channelId: option.channelId + '1', localUid: Number('1' + option.screenShareId) }, {} ); - await agora.updateChannelMediaOptionsEx(false) + await agora.updateChannelMediaOptionsEx(true) }, updateChannelMediaOptionsEx: async (bool: boolean) => { - rtcEngine.updateChannelMediaOptionsEx({ + await agora.startCameraCapture() + await rtcEngine.updateChannelMediaOptionsEx({ clientRoleType: bool ? ClientRoleType.ClientRoleBroadcaster : ClientRoleType.ClientRoleAudience, //用户角色 ClientRoleBroadcaster 主播 ClientRoleAudience 观众 autoSubscribeAudio: false,//设置是否自动订阅所有音频流 autoSubscribeVideo: true,//设置是否自动订阅所有视频流