首页 > 解决方案 > 从 Zoom iOS SDK 自定义会议实施中获取当前活跃用户

问题描述

我已经实现了 Zoom iOS SDK 以使用自定义 UI。一切都按预期工作,但我无法弄清楚如何获取当前活动用户的用户 ID。

我已经实现了下面的委托方法,它讲述了当前活动的视频用户,但不幸的是,它显示了会议中除我之外的所有其他参与者。

func onSinkMeetingActiveVideo(_ userID: UInt) {
    if let service = MobileRTC.shared().getMeetingService(), let username = service.userInfo(byID: userID)?.userName {
        print("\(#function) : \(userID) : \(username)")
    }
}

我需要知道谁是当前的活跃用户,即使是我在说话。

标签: iosswiftiphonezoom-sdk

解决方案


您可以从会议服务 MobileRTCMeetingService 中检索此类信息。

移动RTCMeetingService

func getActiveUserId() -> UInt? {
    if let meetingService = MobileRTC.shared().getMeetingService() {
        return meetingService.activeUserID()
    }
    return nil
}

额外说明:在 Zoom 中还有一个固定用户的概念,它会覆盖活动视频单元中的活动用户。可以通过以下方式检索固定的用户 ID:

func getPinnedUserId() -> UInt? {
    if let meetingService = MobileRTC.shared().getMeetingService(), let userList = meetingService.getInMeetingUserList(){
        for userId in userList {
            if let userId = userId as? UInt, meetingService.isUserPinned(userId) {
                return userId
            }
        }
        return nil
    }
    return nil
}

因此,为了确定哪个是活动视频单元格中视频的用户 ID,您必须同时检查两者,优先考虑固定用户。

let currentVideoUserId = getPinnedUserId() ?? getActiveUserId()

在会议期间,您将永远不会成为您自己的视频单元中的活跃用户,因为即使您正在发言,您将继续在活跃的视频单元中看到其他人。

另一方面,如果您想知道谁在说话,那么您必须检索用户列表并检查 audioStatus [MobileRTCAudioStatus]。

MobileRTCAudioStatus

MobileRTCMeetingUserInfo

请注意,您可以同时让多个用户发言。

如果您对活跃的演讲者用户感兴趣,还有另一个回调可能很有用:它是 MobileRTCVideoServiceDelegate 中的 onSinkMeetingActiveVideoForDeck

MobileRTCVideoServiceDelegate

根据文档,每次有新扬声器时都应该触发它。ZOOM UI 使用它来更改当前扬声器用户周围的黄色框。


推荐阅读