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

Start the viewController with front cam #10

Closed
vishalvshekkar opened this issue Jan 15, 2017 · 3 comments
Closed

Start the viewController with front cam #10

vishalvshekkar opened this issue Jan 15, 2017 · 3 comments

Comments

@vishalvshekkar
Copy link

Hey,

This is a wonderful library, thank you for this.

I have problem. I want to start my camera view controller with the front camera. If I invoke switchCamera() in viewDidLoad or viewWillAppear:animated, the app crashes with the following message:

[AVCaptureSession stopRunning] stopRunning may not be called between calls to beginConfiguration and commitConfiguration

I assumed that switchCamera() stopped the session when it was still being configured.

Then , I tried to set the currentCamera property to .front, but, that property's setter is private.

Am I missing a way to do this?

@Awalz
Copy link
Owner

Awalz commented Jan 16, 2017

Hey vishal,

You will not be able to call switchCamera() in viewDidLoad or viewWillAppear:animated. The AVCaptureSession is configured asynchronously in viewDidAppear, so it fail until it has finished configuring.

Currently, there is no way to configure SwiftyCam the way you are asking. I had not considered to add an option for the default. It is something I will add very soon in a future release.

In the meantime, if you need this functionality, you can manually add the source code in the project. on line 143 of SwiftyCamViewController, change the currentCamera to front:

private(set) public var currentCamera        = CameraSelection.front

Should do the trick in the meantime. Ill update this issue once I add the functionality.

Andrew

@Awalz
Copy link
Owner

Awalz commented Jan 16, 2017

I have updated the project to support this functionality. You should update your project to version 2.1.0. Then in your ViewDidLoad, change the defaultCamera property to .front:

override func viewDidLoad() {
   super.viewDidLoad()
   defaultCamera = .front
   ...
}

This should do the trick. Let me know if you have any other issues

Andrew

@Awalz Awalz closed this as completed Jan 16, 2017
@vishalvshekkar
Copy link
Author

Hey, thank you for this quick enhancement.

I had done some makeshift changes to make it work with the front cam by default, but, I'm going to pull your changes from v 2.1.0 now.

Have a good one.

Logikgate added a commit to flypapertech/SwiftyCam that referenced this issue Sep 22, 2021
I don't know the reason for this but the v8 runtime blows up when layerClass is exposed to objective-c.  It causes the MetadataBuilder::RegisterStaticMethods function to fail.

I tested this without exposing layerClass to objective-c and everything works fine.  This is key to fixing nstudio/nativescript-plugins#12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants