我是iOS开发中的新手。我正在尝试从应用程序的文档目录中的相机相册中获取所有照片和视频,然后尝试压缩它们。 我只能获取照片而不能获取视频。请告诉我如何获取视频。 这就是我的代码寻找照片的方式。我也尝试过使用MediaPlayer和MobileCoreServices框架。但它有效。请帮我一个适合我现在代码的代码。
- (void) imagePickerController:(RImagePickerController *)imagePickerController didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSArray *rootDocumentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
rootDocumentsDirectory = [rootDocumentPath objectAtIndex:0];
selectedImagesPath = [rootDocumentsDirectory stringByAppendingString:@"/Selected Images"];
[[NSFileManager defaultManager]createDirectoryAtPath:selectedImagesPath withIntermediateDirectories:NO attributes:nil error:nil];
if (imagePickerController.allowsMultipleSelection)
{
mediaInfoArray = (NSArray *)info;
for (i =0; i<mediaInfoArray.count ; i++)
{
NSData *data = UIImageJPEGRepresentation([[mediaInfoArray objectAtIndex:i] objectForKey:@"UIImagePickerControllerOriginalImage"], 1.0);
NSString *fileNameCount = [NSString stringWithFormat:@"%@/Image%d.png",selectedImagesPath,i];
[data writeToFile:fileNameCount atomically:YES];
}
NSLog(@"Selected %d photos", mediaInfoArray.count);
}
NSDictionary *mediaInfo = (NSDictionary *)info;
NSLog(@"Selected: %@", mediaInfo);
[self dismissViewControllerAnimated:YES completion:NULL];
}