【发布时间】:2015-01-23 05:34:27
【问题描述】:
我正在向聊天应用程序添加视频。用户可以分享从他们的文件中选择的视频,也可以录制一个新视频以上传。
我遇到的问题是区分刚刚录制的视频和已选择的视频,因为我想在他们上传刚刚录制的视频时将其保存到他们的相册中。
目前我的代码如下所示:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// This checks whether we are adding image or video (public.movie for video)
if ([[info objectForKey:UIImagePickerControllerMediaType] isEqualToString:@"public.image"]) {
UIImage * image = [info objectForKey:UIImagePickerControllerEditedImage];
[self sendImage:image];
}
else {
// SS-V
// If we are dealing with a video then we want to return to the chat view and post the video
NSURL * videoURL = (NSURL *)[info objectForKey:UIImagePickerControllerMediaURL];
// Send video to the chat view
[self sendVideo:[videoURL absoluteString]];
}
[tableView reloadData];
[picker dismissViewControllerAnimated:YES completion:Nil];
}
所以我正在获取视频的本地 url,然后将其上传到外部数据库。
我也有这个代码:
// Save the recorded video to the iPhone
NSString * videoCompatibleString = [videoURL.absoluteString stringByReplacingOccurrencesOfString:@"file://" withString:@""];
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(videoCompatibleString)) {
UISaveVideoAtPathToSavedPhotosAlbum (videoCompatibleString, self, nil, nil);
}
这会将它保存到我的手机库中。
所以现在我唯一的问题是如何区分刚刚拍摄的视频和已经从我的库中选择的视频。
【问题讨论】:
标签: ios objective-c video