I'm trying to display a remote screen share video using the Agora iOS SDK. I'm setting up the video canvas after receiving the didJoinedOfUid delegate, but the preview is not showing up. This is my configuration for setting up my View.
func createScreenShareView(uid: UInt, agoraEngine: AgoraRtcEngineKit) {
guard isStreamActive else {
print("FOO: Screen share not active. Skipping createScreenShareView.")
return
}
print("FOO: Adding remoteShareView to main view for uid \(uid)")
view.addSubview(remoteShareView)
view.bringSubviewToFront(remoteShareView)
NSLayoutConstraint.activate([
remoteShareView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
remoteShareView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
remoteShareView.widthAnchor.constraint(equalTo: view.widthAnchor),
remoteShareView.heightAnchor.constraint(equalTo: view.heightAnchor),
])
print("FOO: Activated constraints for remoteShareView")
let videoCanvas = AgoraRtcVideoCanvas()
videoCanvas.uid = uid
videoCanvas.view = remoteShareView
videoCanvas.renderMode = .fit
print("FOO: Setting up remote video for uid \(uid)")
agoraEngine.setupRemoteVideo(videoCanvas)
}
In my AgoraRtcEngineDelegate, I call a delegate method to notify about receiving video stream and pass the uid and engine to view controller.
func rtcEngine(_ engine: AgoraRtcEngineKit, didJoinedOfUid uid: UInt, elapsed: Int {
self.uid = uid
if let engine = agoraEngine {
print("FOO: calling screenDelegate?.didJoinedOfUid for uid \(uid)")
screenDelegate?.didJoinedOfUid(uid: uid, elapsed: elapsed, agoraEngine: engine)
}
}
Here is the implementation for that
func didJoinedOfUid(uid: UInt, elapsed: Int, agoraEngine: AgoraRtcEngineKit) {
print("FOO: didJoinedOfUid called with uid \(uid), elapsed \(elapsed) ms")
createScreenShareView(uid: uid, agoraEngine: agoraEngine)
}
func didOfflineOfUid(uid: UInt, agoraEngine: AgoraRtcEngineKit) {
print("FOO: didOfflineOfUid called with uid \(uid)")
stopSharing(uid: uid, agoraEngine: agoraEngine)
}
The view is getting added and visible but remote video stream is not being shown . This happened when I shared from Android to iOS.
It worked after I upgraded the SDK to newer version