简体   繁体   English

渲染现有参与者的视频轨道

[英]render video tracks of existing participants

So I connect to a room, which might already have existing participants sharing their videos. 因此,我连接到一个会议室,该会议室可能已经有现有的参与者共享他们的视频。 However when I try to iterate through all the participants and add their respective videos...it doesn't work. 但是,当我尝试遍历所有参与者并添加他们各自的视频时,它不起作用。 For some reason, even though the participant count is not 0. How do I get the video tracks of all the existing participants in a room and render them? 由于某些原因,即使参与者计数不为0。如何获取房间中所有现有参与者的视频轨道并进行渲染?

So basically this is the workflow: 所以基本上这是工作流程:

  1. User 1 and 2 enters room and shares their videos 用户1和2进入会议室并分享他们的视频
  2. User 3 enters room, and wants to show the video of the existing participants on screen(eg user 1 and 2 who logged in before him) How do I do that? 用户3进入房间,并希望在屏幕上显示现有参与者的视频(例如,在他之前登录的用户1和2)如何执行此操作? )

Here is my code for the didConnect() delegate which fires when one enters a room.the addVideoTrack function renders the video for any new participants, so its working fine, but I want to do it for previously existing participants. 这是我的didConnect()委托的代码,当有人进入房间时会触发该代码。addVideoTrack函数可为任何新参与者呈现视频,因此它可以正常工作,但我想对以前已​​有的参与者进行处理。

    func didConnect(to room: TVIRoom) {
    connectedParticipants = room.participants
    for participant in connectedParticipants {

        for videoTrack in participant.videoTracks {
            addVideoTrack(videoTrack:videoTrack)
        }

    }

    changeRoomLabel(messageText: "Room: \(room.name)")
}

Twilio developer evangelist here. Twilio开发人员布道者在这里。

When you connect to the room and find the participants, you may not have connected to their media streams yet. 当您连接到会议室并找到参与者时,您可能尚未连接到他们的媒体流。 Instead, you should implement the TVIParticipantDelegate . 相反,您应该实现TVIParticipantDelegate As you can see in the Twilio Video quickstart application (which only handles one external participant, but is a good example), when connecting to a room set the controller as the participant's delegate: 正如您在Twilio Video快速入门应用程序 (仅处理一个外部参与者,但是一个很好的示例)中看到的那样,当连接到会议室时,将控制器设置为参与者的代表:

func didConnect(to room: TVIRoom) {
    if (room.participants.count > 0) {
        self.participant = room.participants[0]
        self.participant?.delegate = self
    }
}

Then, the example implements the TVIParticipantDelegate participant:addedVideoTrack to render the video once it is added to the participant: 然后,该示例实现TVIParticipantDelegate participant:addedVideoTrack以在将视频添加到参与者后呈现该视频:

extension ViewController : TVIParticipantDelegate {
    func participant(_ participant: TVIParticipant, addedVideoTrack videoTrack: TVIVideoTrack) {
        logMessage(messageText: "Participant \(participant.identity) added video track")

        if (self.participant == participant) {
            setupRemoteVideoView()
            videoTrack.addRenderer(self.remoteView!)
        }
    }
}

And the other delegate methods here . 还有其他的委托方法

Let me know if that helps at all. 让我知道是否有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在opentok中显示所有加入视频通话的参与者列表 - how to show participants lists who are all joined the video call in opentok 为什么同一视频文件的AVAsset轨道具有不同的timeRange? - Why AVAsset tracks has different timeRange for same video file? 无法使用 WebRTC 渲染远程视频 - Unable to render remote video with WebRTC 使用AudioMixInputParameters AVFoundation为每个视频轨道设置多个音量在Swift iOS中不起作用 - Setting multiple Volumes to each Video tracks using AudioMixInputParameters AVFoundation is not working in Swift iOS 即使存在视频,AVASset也具有0条音轨,并且在“相机胶卷”中可以正常播放:故障排除步骤? - AVAsset has 0 tracks even though video exists and plays fine from the Camera Roll: troubleshooting steps? 无法从 AVURLAsset 为 AVPlayer 获取 HLS 视频(.m3u8 格式)的视频轨道? - Can't able to get Video Tracks from AVURLAsset for HLS videos(.m3u8 format) for AVPlayer? 如何在 Swift 中处理现有视频的帧 - How to process frames of an existing video in Swift 可选绑定的参与者的名字是什么? - What are the names of the participants of an optional binding? 在 SceneKit iOS 中渲染流式视频的最有效方法是什么? - What is the most efficient way to render a streamed video in SceneKit iOS? 参与者如何扭转他们对 CKShare 的接受? - How may participants reverse their acceptance of CKShare?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM