0

I want use iphone camera for tacking photo or videos.

I know how to open JUST Photo Camera, and JUST Video Camera, but i don't know how to launch both in the same time.

Can i use UIImagePickerController to open both in the same time or i need create a custom view?

Below is code used just for Photo Camera and Video Camera

-(void)photoCameraButtonAction{
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

        imagePicker = [[UIImagePickerController alloc] init];
        imagePicker.delegate = self;
        imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

        [self presentViewController:imagePicker animated:YES completion:nil];
    }
}

-(void)videoCameraButtonAction{

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

        imagePicker = [[UIImagePickerController alloc] init];
        imagePicker.delegate = self;
        imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

        NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
        NSArray *videoMediaTypesOnly = [mediaTypes filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(SELF contains %@)", @"movie"]];

        imagePicker.mediaTypes = videoMediaTypesOnly;
        imagePicker.videoQuality = UIImagePickerControllerQualityTypeMedium;
        imagePicker.videoMaximumDuration = 180;

        [self presentViewController:imagePicker animated:YES completion:nil];
    }
}

Thank you!

Gaby Fitcal
  • 1,814
  • 1
  • 17
  • 28
  • The same physical camera is used for both. The primary difference is the settings for basically everything. Video is lower resolution, and it has to be tracking motion better, which means faster shutter speeds. I'm not a photography buff or anything like that, but I do know you can't do both at the same time with good results. You can record video and capture frames as photos. It's not really the same, though. – Avi Nov 20 '15 at 09:23
  • You can create a custom view and show one on another view thats smaller inside, on the custom view give user button to choose between image and photo picker, might read more in [here](http://stackoverflow.com/questions/17918584/ios-uiimagepickercontroller-set-frame) – Tj3n Nov 20 '15 at 11:24

1 Answers1

2

You can do it like that

        let picker = UIImagePickerController()
        picker.delegate = self
        picker.sourceType = .camera
        picker.mediaTypes = [kUTTypeMovie as String,kUTTypeImage as String]
        self.present(picker, animated: true, completion: nil)
hmlasnk
  • 1,160
  • 1
  • 14
  • 33