还原永久加入房间

This commit is contained in:
yj 2024-09-05 13:34:07 +08:00
parent eee2c11336
commit cd1f274644
2 changed files with 32 additions and 11 deletions

View File

@ -434,9 +434,9 @@ const Meeting: React.FC = () => {
if (userInfo.roleId !== '1') {
let userId = item.watchUids.find((uid: any) => uid === userInfo.uid)
if (userId) {
await agora.allJoinChannelEx()
agora.updateChannelMediaOptionsEx(true)
} else {
await agora.allLeaveChannelEx()
agora.updateChannelMediaOptionsEx(false)
}
}
break;
@ -567,10 +567,9 @@ const Meeting: React.FC = () => {
screenShareId: userInfo.screenShareId,
token: state.token,
tokenA: state.tokenA,
roleId: userInfo.roleId,
})
if (userInfo.roleId === '1') {
await agora.allJoinChannelEx(true)
}
await agora.allJoinChannelEx(false)
}
// 状态更新
const changeAgoraDevice = () => {

View File

@ -17,6 +17,7 @@ const option: any = {
channelId: '',
uid: '',
screenShareId: '',
roleId: '2',
}
let rtcEngine: any = '';
export const agora = {
@ -238,24 +239,44 @@ export const agora = {
);
},
// 所有用户加入的第二个房间
allJoinChannelEx: async (bool: boolean = false) => {
await agora.startCameraCapture()
allJoinChannelEx: async (bool: boolean) => {
await rtcEngine.joinChannelEx(
option.tokenA,
{ channelId: option.channelId + 'a', localUid: Number('1' + option.screenShareId) },
{
clientRoleType: bool ? ClientRoleType.ClientRoleAudience : ClientRoleType.ClientRoleBroadcaster, //用户角色 ClientRoleBroadcaster 主播 ClientRoleAudience 观众
}
);
agora.updateChannelMediaOptionsEx(bool)
},
// 更新第二个房间配置
updateChannelMediaOptionsEx: async (bool: boolean) => {
let obj;
if (bool) {
await agora.startCameraCapture()
obj = {
clientRoleType: ClientRoleType.ClientRoleBroadcaster, //用户角色 ClientRoleBroadcaster 主播 ClientRoleAudience 观众
autoSubscribeAudio: false,//设置是否自动订阅所有音频流
autoSubscribeVideo: true,//设置是否自动订阅所有视频流
autoSubscribeVideo: false,//设置是否自动订阅所有视频流
publishMicrophoneTrack: false,//设置是否发布麦克风采集到的音频
publishCameraTrack: true,//设置是否发布摄像头采集的视频
publishScreenTrack: false,//设置是否发布屏幕采集的视频
}
);
} else {
await agora.stopCameraCapture();
obj = {
clientRoleType: ClientRoleType.ClientRoleAudience, //用户角色 ClientRoleBroadcaster 主播 ClientRoleAudience 观众
autoSubscribeAudio: false,//设置是否自动订阅所有音频流
autoSubscribeVideo: option.roleId === '1',//设置是否自动订阅所有视频流
publishMicrophoneTrack: false,//设置是否发布麦克风采集到的音频
publishCameraTrack: false,//设置是否发布摄像头采集的视频
publishScreenTrack: false,//设置是否发布屏幕采集的视频
}
}
await rtcEngine.updateChannelMediaOptionsEx(obj, { channelId: option.channelId + 'a', localUid: Number('1' + option.screenShareId) })
},
// 退出第二个房间
allLeaveChannelEx: async () => {
await agora.stopCameraCapture();
await rtcEngine.leaveChannelEx({ channelId: option.channelId + 'a', localUid: Number('1' + option.screenShareId) })
},
// ai降噪
@ -300,6 +321,7 @@ export const agora = {
option.channelId = data.channelId;
option.uid = Number(data.uid);
option.screenShareId = data.screenShareId;
option.roleId = data.roleId;
await agora.joinChannel()
},
// 桌面捕获音频和视频的媒体源的信息