diff --git a/src/components/UserVideo/index.tsx b/src/components/UserVideo/index.tsx index fa27e9c..f843c96 100644 --- a/src/components/UserVideo/index.tsx +++ b/src/components/UserVideo/index.tsx @@ -62,10 +62,10 @@ const UserVideo: React.FC = () => { useEffect(() => { userList.forEach((item: any) => { - agora.setupRemoteVideoJoin({ + agora.setupRemoteVideoEx({ uid: Number('1' + item.screenShareId), view: document.getElementById(`video-${item.screenShareId}`), - channelId: state.channelId, + channelId: state.channelId + '1', }) }) }, [userList]) diff --git a/src/utils/package/agora.ts b/src/utils/package/agora.ts index 68b6255..2be8249 100644 --- a/src/utils/package/agora.ts +++ b/src/utils/package/agora.ts @@ -163,6 +163,20 @@ export const agora = { ); } }, + setupRemoteVideoEx: async (item: any) => { + if (item.view?.childNodes.length === 1) { + await rtcEngine.setupRemoteVideoEx( + { + renderMode: agora.getRrenderMode(item.uid), + sourceType: VideoSourceType.VideoSourceRemote, + uid: item.uid, + view: item.view, + setupMode: VideoViewSetupMode.VideoViewSetupAdd, + }, + { channelId: item.channelId }, + ); + } + }, // 退出 setupRemoteVideo: async (item: any) => { await rtcEngine.setupRemoteVideo( @@ -231,6 +245,7 @@ export const agora = { await agora.updateChannelMediaOptionsEx(false) }, updateChannelMediaOptionsEx: async (bool: boolean) => { + bool ? agora.startCameraCapture() : agora.stopCameraCapture(); rtcEngine.updateChannelMediaOptionsEx({ clientRoleType: bool ? ClientRoleType.ClientRoleBroadcaster : ClientRoleType.ClientRoleAudience, //用户角色 ClientRoleBroadcaster 主播 ClientRoleAudience 观众 autoSubscribeAudio: false,//设置是否自动订阅所有音频流