使用 RealtimeKit 主持人控制来管理实时会话中的其他参与者。您可以使音频或视频静音、置顶参与者,或将参与者从会话中移除。 这些操作需要本地参与者的 预设 中启用特定的主持人控制权限。 在显示 UI 控件或调用这些方法之前,请验证本地参与者是否具有必要的权限。 在本指南中,本地参与者是指执行操作的用户。
要对特定参与者执行操作,您首先需要检索其参与者对象。
远程参与者(其他参与者)可在 meeting.participants 中获取。本地参与者可在 meeting.self 中获取。
有关详细信息,请参阅会议对象详解。
const joinedParticipants = meeting.participants.joined.toArray();
const participant = joinedParticipants[0];
if (!participant) {
// 当前没有远程参与者加入。
}要对特定参与者执行操作,您首先需要检索其参与者对象。
远程参与者(其他参与者)可在 meeting.participants 中获取。本地参与者可在 meeting.self 中获取。
有关详细信息,请参阅会议对象详解。
const joinedParticipants = meeting.participants.joined.toArray();
const participant = joinedParticipants[0];
if (!participant) {
// 当前没有远程参与者加入。
}要对特定参与者执行操作,您首先需要检索其参与者对象。
远程参与者(其他参与者)可在 meeting.participants 中获取。本地参与者可在 meeting.self 中获取。
有关详细信息,请参阅会议对象详解。
const joinedParticipants = meeting.participants.joined.toArray();
const participant = joinedParticipants[0];
if (!participant) {
// 当前没有远程参与者加入。
}要对特定参与者执行操作,请从 participants 属性中检索其参与者对象。
远程参与者在 meeting.participants.joined 中可用。本地参与者在 meeting.localUser 中可用。
val joinedParticipants = meeting.participants.joined
val participant = joinedParticipants.firstOrNull()
if (participant == null) {
// 当前没有远程参与者加入。
}要对特定参与者执行操作,请从 participants 属性中检索其参与者对象。
远程参与者在 meeting.participants.joined 中可用。本地参与者在 meeting.localUser 中可用。
let joinedParticipants = meeting.participants.joined
guard let participant = joinedParticipants.first else {
// 当前没有远程参与者加入。
return
}要对特定参与者执行操作,请从 participants 属性中检索其参与者对象。
远程参与者在 meeting.participants.joined 中可用。本地参与者在 meeting.localUser 中可用。
final joinedParticipants = meeting.participants.joined;
final participant = joinedParticipants.firstOrNull;
if (participant == null) {
// 当前没有远程参与者加入。
}要对特定参与者执行操作,请从 participants 属性中检索其参与者对象。
远程参与者在 meeting.participants.joined 中可用。本地参与者在 meeting.self 中可用。
const joinedParticipants = meeting.participants.joined;
const participant = joinedParticipants.toArray()[0];
if (!participant) {
// 当前没有远程参与者加入。
}或者使用 useRealtimeKitSelector hook:
import { useRealtimeKitSelector } from '@cloudflare/realtimekit-react-native';
const joinedParticipants = useRealtimeKitSelector((m) => m.participants.joined);当您需要管理背景噪音、主持课堂或网络研讨会或防止会话期间的中断时,可以静音参与者的音频。
此操作需要本地参与者的预设中启用 **Mute Audio(disable_participant_audio)**主持人控制权限。
要静音特定参与者的音频:
-
检查本地参与者是否有权限将其他参与者的音频静音。
const canMuteAudio = meeting.self.permissions.canDisableParticipantAudio === true; if (!canMuteAudio) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
disableAudio()。如果本地参与者没有所需权限,
disableAudio()会抛出一个错误代码为1201的ClientError。try { await participant.disableAudio(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有将其他参与者音频静音的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,目标参与者的
audioEnabled会变为false,并且 SDK 会触发audioUpdate事件。选项 A:在参与者对象上进行监听
participant.on("audioUpdate", ({ audioEnabled, audioTrack }) => { // audioEnabled 为 false // 更新该参与者的 UI });选项 B:在
joined映射上进行监听meeting.participants.joined.on( "audioUpdate", (participant, { audioEnabled, audioTrack }) => { if (participant.id === targetParticipantId) { // audioEnabled 为 false // 更新该参与者的 UI } }, );
-
检查本地参与者是否有权限将其他参与者的音频静音。
const canMuteAudio = meeting.self.permissions.canDisableParticipantAudio === true; if (!canMuteAudio) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
disableAudio()。如果本地参与者没有所需权限,
disableAudio()会抛出一个错误代码为1201的ClientError。try { await participant.disableAudio(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有将其他参与者音频静音的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,目标参与者的
audioEnabled会变为false,并且 SDK 会触发audioUpdate事件。选项 A:在参与者对象上进行监听
participant.on("audioUpdate", ({ audioEnabled, audioTrack }) => { // audioEnabled 为 false // 更新该参与者的 UI });选项 B:在
joined映射上进行监听meeting.participants.joined.on( "audioUpdate", (participant, { audioEnabled, audioTrack }) => { if (participant.id === targetParticipantId) { // audioEnabled 为 false // 更新该参与者的 UI } }, );
-
检查本地参与者是否有权限将其他参与者的音频静音。
const canMuteAudio = meeting.self.permissions.canDisableParticipantAudio === true; if (!canMuteAudio) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
disableAudio()。如果本地参与者没有所需权限,
disableAudio()会抛出一个错误代码为1201的ClientError。try { await participant.disableAudio(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有将其他参与者音频静音的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,目标参与者的
audioEnabled会变为false,并且 SDK 会触发audioUpdate事件。选项 A:在参与者对象上进行监听
participant.on("audioUpdate", ({ audioEnabled, audioTrack }) => { // audioEnabled 为 false // 更新该参与者的 UI });选项 B:在
joined映射上进行监听meeting.participants.joined.on( "audioUpdate", (participant, { audioEnabled, audioTrack }) => { if (participant.id === targetParticipantId) { // audioEnabled 为 false // 更新该参与者的 UI } }, );
- 检查本地参与者是否具有静音其他参与者音频的权限。
val canMuteAudio = meeting.localUser.permissions.host.canMuteAudio
if (!canMuteAudio) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
disableAudio()。如果本地参与者没有所需的权限,disableAudio()将返回HostError。
val error = participant.disableAudio()
if (error != null) {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,目标参与者的
audioEnabled变为false。
meeting.addParticipantsEventListener(object : RtkParticipantsEventListener {
override fun onAudioUpdate(participant: RtkRemoteParticipant, isEnabled: Boolean) {
// audioEnabled 为 false
// 更新该参与者的 UI
}
})- 检查本地参与者是否具有静音其他参与者音频的权限。
let canMuteAudio = meeting.localUser.permissions.host.canMuteAudio
if !canMuteAudio {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
disableAudio()。如果本地参与者没有所需的权限,disableAudio()将返回HostError。
if let error = participant.disableAudio() {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,目标参与者的
audioEnabled变为false。
extension MeetingViewModel: RtkParticipantsEventListener {
func onAudioUpdate(participant: RtkRemoteParticipant, isEnabled: Bool) {
// audioEnabled 为 false
// 更新该参与者的 UI
}
}
// 注册监听器
meeting.addParticipantsEventListener(participantsEventListener: self)- 检查本地参与者是否具有静音其他参与者音频的权限。
final canMuteAudio = meeting.localUser.permissions.host.canMuteAudio;
if (!canMuteAudio) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
disableAudio()。
participant.disableAudio(
onResult: (error) {
if (error != null) {
// 处理错误 - 权限被拒绝或其他问题。
return;
}
// 音频已成功静音。
},
);- 通过监听更新来处理结果。调用成功后,目标参与者的
audioEnabled变为false。
class ParticipantsEventsListener extends RtkParticipantsEventListener {
@override
void onAudioUpdate(RtkRemoteParticipant participant, bool isEnabled) {
// audioEnabled 为 false
// 更新该参与者的 UI
}
}
// 注册监听器
meeting.addParticipantsEventListener(ParticipantsEventsListener());- 检查本地参与者是否具有静音其他参与者音频的权限。
const canDisableParticipantAudio = meeting.self.permissions.canDisableParticipantAudio;
if (!canDisableParticipantAudio) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
disableAudio()。
participant
.disableAudio()
.catch((err) => {
// 处理错误 - 权限被拒绝或其他问题。
console.log(err);
});- 通过监听更新来处理结果。调用成功后,目标参与者的
audioEnabled变为false。
meeting.participants.joined.on('audioUpdate', (participant) => {
// participant.audioEnabled 为 false
// 更新该参与者的 UI
});这会影响所有参与者,包括本地参与者。要静音会话中所有参与者的音频:
-
检查本地参与者是否有权限将其他参与者的音频静音。
const canMuteAudio = meeting.self.permissions.canDisableParticipantAudio === true; if (!canMuteAudio) { // 在您的 UI 中禁用此控件。 } -
调用
disableAllAudio()。如果本地参与者没有所需权限,
disableAllAudio()会抛出一个错误代码为1201的ClientError。try { await meeting.participants.disableAllAudio(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有将其他参与者音频静音的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,每个参与者的
audioEnabled都会变为false,且 SDK 会触发audioUpdate事件。 本地参与者也会在meeting.self上接收到audioUpdate。在
joined映射上监听远程参与者更新:meeting.participants.joined.on( "audioUpdate", (participant, { audioEnabled, audioTrack }) => { // audioEnabled 为 false // 更新该参与者的 UI }, );在
meeting.self上监听本地参与者更新:meeting.self.on("audioUpdate", ({ audioEnabled, audioTrack }) => { // audioEnabled 为 false // 更新本地参与者的 UI });
-
检查本地参与者是否有权限将其他参与者的音频静音。
const canMuteAudio = meeting.self.permissions.canDisableParticipantAudio === true; if (!canMuteAudio) { // 在您的 UI 中禁用此控件。 } -
调用
disableAllAudio()。如果本地参与者没有所需权限,
disableAllAudio()会抛出一个错误代码为1201的ClientError。try { await meeting.participants.disableAllAudio(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有将其他参与者音频静音的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,每个参与者的
audioEnabled都会变为false,且 SDK 会触发audioUpdate事件。 本地参与者也会在meeting.self上接收到audioUpdate。在
joined映射上监听远程参与者更新:meeting.participants.joined.on( "audioUpdate", (participant, { audioEnabled, audioTrack }) => { // audioEnabled 为 false // 更新该参与者的 UI }, );在
meeting.self上监听本地参与者更新:meeting.self.on("audioUpdate", ({ audioEnabled, audioTrack }) => { // audioEnabled 为 false // 更新本地参与者的 UI });
-
检查本地参与者是否有权限将其他参与者的音频静音。
const canMuteAudio = meeting.self.permissions.canDisableParticipantAudio === true; if (!canMuteAudio) { // 在您的 UI 中禁用此控件。 } -
调用
disableAllAudio()。如果本地参与者没有所需权限,
disableAllAudio()会抛出一个错误代码为1201的ClientError。try { await meeting.participants.disableAllAudio(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有将其他参与者音频静音的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,每个参与者的
audioEnabled都会变为false,且 SDK 会触发audioUpdate事件。 本地参与者也会在meeting.self上接收到audioUpdate。在
joined映射上监听远程参与者更新:meeting.participants.joined.on( "audioUpdate", (participant, { audioEnabled, audioTrack }) => { // audioEnabled 为 false // 更新该参与者的 UI }, );在
meeting.self上监听本地参与者更新:meeting.self.on("audioUpdate", ({ audioEnabled, audioTrack }) => { // audioEnabled 为 false // 更新本地参与者的 UI });
- 检查本地参与者是否具有静音其他参与者音频的权限。
val canMuteAudio = meeting.localUser.permissions.host.canMuteAudio
if (!canMuteAudio) {
// 在您的 UI 中禁用该控件。
}- 在 participants 对象上调用
disableAllAudio()。如果本地参与者没有所需的权限,disableAllAudio()将返回HostError。
val error = meeting.participants.disableAllAudio()
if (error != null) {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,每个参与者的
audioEnabled变为false。
meeting.addParticipantsEventListener(object : RtkParticipantsEventListener {
override fun onAudioUpdate(participant: RtkRemoteParticipant, isEnabled: Boolean) {
// audioEnabled 为 false
// 更新该参与者的 UI
}
})- 检查本地参与者是否具有静音其他参与者音频的权限。
let canMuteAudio = meeting.localUser.permissions.host.canMuteAudio
if !canMuteAudio {
// 在您的 UI 中禁用该控件。
}- 在 participants 对象上调用
disableAllAudio()。如果本地参与者没有所需的权限,disableAllAudio()将返回HostError。
if let error = meeting.participants.disableAllAudio() {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,每个参与者的
audioEnabled变为false。
extension MeetingViewModel: RtkParticipantsEventListener {
func onAudioUpdate(participant: RtkRemoteParticipant, isEnabled: Bool) {
// audioEnabled 为 false
// 更新该参与者的 UI
}
}
// 注册监听器
meeting.addParticipantsEventListener(participantsEventListener: self)- 检查本地参与者是否具有静音其他参与者音频的权限。
final canMuteAudio = meeting.localUser.permissions.host.canMuteAudio;
if (!canMuteAudio) {
// 在您的 UI 中禁用该控件。
}- 在 participants 对象上调用
disableAllAudio()。
meeting.participants.disableAllAudio(
onResult: (error) {
if (error != null) {
// 处理错误 - 权限被拒绝或其他问题。
return;
}
// 所有音频已成功静音。
},
);- 通过监听更新来处理结果。调用成功后,每个参与者的
audioEnabled变为false。
class ParticipantsEventsListener extends RtkParticipantsEventListener {
@override
void onAudioUpdate(RtkRemoteParticipant participant, bool isEnabled) {
// audioEnabled 为 false
// 更新该参与者的 UI
}
}
// 注册监听器
meeting.addParticipantsEventListener(ParticipantsEventsListener());- 检查本地参与者是否具有静音其他参与者音频的权限。
const canDisableParticipantAudio = meeting.self.permissions.canDisableParticipantAudio;
if (!canDisableParticipantAudio) {
// 在您的 UI 中禁用该控件。
}- 在 participants 对象上调用
disableAllAudio()。
meeting.participants
.disableAllAudio(true)
.catch((err) => {
// 处理错误 - 权限被拒绝或其他问题。
console.log(err);
});- 通过监听更新来处理结果。调用成功后,每个参与者的
audioEnabled变为false。
meeting.participants.joined.on('audioUpdate', (participant) => {
// participant.audioEnabled 为 false
// 更新该参与者的 UI
});当您需要主持会话、实施隐私保护或在课堂或网络研讨会期间防止出现不想要的视频时,可以禁用参与者的视频。
此操作需要本地参与者的预设中启用 **Mute Video(disable_participant_video)**主持人控制权限。
要禁用特定参与者的视频:
-
检查本地参与者是否有权限禁用其他参与者的视频。
const canDisableVideo = meeting.self.permissions.canDisableParticipantVideo === true; if (!canDisableVideo) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
disableVideo()。如果本地参与者没有所需权限,
disableVideo()会抛出一个错误代码为1201的ClientError。try { await participant.disableVideo(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有禁用其他参与者视频的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,目标参与者的
videoEnabled会变为false,并且 SDK 会触发videoUpdate事件。选项 A:在参与者对象上进行监听
participant.on("videoUpdate", ({ videoEnabled, videoTrack }) => { // videoEnabled 为 false // 更新该参与者的 UI });选项 B:在
joined映射上进行监听meeting.participants.joined.on( "videoUpdate", (participant, { videoEnabled, videoTrack }) => { // videoEnabled 为 false // 更新该参与者的 UI }, );
-
检查本地参与者是否有权限禁用其他参与者的视频。
const canDisableVideo = meeting.self.permissions.canDisableParticipantVideo === true; if (!canDisableVideo) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
disableVideo()。如果本地参与者没有所需权限,
disableVideo()会抛出一个错误代码为1201的ClientError。try { await participant.disableVideo(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有禁用其他参与者视频的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,目标参与者的
videoEnabled会变为false,并且 SDK 会触发videoUpdate事件。选项 A:在参与者对象上进行监听
participant.on("videoUpdate", ({ videoEnabled, videoTrack }) => { // videoEnabled 为 false // 更新该参与者的 UI });选项 B:在
joined映射上进行监听meeting.participants.joined.on( "videoUpdate", (participant, { videoEnabled, videoTrack }) => { // videoEnabled 为 false // 更新该参与者的 UI }, );
-
检查本地参与者是否有权限禁用其他参与者的视频。
const canDisableVideo = meeting.self.permissions.canDisableParticipantVideo === true; if (!canDisableVideo) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
disableVideo()。如果本地参与者没有所需权限,
disableVideo()会抛出一个错误代码为1201的ClientError。try { await participant.disableVideo(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有禁用其他参与者视频的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,目标参与者的
videoEnabled会变为false,并且 SDK 会触发videoUpdate事件。选项 A:在参与者对象上进行监听
participant.on("videoUpdate", ({ videoEnabled, videoTrack }) => { // videoEnabled 为 false // 更新该参与者的 UI });选项 B:在
joined映射上进行监听meeting.participants.joined.on( "videoUpdate", (participant, { videoEnabled, videoTrack }) => { // videoEnabled 为 false // 更新该参与者的 UI }, );
- 检查本地参与者是否具有禁用其他参与者视频的权限。
val canMuteVideo = meeting.localUser.permissions.host.canMuteVideo
if (!canMuteVideo) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
disableVideo()。如果本地参与者没有所需的权限,disableVideo()将返回HostError。
val error = participant.disableVideo()
if (error != null) {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,目标参与者的
videoEnabled变为false。
meeting.addParticipantsEventListener(object : RtkParticipantsEventListener {
override fun onVideoUpdate(participant: RtkRemoteParticipant, isEnabled: Boolean) {
// videoEnabled 为 false
// 更新该参与者的 UI
}
})- 检查本地参与者是否具有禁用其他参与者视频的权限。
let canMuteVideo = meeting.localUser.permissions.host.canMuteVideo
if !canMuteVideo {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
disableVideo()。如果本地参与者没有所需的权限,disableVideo()将返回HostError。
if let error = participant.disableVideo() {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,目标参与者的
videoEnabled变为false。
extension MeetingViewModel: RtkParticipantsEventListener {
func onVideoUpdate(participant: RtkRemoteParticipant, isEnabled: Bool) {
// videoEnabled 为 false
// 更新该参与者的 UI
}
}
// 注册监听器
meeting.addParticipantsEventListener(participantsEventListener: self)- 检查本地参与者是否具有禁用其他参与者视频的权限。
final canMuteVideo = meeting.localUser.permissions.host.canMuteVideo;
if (!canMuteVideo) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
disableVideo()。
participant.disableVideo(
onResult: (error) {
if (error != null) {
// 处理错误 - 权限被拒绝或其他问题。
return;
}
// 视频已成功禁用。
},
);- 通过监听更新来处理结果。调用成功后,目标参与者的
videoEnabled变为false。
class ParticipantsEventsListener extends RtkParticipantsEventListener {
@override
void onVideoUpdate(RtkRemoteParticipant participant, bool isEnabled) {
// videoEnabled 为 false
// 更新该参与者的 UI
}
}
// 注册监听器
meeting.addParticipantsEventListener(ParticipantsEventsListener());- 检查本地参与者是否具有禁用其他参与者视频的权限。
const canDisableParticipantVideo = meeting.self.permissions.canDisableParticipantVideo;
if (!canDisableParticipantVideo) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
disableVideo()。
participant
.disableVideo()
.catch((err) => {
// 处理错误 - 权限被拒绝或其他问题。
console.log(err);
});- 通过监听更新来处理结果。调用成功后,目标参与者的
videoEnabled变为false。
meeting.participants.joined.on('videoUpdate', (participant) => {
// participant.videoEnabled 为 false
// 更新该参与者的 UI
});这会影响所有参与者,包括本地参与者。要禁用会话中所有参与者的视频:
-
检查本地参与者是否有权限禁用其他参与者的视频。
const canDisableVideo = meeting.self.permissions.canDisableParticipantVideo === true; if (!canDisableVideo) { // 在您的 UI 中禁用此控件。 } -
调用
disableAllVideo()。如果本地参与者没有所需权限,
disableAllVideo()会抛出一个错误代码为1201的ClientError。try { await meeting.participants.disableAllVideo(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有禁用其他参与者视频的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,每个参与者的
videoEnabled都会变为false,且 SDK 会触发videoUpdate事件。 本地参与者也会在meeting.self上接收到videoUpdate。在
joined映射上监听远程参与者更新:meeting.participants.joined.on( "videoUpdate", (participant, { videoEnabled, videoTrack }) => { // videoEnabled 为 false // 更新该参与者的 UI }, );在
meeting.self上监听本地参与者更新:meeting.self.on("videoUpdate", ({ videoEnabled, videoTrack }) => { // videoEnabled 为 false // 更新本地参与者的 UI });
-
检查本地参与者是否有权限禁用其他参与者的视频。
const canDisableVideo = meeting.self.permissions.canDisableParticipantVideo === true; if (!canDisableVideo) { // 在您的 UI 中禁用此控件。 } -
调用
disableAllVideo()。如果本地参与者没有所需权限,
disableAllVideo()会抛出一个错误代码为1201的ClientError。try { await meeting.participants.disableAllVideo(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有禁用其他参与者视频的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,每个参与者的
videoEnabled都会变为false,且 SDK 会触发videoUpdate事件。 本地参与者也会在meeting.self上接收到videoUpdate。在
joined映射上监听远程参与者更新:meeting.participants.joined.on( "videoUpdate", (participant, { videoEnabled, videoTrack }) => { // videoEnabled 为 false // 更新该参与者的 UI }, );在
meeting.self上监听本地参与者更新:meeting.self.on("videoUpdate", ({ videoEnabled, videoTrack }) => { // videoEnabled 为 false // 更新本地参与者的 UI });
-
检查本地参与者是否有权限禁用其他参与者的视频。
const canDisableVideo = meeting.self.permissions.canDisableParticipantVideo === true; if (!canDisableVideo) { // 在您的 UI 中禁用此控件。 } -
调用
disableAllVideo()。如果本地参与者没有所需权限,
disableAllVideo()会抛出一个错误代码为1201的ClientError。try { await meeting.participants.disableAllVideo(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有禁用其他参与者视频的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,每个参与者的
videoEnabled都会变为false,且 SDK 会触发videoUpdate事件。 本地参与者也会在meeting.self上接收到videoUpdate。在
joined映射上监听远程参与者更新:meeting.participants.joined.on( "videoUpdate", (participant, { videoEnabled, videoTrack }) => { // videoEnabled 为 false // 更新该参与者的 UI }, );在
meeting.self上监听本地参与者更新:meeting.self.on("videoUpdate", ({ videoEnabled, videoTrack }) => { // videoEnabled 为 false // 更新本地参与者的 UI });
- 检查本地参与者是否具有禁用其他参与者视频的权限。
val canMuteVideo = meeting.localUser.permissions.host.canMuteVideo
if (!canMuteVideo) {
// 在您的 UI 中禁用该控件。
}- 在 participants 对象上调用
disableAllVideo()。如果本地参与者没有所需的权限,disableAllVideo()将返回HostError。
val error = meeting.participants.disableAllVideo()
if (error != null) {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,每个参与者的
videoEnabled变为false。
meeting.addParticipantsEventListener(object : RtkParticipantsEventListener {
override fun onVideoUpdate(participant: RtkRemoteParticipant, isEnabled: Boolean) {
// videoEnabled 为 false
// 更新该参与者的 UI
}
})- 检查本地参与者是否具有禁用其他参与者视频的权限。
let canMuteVideo = meeting.localUser.permissions.host.canMuteVideo
if !canMuteVideo {
// 在您的 UI 中禁用该控件。
}- 在 participants 对象上调用
disableAllVideo()。如果本地参与者没有所需的权限,disableAllVideo()将返回HostError。
if let error = meeting.participants.disableAllVideo() {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,每个参与者的
videoEnabled变为false。
extension MeetingViewModel: RtkParticipantsEventListener {
func onVideoUpdate(participant: RtkRemoteParticipant, isEnabled: Bool) {
// videoEnabled 为 false
// 更新该参与者的 UI
}
}
// 注册监听器
meeting.addParticipantsEventListener(participantsEventListener: self)- 检查本地参与者是否具有禁用其他参与者视频的权限。
final canMuteVideo = meeting.localUser.permissions.host.canMuteVideo;
if (!canMuteVideo) {
// 在您的 UI 中禁用该控件。
}- 在 participants 对象上调用
disableAllVideo()。
meeting.participants.disableAllVideo(
onResult: (error) {
if (error != null) {
// 处理错误 - 权限被拒绝或其他问题。
return;
}
// 所有视频已成功禁用。
},
);- 通过监听更新来处理结果。调用成功后,每个参与者的
videoEnabled变为false。
class ParticipantsEventsListener extends RtkParticipantsEventListener {
@override
void onVideoUpdate(RtkRemoteParticipant participant, bool isEnabled) {
// videoEnabled 为 false
// 更新该参与者的 UI
}
}
// 注册监听器
meeting.addParticipantsEventListener(ParticipantsEventsListener());- 检查本地参与者是否具有禁用其他参与者视频的权限。
const canDisableParticipantVideo = meeting.self.permissions.canDisableParticipantVideo;
if (!canDisableParticipantVideo) {
// 在您的 UI 中禁用该控件。
}- 在 participants 对象上调用
disableAllVideo()。
meeting.participants
.disableAllVideo(true)
.catch((err) => {
// 处理错误 - 权限被拒绝或其他问题。
console.log(err);
});- 通过监听更新来处理结果。调用成功后,每个参与者的
videoEnabled变为false。
meeting.participants.joined.on('videoUpdate', (participant) => {
// participant.videoEnabled 为 false
// 更新该参与者的 UI
});置顶参与者以突出显示他们,例如网络研讨会主讲人或课堂老师。这是一个会话范围的操作。所有参与者都会将置顶的参与者视为焦点。
此操作需要本地参与者的预设中启用 **Pin Participant(pin_participant)**主持人控制权限。
要在会话中置顶参与者:
-
检查本地参与者是否有权限置顶参与者。
const canPinParticipant = meeting.self.permissions.pinParticipant === true; if (!canPinParticipant) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
pin()。如果本地参与者没有所需权限,
pin()会抛出一个错误代码为1201的ClientError。try { await participant.pin(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有置顶参与者的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后:
- 目标参与者的
isPinned变为 true。 - 该参与者将被添加到
meeting.participants.pinned中。 - SDK 会触发
pinned事件。
选项 A:在参与者对象上进行监听
participant.on("pinned", (updatedParticipant) => { // updatedParticipant.isPinned 为 true // 更新您的 UI。 });选项 B:在
joined映射上进行监听meeting.participants.joined.on("pinned", (updatedParticipant) => { // updatedParticipant.isPinned 为 true // 更新您的 UI。 });如果之前已存在置顶的参与者,则 SDK 会为该参与者触发
unpinned事件。 - 目标参与者的
-
在目标被置顶参与者端,
meeting.self.isPinned变为true且meeting.self会触发pinned:meeting.self.on("pinned", (selfParticipant) => { // 更新本地 UI 以指示该参与者已被置顶。 });
-
检查本地参与者是否有权限置顶参与者。
const canPinParticipant = meeting.self.permissions.pinParticipant === true; if (!canPinParticipant) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
pin()。如果本地参与者没有所需权限,
pin()会抛出一个错误代码为1201的ClientError。try { await participant.pin(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有置顶参与者的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后:
- 目标参与者的
isPinned变为 true。 - 该参与者将被添加到
meeting.participants.pinned中。 - SDK 会触发
pinned事件。
选项 A:在参与者对象上进行监听
participant.on("pinned", (updatedParticipant) => { // updatedParticipant.isPinned 为 true // 更新您的 UI。 });选项 B:在
joined映射上进行监听meeting.participants.joined.on("pinned", (updatedParticipant) => { // updatedParticipant.isPinned 为 true // 更新您的 UI。 });如果之前已存在置顶的参与者,则 SDK 会为该参与者触发
unpinned事件。 - 目标参与者的
-
在目标被置顶参与者端,
meeting.self.isPinned变为true且meeting.self会触发pinned:meeting.self.on("pinned", (selfParticipant) => { // 更新本地 UI 以指示该参与者已被置顶。 });
-
检查本地参与者是否有权限置顶参与者。
const canPinParticipant = meeting.self.permissions.pinParticipant === true; if (!canPinParticipant) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
pin()。如果本地参与者没有所需权限,
pin()会抛出一个错误代码为1201的ClientError。try { await participant.pin(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有置顶参与者的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后:
- 目标参与者的
isPinned变为 true。 - 该参与者将被添加到
meeting.participants.pinned中。 - SDK 会触发
pinned事件。
选项 A:在参与者对象上进行监听
participant.on("pinned", (updatedParticipant) => { // updatedParticipant.isPinned 为 true // 更新您的 UI。 });选项 B:在
joined映射上进行监听meeting.participants.joined.on("pinned", (updatedParticipant) => { // updatedParticipant.isPinned 为 true // 更新您的 UI。 });如果之前已存在置顶的参与者,则 SDK 会为该参与者触发
unpinned事件。 - 目标参与者的
-
在目标被置顶参与者端,
meeting.self.isPinned变为true且meeting.self会触发pinned:meeting.self.on("pinned", (selfParticipant) => { // 更新本地 UI 以指示该参与者已被置顶。 });
- 检查本地参与者是否具有置顶参与者的权限。
val canPinParticipant = meeting.localUser.permissions.host.canPinParticipant
if (!canPinParticipant) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
pin()。如果本地参与者没有所需的权限,pin()将返回HostError。
val error = participant.pin()
if (error != null) {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,目标参与者的
isPinned变为true,且该参与者可在meeting.participants.pinned中获取。
meeting.addParticipantsEventListener(object : RtkParticipantsEventListener {
override fun onParticipantPinned(participant: RtkRemoteParticipant) {
// participant.isPinned 为 true
// 更新您的 UI。
}
})- 检查本地参与者是否具有置顶参与者的权限。
let canPinParticipant = meeting.localUser.permissions.host.canPinParticipant
if !canPinParticipant {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
pin()。如果本地参与者没有所需的权限,pin()将返回HostError。
if let error = participant.pin() {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,目标参与者的
isPinned变为true,且该参与者可在meeting.participants.pinned中获取。
extension MeetingViewModel: RtkParticipantsEventListener {
func onParticipantPinned(participant: RtkRemoteParticipant) {
// participant.isPinned 为 true
// 更新您的 UI。
}
}
// 注册监听器
meeting.addParticipantsEventListener(participantsEventListener: self)- 检查本地参与者是否具有置顶参与者的权限。
final canPinParticipant = meeting.localUser.permissions.host.canPinParticipant;
if (!canPinParticipant) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
pin()。
participant.pin();- 通过监听更新来处理结果。调用成功后,目标参与者的
isPinned变为true,且该参与者可在meeting.participants.pinned中获取。
class ParticipantsEventsListener extends RtkParticipantsEventListener {
@override
void onParticipantPinned(RtkRemoteParticipant participant) {
// participant.isPinned 为 true
// 更新您的 UI。
}
}
// 注册监听器
meeting.addParticipantsEventListener(ParticipantsEventsListener());- 检查本地参与者是否具有置顶参与者的权限。
const canPinParticipant = meeting.self.permissions.pinParticipant;
if (!canPinParticipant) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
pin()。
participant.pin();- 通过监听更新来处理结果。调用成功后,目标参与者的
isPinned变为true,且该参与者可在meeting.participants.pinned中获取。
meeting.participants.pinned.on('participantPinned', (participant) => {
// participant.isPinned 为 true
// 更新您的 UI。
});当您需要撤销突出显示并将会话返回到标准网格或活跃发言者视图时,可以取消置顶参与者。 要取消置顶会话中已置顶的参与者:
-
检查本地参与者是否有权限取消置顶参与者。
const canUnpinParticipant = meeting.self.permissions.pinParticipant === true; if (!canUnpinParticipant) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
unpin()。如果本地参与者没有所需权限,
unpin()会抛出一个错误代码为1201的ClientError。try { await participant.unpin(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有取消置顶参与者的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后:
- 目标参与者的
isPinned变为false。 - 该参与者将从
meeting.participants.pinned中被移除。 - SDK 会触发
unpinned事件。
选项 A:在参与者对象上进行监听
participant.on("unpinned", (updatedParticipant) => { // updatedParticipant.isPinned 为 false // 更新您的 UI。 });选项 B:在
joined映射上进行监听meeting.participants.joined.on("unpinned", (updatedParticipant) => { // updatedParticipant.isPinned 为 false // 更新您的 UI。 }); - 目标参与者的
-
在目标被取消置顶参与者端,
meeting.self.isPinned变为false且meeting.self会触发unpinned:meeting.self.on("unpinned", (selfParticipant) => { // 更新本地 UI 以指示该参与者不再处于置顶状态。 });
-
检查本地参与者是否有权限取消置顶参与者。
const canUnpinParticipant = meeting.self.permissions.pinParticipant === true; if (!canUnpinParticipant) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
unpin()。如果本地参与者没有所需权限,
unpin()会抛出一个错误代码为1201的ClientError。try { await participant.unpin(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有取消置顶参与者的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后:
- 目标参与者的
isPinned变为false。 - 该参与者将从
meeting.participants.pinned中被移除。 - SDK 会触发
unpinned事件。
选项 A:在参与者对象上进行监听
participant.on("unpinned", (updatedParticipant) => { // updatedParticipant.isPinned 为 false // 更新您的 UI。 });选项 B:在
joined映射上进行监听meeting.participants.joined.on("unpinned", (updatedParticipant) => { // updatedParticipant.isPinned 为 false // 更新您的 UI。 }); - 目标参与者的
-
在目标被取消置顶参与者端,
meeting.self.isPinned变为false且meeting.self会触发unpinned:meeting.self.on("unpinned", (selfParticipant) => { // 更新本地 UI 以指示该参与者不再处于置顶状态。 });
-
检查本地参与者是否有权限取消置顶参与者。
const canUnpinParticipant = meeting.self.permissions.pinParticipant === true; if (!canUnpinParticipant) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
unpin()。如果本地参与者没有所需权限,
unpin()会抛出一个错误代码为1201的ClientError。try { await participant.unpin(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有取消置顶参与者的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后:
- 目标参与者的
isPinned变为false。 - 该参与者将从
meeting.participants.pinned中被移除。 - SDK 会触发
unpinned事件。
选项 A:在参与者对象上进行监听
participant.on("unpinned", (updatedParticipant) => { // updatedParticipant.isPinned 为 false // 更新您的 UI。 });选项 B:在
joined映射上进行监听meeting.participants.joined.on("unpinned", (updatedParticipant) => { // updatedParticipant.isPinned 为 false // 更新您的 UI。 }); - 目标参与者的
-
在目标被取消置顶参与者端,
meeting.self.isPinned变为false且meeting.self会触发unpinned:meeting.self.on("unpinned", (selfParticipant) => { // 更新本地 UI 以指示该参与者不再处于置顶状态。 });
- 检查本地参与者是否具有取消置顶参与者的权限。
val canPinParticipant = meeting.localUser.permissions.host.canPinParticipant
if (!canPinParticipant) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
unpin()。如果本地参与者没有所需的权限,unpin()将返回HostError。
val error = participant.unpin()
if (error != null) {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,目标参与者的
isPinned变为false。
meeting.addParticipantsEventListener(object : RtkParticipantsEventListener {
override fun onParticipantUnpinned(participant: RtkRemoteParticipant) {
// participant.isPinned 为 false
// 更新您的 UI。
}
})- 检查本地参与者是否具有取消置顶参与者的权限。
let canPinParticipant = meeting.localUser.permissions.host.canPinParticipant
if !canPinParticipant {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
unpin()。如果本地参与者没有所需的权限,unpin()将返回HostError。
if let error = participant.unpin() {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,目标参与者的
isPinned变为false。
extension MeetingViewModel: RtkParticipantsEventListener {
func onParticipantUnpinned(participant: RtkRemoteParticipant) {
// participant.isPinned 为 false
// 更新您的 UI。
}
}
// 注册监听器
meeting.addParticipantsEventListener(participantsEventListener: self)- 检查本地参与者是否具有取消置顶参与者的权限。
final canPinParticipant = meeting.localUser.permissions.host.canPinParticipant;
if (!canPinParticipant) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
unpin()。
participant.unpin();- 通过监听更新来处理结果。调用成功后,目标参与者的
isPinned变为false。
class ParticipantsEventsListener extends RtkParticipantsEventListener {
@override
void onParticipantUnpinned(RtkRemoteParticipant participant) {
// participant.isPinned 为 false
// 更新您的 UI。
}
}
// 注册监听器
meeting.addParticipantsEventListener(ParticipantsEventsListener());- 检查本地参与者是否具有取消置顶参与者的权限。
const canPinParticipant = meeting.self.permissions.pinParticipant;
if (!canPinParticipant) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
unpin()。
participant.unpin();- 通过监听更新来处理结果。调用成功后,目标参与者的
isPinned变为false。
meeting.participants.pinned.on('unpinned', (participant) => {
// participant.isPinned 为 false
// 更新您的 UI。
});当您需要管理违规行为或强制执行会话规则时,可以将参与者从会话中移除。
此操作需要本地参与者的预设中启用 **Kick Participants(kick_participant)**主持人控制权限。
要从会话中移除特定参与者:
-
检查本地参与者是否有权限移除参与者。
const canKickParticipant = meeting.self.permissions.kickParticipant === true; if (!canKickParticipant) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
kick()。如果本地参与者没有所需权限,
kick()会抛出一个错误代码为1201的ClientError。try { await participant.kick(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有移除参与者的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后:
- 被踢出的参与者将从
meeting.participants.joined中被移除。 - 该参与者将从他们所在的其他参与者映射中被移除(例如,
meeting.participants.pinned)。 - SDK 会在
meeting.participants.joined上触发participantLeft事件。
meeting.participants.joined.on("participantLeft", (participant) => { // 从 UI 中移除该参与者的卡片。 });会话中的其他参与者也会通过
participantLeft观察到该参与者的离开。 - 被踢出的参与者将从
-
在被移除的参与者端,会话会断开连接,且
meeting.self会触发roomLeft事件,state 设置为kicked。meeting.self.on("roomLeft", ({ state }) => { if (state === "kicked") { // 显示一条消息并将用户导航出会议 UI。 } });
-
检查本地参与者是否有权限移除参与者。
const canKickParticipant = meeting.self.permissions.kickParticipant === true; if (!canKickParticipant) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
kick()。如果本地参与者没有所需权限,
kick()会抛出一个错误代码为1201的ClientError。try { await participant.kick(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有移除参与者的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后:
- 被踢出的参与者将从
meeting.participants.joined中被移除。 - 该参与者将从他们所在的其他参与者映射中被移除(例如,
meeting.participants.pinned)。 - SDK 会在
meeting.participants.joined上触发participantLeft事件。
meeting.participants.joined.on("participantLeft", (participant) => { // 从 UI 中移除该参与者的卡片。 });会话中的其他参与者也会通过
participantLeft观察到该参与者的离开。 - 被踢出的参与者将从
-
在被移除的参与者端,会话会断开连接,且
meeting.self会触发roomLeft事件,state 设置为kicked。meeting.self.on("roomLeft", ({ state }) => { if (state === "kicked") { // 显示一条消息并将用户导航出会议 UI。 } });
-
检查本地参与者是否有权限移除参与者。
const canKickParticipant = meeting.self.permissions.kickParticipant === true; if (!canKickParticipant) { // 在您的 UI 中禁用此控件。 } -
在目标参与者上调用
kick()。如果本地参与者没有所需权限,
kick()会抛出一个错误代码为1201的ClientError。try { await participant.kick(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有移除参与者的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后:
- 被踢出的参与者将从
meeting.participants.joined中被移除。 - 该参与者将从他们所在的其他参与者映射中被移除(例如,
meeting.participants.pinned)。 - SDK 会在
meeting.participants.joined上触发participantLeft事件。
meeting.participants.joined.on("participantLeft", (participant) => { // 从 UI 中移除该参与者的卡片。 });会话中的其他参与者也会通过
participantLeft观察到该参与者的离开。 - 被踢出的参与者将从
-
在被移除的参与者端,会话会断开连接,且
meeting.self会触发roomLeft事件,state 设置为kicked。meeting.self.on("roomLeft", ({ state }) => { if (state === "kicked") { // 显示一条消息并将用户导航出会议 UI。 } });
- 检查本地参与者是否具有移除参与者的权限。
val canKickParticipant = meeting.localUser.permissions.host.canKickParticipant
if (!canKickParticipant) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
kick()。如果本地参与者没有所需的权限,kick()将返回HostError。
val error = participant.kick()
if (error != null) {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,被踢出的参与者将从
meeting.participants.joined中被移除。
meeting.addParticipantsEventListener(object : RtkParticipantsEventListener {
override fun onParticipantLeave(participant: RtkRemoteParticipant) {
// 从 UI 中移除该参与者的视频瓦片。
}
})- 检查本地参与者是否具有移除参与者的权限。
let canKickParticipant = meeting.localUser.permissions.host.canKickParticipant
if !canKickParticipant {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
kick()。如果本地参与者没有所需的权限,kick()将返回HostError。
if let error = participant.kick() {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,被踢出的参与者将从
meeting.participants.joined中被移除。
extension MeetingViewModel: RtkParticipantsEventListener {
func onParticipantLeave(participant: RtkRemoteParticipant) {
// 从 UI 中移除该参与者的视频瓦片。
}
}
// 注册监听器
meeting.addParticipantsEventListener(participantsEventListener: self)- 检查本地参与者是否具有移除参与者的权限。
final canKickParticipant = meeting.localUser.permissions.host.canKickParticipant;
if (!canKickParticipant) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
kick()。
participant.kick(
onResult: (error) {
if (error != null) {
// 处理错误 - 权限被拒绝或其他问题。
return;
}
// 参与者已成功移除。
},
);- 通过监听更新来处理结果。调用成功后,被踢出的参与者将从
meeting.participants.joined中被移除。
class ParticipantsEventsListener extends RtkParticipantsEventListener {
@override
void onParticipantLeave(RtkRemoteParticipant participant) {
// 从 UI 中移除该参与者的视频瓦片。
}
}
// 注册监听器
meeting.addParticipantsEventListener(ParticipantsEventsListener());- 检查本地参与者是否具有移除参与者的权限。
const canKickParticipant = meeting.self.permissions.kickParticipant;
if (!canKickParticipant) {
// 在您的 UI 中禁用该控件。
}- 在目标参与者上调用
kick()。
participant
.kick()
.catch((err) => {
// 处理错误 - 权限被拒绝或其他问题。
console.log(err);
});- 通过监听更新来处理结果。调用成功后,被踢出的参与者将从
meeting.participants.joined中被移除。
meeting.participants.joined.on('participantLeft', (participant) => {
// 从 UI 中移除该参与者的视频瓦片。
});这会将所有人从会话中移除,包括本地参与者。这会为所有人结束会话。
有关完整的结束会话流程,请参阅 结束会话。
要从会话中移除所有参与者:
-
检查本地参与者是否有权限移除参与者。
const canKickParticipant = meeting.self.permissions.kickParticipant === true; if (!canKickParticipant) { // 在您的 UI 中禁用此控件。 } -
调用
kickAll()。如果本地参与者没有所需权限,
kickAll()会抛出一个错误代码为1201的ClientError。try { await meeting.participants.kickAll(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有移除参与者的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,所有参与者都将退出会话。在每个客户端上,
meeting.self会触发roomLeft事件且 state 设置为ended。meeting.self.on("roomLeft", ({ state }) => { if (state === "ended") { // 显示一条消息并将用户导航出会议 UI。 } });
-
检查本地参与者是否有权限移除参与者。
const canKickParticipant = meeting.self.permissions.kickParticipant === true; if (!canKickParticipant) { // 在您的 UI 中禁用此控件。 } -
调用
kickAll()。如果本地参与者没有所需权限,
kickAll()会抛出一个错误代码为1201的ClientError。try { await meeting.participants.kickAll(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有移除参与者的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,所有参与者都将退出会话。在每个客户端上,
meeting.self会触发roomLeft事件且 state 设置为ended。meeting.self.on("roomLeft", ({ state }) => { if (state === "ended") { // 显示一条消息并将用户导航出会议 UI。 } });
-
检查本地参与者是否有权限移除参与者。
const canKickParticipant = meeting.self.permissions.kickParticipant === true; if (!canKickParticipant) { // 在您的 UI 中禁用此控件。 } -
调用
kickAll()。如果本地参与者没有所需权限,
kickAll()会抛出一个错误代码为1201的ClientError。try { await meeting.participants.kickAll(); } catch (err: any) { if (err?.code === 1201) { // 本地参与者没有移除参与者的权限。 return; } throw err; } -
通过监听更新来处理结果。
调用成功后,所有参与者都将退出会话。在每个客户端上,
meeting.self会触发roomLeft事件且 state 设置为ended。meeting.self.on("roomLeft", ({ state }) => { if (state === "ended") { // 显示一条消息并将用户导航出会议 UI。 } });
- 检查本地参与者是否具有移除参与者的权限。
val canKickParticipant = meeting.localUser.permissions.host.canKickParticipant
if (!canKickParticipant) {
// 在您的 UI 中禁用该控件。
}- 在 participants 对象上调用
kickAll()。如果本地参与者没有所需的权限,kickAll()将返回HostError。
val error = meeting.participants.kickAll()
if (error != null) {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,所有参与者退出会话。
meeting.addMeetingRoomEventListener(object : RtkMeetingRoomEventListener {
override fun onMeetingEnded() {
// 显示一条消息并引导用户退出会议 UI。
}
})- 检查本地参与者是否具有移除参与者的权限。
let canKickParticipant = meeting.localUser.permissions.host.canKickParticipant
if !canKickParticipant {
// 在您的 UI 中禁用该控件。
}- 在 participants 对象上调用
kickAll()。如果本地参与者没有所需的权限,kickAll()将返回HostError。
if let error = meeting.participants.kickAll() {
// 处理错误 - 权限被拒绝。
}- 通过监听更新来处理结果。调用成功后,所有参与者退出会话。
extension MeetingViewModel: RtkMeetingRoomEventListener {
func onMeetingEnded() {
// 显示一条消息并引导用户退出会议 UI。
}
}
// 注册监听器
meeting.addMeetingRoomEventListener(meetingRoomEventListener: self)- 检查本地参与者是否具有移除参与者的权限。
final canKickParticipant = meeting.localUser.permissions.host.canKickParticipant;
if (!canKickParticipant) {
// 在您的 UI 中禁用该控件。
}- 在 participants 对象上调用
kickAll()。
meeting.participants.kickAll(
onResult: (error) {
if (error != null) {
// 处理错误 - 权限被拒绝或其他问题。
return;
}
// 所有参与者已成功移除。
},
);- 通过监听更新来处理结果。调用成功后,所有参与者退出会话。
class MeetingRoomEventsListener extends RtkMeetingRoomEventListener {
@override
void onMeetingEnded() {
// 显示一条消息并引导用户退出会议 UI。
}
}
// 注册监听器
meeting.addMeetingRoomEventListener(MeetingRoomEventsListener());- 检查本地参与者是否具有移除参与者的权限。
const canKickParticipant = meeting.self.permissions.kickParticipant;
if (!canKickParticipant) {
// 在您的 UI 中禁用该控件。
}- 在 participants 对象上调用
kickAll()。
meeting.participants
.kickAll()
.catch((err) => {
// 处理错误 - 权限被拒绝或其他问题。
console.log(err);
});- 通过监听更新来处理结果。调用成功后,所有参与者退出会话。
meeting.self.on('roomLeft', ({ state }) => {
if (state === 'kicked') {
// 显示一条消息并引导用户退出会议 UI。
}
});