Created
September 28, 2017 07:03
-
-
Save leilee/aebadc13e227c02defc29f43a27c5868 to your computer and use it in GitHub Desktop.
Present UIImagePickerController for capture video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)showCamera | |
{ | |
auto showCamera = ^{ | |
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) | |
{ | |
// TODO: alert | |
return; | |
} | |
auto availableMediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera]; | |
if (![availableMediaTypes containsObject:(NSString*)kUTTypeMovie]) | |
{ | |
// TODO: alert | |
return; | |
} | |
auto camera = [[UIImagePickerController alloc] init]; | |
camera.sourceType = UIImagePickerControllerSourceTypeCamera; | |
camera.mediaTypes = @[ (NSString*)kUTTypeMovie ]; | |
camera.showsCameraControls = YES; | |
camera.videoQuality = UIImagePickerControllerQualityTypeIFrame1280x720; | |
camera.delegate = self; | |
[self presentViewController:camera animated:YES completion:nil]; | |
}; | |
[OUPPhotoLibrary up_authorizeVideoRecord:^(BOOL granted) { | |
if (granted) | |
{ | |
showCamera(); | |
} | |
else | |
{ | |
// TODO: alert | |
} | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment