iPhoneアプリのカメラにオーバーレイを作成したい.私はこのチュートリアルに従っています
しかし、それは画像のキャプチャについて教えてくれるので、ビデオの録画に実装する必要があります。
チュートリアルでは単純に
- (void)takePicture
{
[picker takePicture];
}
しかし、ビデオの録画に実装することはできません。できれば例を教えてください
オーバーレイなしで、ビデオを記録するためにこのコーディングを使用しています[上記のチュートリアルで実装したい]
-(void)ViewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUploadVideoProgress:) name:@"UPLOADPROGRESS" object:nil];
self.mediaTypes=[NSArray arrayWithObjects:(NSString *) kUTTypeMovie,nil];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
videoRecorder = [[UIImagePickerController alloc] init];
videoRecorder.sourceType = UIImagePickerControllerSourceTypeCamera;
videoRecorder.delegate = self;
NSArray *mediaTypes1 = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
NSArray *videoMediaTypesOnly = [mediaTypes1 filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(SELF contains %@)", @"movie"]];
if ([videoMediaTypesOnly count] == 0)
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Sorry but your device does not support video recording"
delegate:nil
cancelButtonTitle:@"OK"
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet showInView:[[self view] window]];
}
else
{
if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear])
videoRecorder.cameraDevice = UIImagePickerControllerCameraDeviceRear;
videoRecorder.mediaTypes = videoMediaTypesOnly;
videoRecorder.videoQuality = UIImagePickerControllerQualityType640x480;
videoRecorder.videoMaximumDuration = 30.0f;
appDelegate.videoOrientation = @"portrait";
[self presentModalViewController:videoRecorder animated:YES];
}
}
else
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Sorry but your device does not support video recording"
delegate:nil
cancelButtonTitle:@"OK"
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet showInView:[[self view] window]];
}
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
self.videoURL=[[info objectForKey:UIImagePickerControllerMediaURL] path];
self.videoData=[NSData dataWithContentsOfURL:[info objectForKey:UIImagePickerControllerMediaURL]];
[self dismissModalViewControllerAnimated:YES];
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType compare:(NSString*)kUTTypeMovie] == NSOrderedSame) {
NSURL *mediaUrl = [info objectForKey:UIImagePickerControllerMediaURL];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:mediaUrl];
moviePlayer.shouldAutoplay=NO;
UIImage *thumbnail = [moviePlayer thumbnailImageAtTime:0.0 timeOption:MPMovieTimeOptionNearestKeyFrame];
appDelegate.selectedVideo=[NSDictionary dictionaryWithObjectsAndKeys:
self.videoURL,@"videourl",
self.videoData,@"videodata",
thumbnail,@"thumbdata",
nil ];
}
AddOrEditVideoDetails *controller = [[AddOrEditVideoDetails alloc]initWithNibName:@"AddOrEditVideoView"bundle:nil];
[[self navigationController] pushViewController:controller animated:YES];
}