MPMoviePlayerViewController has aspect ration wrong for a split second - ios

I create a movie using UIImagePickerController using the following:
self.cameraUI = [[UIImagePickerController alloc] init];
self.cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
self.cameraUI.mediaTypes = #[(NSString *)kUTTypeMovie];
self.cameraUI.delegate = self;
self.cameraUI.videoQuality = UIImagePickerControllerQualityTypeMedium;
self.cameraUI.cameraDevice = UIImagePickerControllerCameraDeviceFront;
In the playback of the video I see that it looks good.
Then I try to load the movie with MPMoviePlayerViewController
self.player = [[MPMoviePlayerViewController alloc] initWithContentURL:self.chacha];
self.player.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[self presentMoviePlayerViewControllerAnimated:self.player];
For a split second when the movie view controller is presented the aspect ratio goes from warped to correct.
Anyone know what might be causing this? I have messed with settings for the movie controller and nothing there I have tried has helped.

Perhaps you could render it off-screen, or set it's Hidden property to YES until it finishes loading and you're sure the aspect ratio is correct.
I don't have much experience with that player.

Related

Camera photo mode fullscreen on iOS7

Is there a way to set the camera photo mode fullscreen on an iPod 5gen with iOS7.1? When you are going to take a photo, the photo mode is not in fullscreen, only the video mode is in fullscreen, so, is there a way to change it? (I think the same problem must happen on an iPhone 5 and greater).
Here is my code so far, it displays the control but partially, not fullscreen, and the control gets aligned to the top because the camera controls are removed from the view:
self.picker = [[UIImagePickerController alloc] init];
self.picker.delegate = self;
self.picker.allowsEditing = NO;
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.showsCameraControls = NO;
//self.picker.mediaTypes = mediaTypes; //just for the record
self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.picker.modalPresentationStyle = UIModalPresentationFullScreen;
self.picker.cameraOverlayView = [self buildOverlay]; //some custom views
[self presentViewController:self.picker animated:YES completion:NULL];
Thank you very much in advance.
Apply proper CGAffineTransform transformation in order to set camera mode.
Try out the following link this may help you:
here

Objective-C Camera Crop Size

I have a routine that I use to trigger the camera to take a photo. After the camera takes the photo the user is then given an option to crop the image by default before the delegate passes me back the UIImage. Is there any way that I can pass in a dynamic CGRect to make this default crop area a specific size? One thing I should mention is that the application is a landscape iPad application.
Here is a code sample:
-(void)triggerCamera:(id)sender
{
UIImagePickerController *camera = [[UIImagePickerController alloc] init];
camera.delegate = self;
camera.allowsEditing = YES;
camera.sourceType = UIImagePickerControllerSourceTypeCamera;
//pass in some sort of CGRect ??
[self presentViewController:camera animated:YES completion:NULL];
}
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info {
UIImage *img = [info objectForKey: UIImagePickerControllerOriginalImage];
//process my image further
}
Unfortunately you can't set crop size. I was dealing with same problem over 2 years ago and I got stuck with creating my own viewController for cropping image.
Maybe take a look at GKImagePicker on GitHub. This project hasn't had much activity in the past few months (maybe more), but could be worth a shot. It even comes with an option to have a resizable crop area. I have not tried it myself, but the implementation looks to be pretty simple:
self.imagePicker = [[GKImagePicker alloc] init];
self.imagePicker.cropSize = CGSizeMake(320, 90);
self.imagePicker.delegate = self;
[self presentModalViewController:self.imagePicker.imagePickerController animated:YES];

Setting Move and Scale Box for iOS

I have seen several apps that after you take a picture, it shows a view for Move and Scale your picture, with a box showing what the resulting image will look like. My app takes a picture the user takes or picks from library, and adds it to a PDF file. I need this file to be a certain size to fit on the PDF, so I need to set the move and scale box accordingly, but I cannot find any documentation on how to do this. Any suggestions?
Just set the UIImagePickerController instance's allowsEditing to YES.
_imagePickerController = [[UIImagePickerController alloc] init];
...
_imagePickerController.delegate = self;
_imagePickerController.allowsEditing = YES;
The UIImagePickerController picker ONLY performs 320x320 cropping.
Try using this: https://github.com/gekitz/GKImagePicker (GKImagePicker)
Sample Code:
self.imagePicker = [[GKImagePicker alloc] init];
self.imagePicker.cropSize = CGSizeMake(320, 90);
self.imagePicker.delegate = self;
[self presentModalViewController:self.imagePicker.imagePickerController animated:YES];

iPad take a shot with UIImagePickerController

I 'm trying to take a shot and it works, but with 2 problems. First, the pop over controller is displayed in a minimum size (it doesn't obey the setPopoverContentSize) and second and most important, the captured shot is only 640x640 pixels, whereas I want to be the maximum available (5MP).
What's the problem in the following code?
imgPicker = [[UIImagePickerController alloc] init];
imgPicker.delegate = self;
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imgPicker.showsCameraControls = YES;
pop = [[UIPopoverController alloc] initWithContentViewController:imgPicker];
pop.delegate = self;
CGRect re = CGRectMake(50,20,100,20);
CGRect re2 = CGRectMake(0,0,500,500);
[pop setPopoverContentSize:re2.size];
[pop presentPopoverFromRect:re inView:[self view] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Thanks a lot
You are setting the content size incorrectly. You don't call setPopoverContentSize: on the popover, you call it on the view controller that is displayed in the popover. In your case, set the content size of the image picker.
The image received from the image picker is the full sized image. Perhaps you are obtaining the edited image instead of the original image.

Camera with Custom View

My Application uses camera, I would like to add overlay over the camera preview. For example, I want to use a picture frame when I use Camera, also I would like to add a custom bar for camera operations. Kindly help me to do the same.
You might be trying using UIImagePickerController. But I know this one solution to your problem. You can do it easily using AVCamCaptureManager and AVCamRecorder classes. Apple has a demo program build on its developer site here. It is named AVCam. In simple words what it does is when you click to open the camera, it calls the classes and methods which are responsible for opening the iPhone's camera and record video or capture audio. It calls the same classes which are called by UIImagePickerController. So your camera will open and start taking input.
Now, if you open the xib file of that AVCam project, you'll find a small UIView object. This view is responsible for displaying the camera's feed. You can resize that view as per the size you want and the camera's input will be displayed in that much area. You can also put the frame image around it as per your choice.
It worked for me when I wanted to resize the camera's input feed and capture photos. I hope it works for you as well.
Create a UIImagePickerController from code, adjust its properties, add an overlay onto it, and with you controller, control whatever you want on that overlay : custom controls, overlaying images, etc...
That gives something like this :
self.picker = [[UIImagePickerController alloc] init];
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
self.picker.showsCameraControls = NO;
self.picker.navigationBarHidden = YES;
self.picker.toolbarHidden = YES;
self.picker.wantsFullScreenLayout = YES;
// Insert the overlay
self.overlay = [[OverlayViewController alloc] initWithNibName:#"Overlay" bundle:nil];
self.overlay.pickerReference = self.picker;
self.picker.cameraOverlayView = self.overlay.view;
self.picker.delegate = self.overlay;
[self presentModalViewController:self.picker animated:NO];
OverlayViewController is the controller that you must write to control everything you add onto the overlay.
pickerReference is a property you can keep to send orders to the camera. For example, you could call the following from an IBAction coming from a UIButton placed onto the overlay :
[self.pickerReference takePicture];
Read the UIImagePickerController Class Reference, that's right in the documentation…
There are properties for this, especially the cameraOverlayView and showsCameraControls properties.
So you can hide the controls, provide a custom overlay view, and add subviews to this custom view to add custom buttons, frames, etc.
Swift 3 version for answer from Oliver:
self.picker = UIImagePickerController()
self.picker.sourceType = .camera
self.picker.cameraCaptureMode = .photo
self.picker.cameraDevice = .rear
self.picker.showsCameraControls = false
self.picker.isNavigationBarHidden = true
self.picker.isToolbarHidden = true
// Insert the overlay
self.overlayViewController = self.storyboard?.instantiateViewController(withIdentifier: "Overlay") as! OverlayViewController
self.picker.cameraOverlayView = self.overlayViewController.view
self.picker.delegate = self.overlayViewController
self.navigationController?.present(self.picker, animated: true, completion: nil)
OverlayViewController protocols:
class OverlayViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate

Resources