Symptom
After creating a screen-sharing App in iOS and adding a preview window to show what is being published, the preview is mirrored horizontally.
Applies To
- iOS App
- Screen Sharing
Resolution
Before you set your publisher to "screen" you should tell your publisher that your Camera Position is "back" so that the publisher View does not reverse when rendering locally on the device.
Here is the sample code with the additional line highlighted:
let settings = OTPublisherSettings()
settings.name = UIDevice.current.name
publisher = OTPublisher(delegate: self, settings: settings)
publisher?.cameraPosition = AVCaptureDevice.Position.back;
publisher?.videoType = .screen
publisher?.audioFallbackEnabled = false
capturer = ScreenCapturer(withView: view)
publisher?.videoCapture = capturer
session.publish(publisher!, error: &error)
Setting the OTPublisher.cameraPosition corrects the issue with the screen preview being reversed. If you then append a screen preview to your layout using code similar to that below the preview will not be reversed.
if let publisherView = publisher!.view {
publisherView.frame = CGRect(x: 10,
y: 10,
width: kWidgetWidth,
height: kWidgetHeight)
view.addSubview(publisherView)
}
Cause
When you create a screen share publisher in iOS, it uses the current publisher settings. By default the Camera Position is set to Front and the Front Camera preview is reversed to give a mirrored view in the preview. It is not reversed in the published stream.
Additional Information
For more information, see the Apple Developer page on AVCaptureDevice.position.
Articles in this section
- How to use Completion handler for Exception Handling
- Firefox Pre-call test not supported
- Error Creating Session Using Vonage Video API .NET SDK
- Unable to Create Session Even Though API Key and Secret Are Valid
- HTTP 415 Error When Archiving Video Session
- Troubleshooting Invalid JWT When Creating a Video Session using REST API
- Camara Still in Use after Session Disconnect on Android
- Token Shows as Invalid
- HTTP 400 Error When Archiving Video Session
- 1541 Timed out while attempting to publish Error