我想在我的 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];
}