Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoView doesn't work in iOS 16 #247

Open
floriangbh opened this issue Dec 8, 2022 · 1 comment
Open

VideoView doesn't work in iOS 16 #247

floriangbh opened this issue Dec 8, 2022 · 1 comment

Comments

@floriangbh
Copy link

Description

Since iOS 16 the orientation of VideoView doesn't work.

Steps to Reproduce

  1. Create CameraSource from the camera
  2. Attach the camera with addRenderer to a VideoView
  3. Set the phone in landscape mode
  4. See the result, VideoView is in landscape in iOS 15, but not with iOS 16

Code

func startPreview() {
        guard let backCamera = CameraSource.captureDevice(position: .back) else {
            Logs.error("Can't get back camera.")
            Alert.show(message: "No front or back capture device found!", sourceController: self)
            return
        }
        
        // Preview our local camera track in the local video preview view.
        self.camera = CameraSource(delegate: self)
        if let camera = self.camera {
            localVideoTrack =  LocalVideoTrack(source: camera, enabled: true, name: "Camera")
        } else {
            Logs.error("Can't get camera.")
        }
        
        // Add renderer to video track for local preview
        localVideoTrack?.addRenderer(self.previewView)
        Logs.debug("Video track created")
        
        let supportedFormats = CameraSource.supportedFormats(captureDevice: backCamera)
        var formatFound: VideoFormat?
        for format in supportedFormats {
            if let formatCasted = format as? VideoFormat {
                if formatCasted.dimensions.height == 1080 && formatCasted.dimensions.width == 1920 {
                    formatFound = formatCasted
                }
            }
        }
        
        guard let format = formatFound else {
            Alert.show(message: "Can't find the right format.", sourceController: self)
            Logs.error("Can't find the right format.")
            return
        }
        
        camera?.startCapture(device: backCamera, format: format) { (captureDevice, videoFormat, error) in
            if let error {
                let message = "Capture failed with error.\ncode = \((error as NSError).code) error = \(error.localizedDescription)"
                Logs.error(message)
                Alert.show(message: message, sourceController: self)
            } else {
                self.previewView.shouldMirror = (captureDevice.position == .front)
            }
        }
    }

Screenshot

iOS 15.6.1 :

IMG_0005

iOS 16.0.1 :

IMG_2275

Reproduces How Often

Always since iOS 16

Versions

All relevant version information for the issue.

Video iOS SDK

v5.4.0

Xcode

14.1

iOS Version

15.6.1 & 16.0.1

iOS Device

iPhone 13 mini & iPhone SE

@piyushtank
Copy link
Contributor

@floriangbhHave you tried with our Quickstart? I just tried on iOS 16, and I couldn't reproduce the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants