我似乎无法获得远程视频流以正确呈现到我的UIView。我可以听到两个参与者的声音,但即使是IO,也似乎无法渲染视频流。
任何想法为何?这是我的代码:
func rtcEngine(_ engine: AgoraRtcEngineKit, firstRemoteVideoDecodedOfUid uid:UInt, size:CGSize, elapsed:Int) {
DispatchQueue.main.async {
if (self.remoteVideo.isHidden) {
self.remoteVideo.isHidden = false
}
self.agoraKit.muteLocalAudioStream(false)
let videoCanvas = AgoraRtcVideoCanvas()
videoCanvas.uid = 0
videoCanvas.view = self.remoteVideo
videoCanvas.renderMode = .adaptive
self.agoraKit.setupRemoteVideo(videoCanvas)
}
}
答案 0 :(得分:0)
从您的代码中,我看到您正在将UID分配为0。这意味着它将为远程视图自动生成一个新的UID。您可以根据需要将UID设置为0,以自动生成本地视频流。 但是,对于远程流,您需要获取已分配的远程流UID,该UID在回调方法的参数中作为uid变量提供。
此外,您需要确保在采用AgoraRtcEngineDelegate协议的扩展中添加委托方法。
extension VideoChatViewController: AgoraRtcEngineDelegate {
// Tutorial Step 5
func rtcEngine(_ engine: AgoraRtcEngineKit, firstRemoteVideoDecodedOfUid uid:UInt, size:CGSize, elapsed:Int) {
DispatchQueue.main.async {
if (self.remoteVideo.isHidden) {
self.remoteVideo.isHidden = false
}
self.agoraKit.muteLocalAudioStream(false)
let videoCanvas = AgoraRtcVideoCanvas()
videoCanvas.uid = uid
videoCanvas.view = self.remoteVideo
videoCanvas.renderMode = .adaptive
self.agoraKit.setupRemoteVideo(videoCanvas)
}
}
}