保存我在我的应用程序中记录的视频 [英] Save a Video that I record in my app
本文介绍了保存我在我的应用程序中记录的视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我成功地了解了如何在我的学习之旅中制作相机应用程序:
I am succeeding in understanding how to make a camera app in my learning journey:-)
我只能保存一个视频记录。
The only thing I am stuck with is saving a video that I have recorded. I am able to save a photo, but the same does not work for videos.
因此,我几乎可以在iBrad应用程式的帮助下取得。
So I think I have almost got it with the help of iBrad Apps.
得到这个代码:
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
[self dismissModalViewControllerAnimated:YES];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
UIImage *image = [info
objectForKey:UIImagePickerControllerOriginalImage];
imageView.image = image;
if (newMedia)
UIImageWriteToSavedPhotosAlbum(image,
self,
@selector(image:finishedSavingWithError:contextInfo:),
nil);
}
else{
if ([mediaType isEqualToString:(NSString *)kUTTypeMovie]) {
UIImage *movie = [info
objectForKey:UIImagePickerControllerQualityTypeHigh];
videoRecorder2.image = movie;
if (newMedia)
UISaveVideoAtPathToSavedPhotosAlbum(movie,
self,
@selector(movie:finishedSavingWithError:contextInfo:),
nil);
}}}
我有一个if语句,因为应用程序可以同时接收视频和静止图像。
I have an if statement because the app can take both video and still images.
第一部分是为静止 - 其工作,然后第二部分我仍然训练: - )
The first part is for still - which works and then the second part I am still tutu-ing with:-)
推荐答案
尝试:
UISaveVideoAtPathToSavedPhotosAlbum(moviepath,nil,nil,nil);
编辑:尝试此操作并将您的代码修改为此方法:
Try this and modify your code to this method:
// For responding to the user tapping Cancel.
- (void) imagePickerControllerDidCancel: (UIImagePickerController *) picker {
[[picker parentViewController] dismissModalViewControllerAnimated: YES];
[picker release];
}
// For responding to the user accepting a newly-captured picture or movie
- (void) imagePickerController: (UIImagePickerController *) picker
didFinishPickingMediaWithInfo: (NSDictionary *) info {
NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
UIImage *originalImage, *editedImage, *imageToSave;
// Handle a still image capture
if (CFStringCompare ((CFStringRef) mediaType, kUTTypeImage, 0)
== kCFCompareEqualTo) {
editedImage = (UIImage *) [info objectForKey:
UIImagePickerControllerEditedImage];
originalImage = (UIImage *) [info objectForKey:
UIImagePickerControllerOriginalImage];
if (editedImage) {
imageToSave = editedImage;
} else {
imageToSave = originalImage;
}
// Save the new image (original or edited) to the Camera Roll
UIImageWriteToSavedPhotosAlbum (imageToSave, nil, nil , nil);
}
// Handle a movie capture
if (CFStringCompare ((CFStringRef) mediaType, kUTTypeMovie, 0)
== kCFCompareEqualTo) {
NSString *moviePath = [[info objectForKey:
UIImagePickerControllerMediaURL] path];
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath)) {
UISaveVideoAtPathToSavedPhotosAlbum (
moviePath, nil, nil, nil);
}
}
[[picker parentViewController] dismissModalViewControllerAnimated: YES];
[picker release];
}
这篇关于保存我在我的应用程序中记录的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文