This commit is contained in:
yj 2024-08-30 09:30:02 +08:00
parent 1d857aa7cc
commit af97c97f6a
2 changed files with 15 additions and 18 deletions

View File

@ -429,10 +429,11 @@ const Meeting: React.FC = () => {
let userId = item.watchUids.find((uid: any) => uid === userInfo.uid)
if (userId) {
await agora.startCameraCapture()
await agora.allJoinChannelEx()
} else {
await agora.stopCameraCapture();
await agora.allLeaveChannelEx()
}
agora.updateChannelMediaOptionsEx(userId ? true : false)
}
break;
}

View File

@ -240,22 +240,19 @@ export const agora = {
await rtcEngine.joinChannelEx(
option.tokenA,
{ channelId: option.channelId + '1', localUid: Number('1' + option.screenShareId) },
{}
{
clientRoleType: ClientRoleType.ClientRoleBroadcaster, //用户角色 ClientRoleBroadcaster 主播 ClientRoleAudience 观众
autoSubscribeAudio: false,//设置是否自动订阅所有音频流
autoSubscribeVideo: true,//设置是否自动订阅所有视频流
publishMicrophoneTrack: false,//设置是否发布麦克风采集到的音频
publishCameraTrack: true,//设置是否发布摄像头采集的视频
publishScreenTrack: false,//设置是否发布屏幕采集的视频
}
);
await agora.updateChannelMediaOptionsEx(false)
},
updateChannelMediaOptionsEx: async (bool: boolean) => {
rtcEngine.updateChannelMediaOptionsEx({
clientRoleType: bool ? ClientRoleType.ClientRoleBroadcaster : ClientRoleType.ClientRoleAudience, //用户角色 ClientRoleBroadcaster 主播 ClientRoleAudience 观众
autoSubscribeAudio: false,//设置是否自动订阅所有音频流
autoSubscribeVideo: true,//设置是否自动订阅所有视频流
publishMicrophoneTrack: false,//设置是否发布麦克风采集到的音频
publishCameraTrack: true,//设置是否发布摄像头采集的视频
publishScreenTrack: false,//设置是否发布屏幕采集的视频
}, {
channelId: option.channelId + '1',
localUid: Number('1' + option.screenShareId)
})
// 退出第二个房间
allLeaveChannelEx: async () => {
await rtcEngine.leaveChannelEx({ channelId: option.channelId + '1', localUid: Number('1' + option.screenShareId) })
},
// 离开共享屏幕频道
leaveChannelEx: async (uid: any) => {
@ -276,6 +273,7 @@ export const agora = {
},
// 摄像头采集
startCameraCapture: async () => {
console.log(1);
await rtcEngine.startCameraCapture(VideoSourceType.VideoSourceCamera, {
format: {
width: 640,
@ -286,6 +284,7 @@ export const agora = {
},
// 停止采集摄像头
stopCameraCapture: async () => {
console.log(2);
await rtcEngine.stopCameraCapture()
},
// 加入频道
@ -296,9 +295,6 @@ export const agora = {
option.uid = Number(data.uid);
option.screenShareId = data.screenShareId;
await agora.joinChannel()
if (data.tokenA) {
await agora.allJoinChannelEx()
}
},
// 桌面捕获音频和视频的媒体源的信息
getDesktopCapturerVideo: async (thumbSize: any, iconSize: any, includeScreen: boolean) => {