即使 IBOutlet 已连接,远程视频流也不会呈现到 UIView
Remote video stream is not being rendered to the UIView even though the IBOutlet is connected
我似乎无法让远程视频流正确呈现到我的 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)
}
}
从您的代码中,我看到您将 UID 分配为 0。这意味着它将自动为远程视图生成一个新的 UID。如果您愿意,可以将 UID 设置为 0 以自动生成本地视频流。 但是,对于远程流,您需要获取回调方法的参数中提供的远程流的分配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)
}
}
}
我似乎无法让远程视频流正确呈现到我的 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)
}
}
从您的代码中,我看到您将 UID 分配为 0。这意味着它将自动为远程视图生成一个新的 UID。如果您愿意,可以将 UID 设置为 0 以自动生成本地视频流。 但是,对于远程流,您需要获取回调方法的参数中提供的远程流的分配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)
}
}
}