Skip to content

Commit 9b547fa

Browse files
author
Jaesung
authored
Merge pull request #18 from sendbird/feature/jaesung/flip-camera
Fix bug that it keeps mirroring local video view
2 parents fb69a68 + b842f0a commit 9b547fa

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

QuickStart/Dial/VideoCallViewController.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,14 @@ class VideoCallViewController: UIViewController, DirectCallDataSource {
137137
}
138138
return
139139
}
140-
self.mirrorLocalVideoView()
140+
DispatchQueue.main.async { [weak self] in
141+
guard let self = self else { return }
142+
switch oppositeCamera.position {
143+
case .front: self.mirrorLocalVideoView(isEnabled: true)
144+
case .back: self.mirrorLocalVideoView(isEnabled: false)
145+
default: return
146+
}
147+
}
141148
}
142149
}
143150

@@ -194,7 +201,7 @@ extension VideoCallViewController {
194201
self.localVideoView?.embed(localSBVideoView)
195202
self.view?.embed(remoteSBVideoView)
196203

197-
self.mirrorLocalVideoView()
204+
self.mirrorLocalVideoView(isEnabled: true)
198205
}
199206

200207
func resizeLocalVideoView() {
@@ -215,9 +222,12 @@ extension VideoCallViewController {
215222
})
216223
}
217224

218-
func mirrorLocalVideoView() {
225+
func mirrorLocalVideoView(isEnabled: Bool) {
219226
guard let localSBView = self.localVideoView?.subviews.first else { return }
220-
localSBView.transform = CGAffineTransform(scaleX: -1.0, y: 1.0)
227+
switch isEnabled {
228+
case true: localSBView.transform = CGAffineTransform(scaleX: -1.0, y: 1.0)
229+
case false: localSBView.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
230+
}
221231
}
222232

223233
// SendBirdCalls: Start / Stop Video

0 commit comments

Comments
 (0)