Skip to content

Commit b2d08c6

Browse files
author
Arlin
committed
[macOS] Do not show localVideo when ScreenShare
1 parent c5eb555 commit b2d08c6

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

macOS/APIExample/Examples/Advanced/ScreenShare/ScreenShare.swift

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ class ScreenShare: BaseViewController {
207207
mediaOptions.publishCameraTrack = .of(false)
208208
mediaOptions.publishScreenTrack = .of(true)
209209
agoraKit.updateChannel(with: mediaOptions)
210-
agoraKit.startPreview()
211-
setupLocalPreview(isScreenSharing: true)
210+
agoraKit.stopPreview()
211+
videos[0].placeholder.stringValue = "Screen Sharing"
212212
}
213213
} else {
214214
agoraKit.stopScreenCapture()
@@ -218,7 +218,7 @@ class ScreenShare: BaseViewController {
218218
mediaOptions.publishScreenTrack = .of(false)
219219
agoraKit.updateChannel(with: mediaOptions)
220220
agoraKit.startPreview()
221-
setupLocalPreview(isScreenSharing: false)
221+
videos[0].placeholder.stringValue = "Local"
222222
}
223223
}
224224

@@ -277,8 +277,8 @@ class ScreenShare: BaseViewController {
277277
mediaOptions.publishCameraTrack = .of(false)
278278
mediaOptions.publishScreenTrack = .of(true)
279279
agoraKit.updateChannel(with: mediaOptions)
280-
agoraKit.startPreview()
281-
setupLocalPreview(isScreenSharing: true)
280+
agoraKit.stopPreview()
281+
videos[0].placeholder.stringValue = "Screen Sharing"
282282
}
283283
} else {
284284
agoraKit.stopScreenCapture()
@@ -289,7 +289,7 @@ class ScreenShare: BaseViewController {
289289
agoraKit.updateChannel(with: mediaOptions)
290290
agoraKit.startPreview()
291291
isWindowSharing = false
292-
setupLocalPreview(isScreenSharing: false)
292+
videos[0].placeholder.stringValue = "Local"
293293
}
294294
}
295295

@@ -407,7 +407,15 @@ class ScreenShare: BaseViewController {
407407
mirrorMode: .auto
408408
)
409409
)
410-
setupLocalPreview(isScreenSharing: false)
410+
411+
// set up local video to render your local camera preview
412+
let localVideo = videos[0]
413+
let videoCanvas = AgoraRtcVideoCanvas()
414+
videoCanvas.view = localVideo.videocanvas
415+
videoCanvas.renderMode = .fit
416+
agoraKit.setupLocalVideo(videoCanvas)
417+
agoraKit.startPreview()
418+
411419

412420
// start joining channel
413421
// 1. Users can only see each other after they join the
@@ -525,7 +533,7 @@ extension ScreenShare: AgoraRtcEngineDelegate {
525533
videoCanvas.uid = uid
526534
// the view to be binded
527535
videoCanvas.view = remoteVideo.videocanvas
528-
videoCanvas.renderMode = .hidden
536+
videoCanvas.renderMode = .fit
529537
agoraKit.setupRemoteVideo(videoCanvas)
530538
remoteVideo.uid = uid
531539
} else {

0 commit comments

Comments
 (0)