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

Setting mirroringMode #49

Open
cybercent opened this issue Feb 24, 2017 · 12 comments
Open

Setting mirroringMode #49

cybercent opened this issue Feb 24, 2017 · 12 comments
Labels

Comments

@cybercent
Copy link

cybercent commented Feb 24, 2017

Hi,

Setting the mirroringMode expects a session to already exist but crashes the app if the session has already started.

If I set sharedInstance.mirroringMode = .on before calling nextLevel.start() the mirroring mode is not taken into account.
https://github.com/NextLevel/NextLevel/blob/master/Sources/NextLevel.swift#L1758

If I set sharedInstance.mirroringMode = .on in the nextLevelSessionDidStart delegate the app crashes.

@cybercent
Copy link
Author

Meanwhile, if someone encounters the same issue, an alternate solution to obtain the video mirrored is to change the video configuration transform.

sharedInstance.videoConfiguration.transform = CGAffineTransform(scaleX: -1, y: 1)

@piemonte piemonte added the bug label Feb 24, 2017
@piemonte
Copy link
Contributor

piemonte commented Mar 1, 2017

hey @Slash7 thanks, much appreciated. i'll try fix this in my next free opportunity.

@piemonte
Copy link
Contributor

#68

hey @Slash7 this will fix one crash, may not fix the other you mention

@cybercent
Copy link
Author

👍🏻

@otymartin
Copy link

sharedInstance.videoConfiguration.transform = CGAffineTransform(scaleX: -1, y: 1)

this was the only thing that worked. setting mirroringMode has no effect.

@patthehuman
Copy link

How do you actually produce an instagram or snapchat style front facing session without flipping the users face?

@otymartin
Copy link

otymartin commented Nov 25, 2018

@patthehuman
My default device is .front

I set NextLevel.shared.mirroringMode = .on in my viewDidLoad

And do this in my delegate

public func nextLevelDevicePositionDidChange(_ nextLevel: NextLevel) {
        switch nextLevel.devicePosition {
        case .back:
           NextLevel.shared.videoConfiguration.transform = CGAffineTransform(scaleX: 1, y: 1)
        case .front:
            NextLevel.shared.videoConfiguration.transform = CGAffineTransform(scaleX: -1, y: 1)
        default:
            break
        }
    }

Works well.

@patthehuman
Copy link

@otymartin

thank you. I have implemented that. I am getting this error:

Method 'nextLevel(:didUpdateVideoZoomFactor:)' has different argument labels from those required by protocol 'NextLevelDeviceDelegate' ('nextLevel(:didChangeLensPosition:)')

Are you?

@otymartin
Copy link

@patthehuman You probably just wrote the delegate method wrong or have minor syntax error.. I would just copy these.

/// Video Zoom
  public func nextLevel(_ nextLevel: NextLevel, didUpdateVideoZoomFactor videoZoomFactor: Float) {}

  public func nextLevel(_ nextLevel: NextLevel, didChangeLensPosition lensPosition: Float) {}

@patthehuman
Copy link

This is not working for me actually

@otymartin
Copy link

@patthehuman

Can you show your code

@piv199
Copy link

piv199 commented Jun 11, 2021

videoConfiguration.transform = CGAffineTransform(x: -1, y: 1)

for me this produces videos with 180 degrees rotation (though they are opened normally in AVPlayer, QuickTime)

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

No branches or pull requests

5 participants