0

我在将音频和视频从 WebRTC 集成到 SwiftUI 视图时遇到问题。我试图用 UIViewRepresentable 做到这一点,但发现一个错误。关于音频流我不知道。我的 SwiftUI 视图:

        if showingVideo {
            //MARK: SHOW VIDEO, AND TURN ON AUDIO

        } else {

        }

我尝试使用 UIViewRepresentable

func makeUIView(context: Context) -> RTCEAGLVideoView  {
        self.remoteView.frame = CGRect(x: 20, y: 20, width: 200, height: 300)
        self.remoteView = self.video.remoteVideoView!
        return self.remoteView
    }
4

1 回答 1

0

答案是做这样的事情

@ObservedObject var videoCallController: VideoCallController
func updateUIView(_ uiView: UIViewType, context: Context) {
    let remoteRenderer = RTCEAGLVideoView(frame: UIScreen.main.bounds)
    self.videoCallController.webRTCClient.renderRemoteVideo(to: remoteRenderer)

}
func makeUIView(context: Context) -> RTCEAGLVideoView {
    let remoteRenderer = RTCEAGLVideoView(frame: UIScreen.main.bounds)
    self.videoCallController.webRTCClient.renderRemoteVideo(to: remoteRenderer)
    return remoteRenderer
}

渲染远程视频在哪里

func renderRemoteVideo(to renderer: RTCVideoRenderer) {
    self.remoteVideoTrack?.add(renderer)
}

远程视频轨道是 RTCVideoTrack。

于 2020-07-14T13:08:51.807 回答