0

我正在尝试找到一种从 UIImagePickerController 上传视频的方法。下面的代码,它返回 0 长度的视频数据,但我肯定视频路径是正确的,因为它返回类似

/private/var/mobile/Applications/22318D96-B5B5-4C92-A8EB-869311275E40/tmp//trim.‌​AE6xnl.MOV

NSString *videoPath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
NSData *videoData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:videoPath ofType:@"mov"]];
int videoSize = [videoData length];
NSLog(@"Video path: %d", moviePath);
NSLog(@"Video size: %d", videoSize);

知道为pathForResource放置的正确参数是什么吗?

谢谢

4

1 回答 1

0

做这个:

NSURL* movieUrl = [info valueForKey:UIImagePickerControllerMediaURL];
NSData *videoData = [NSData dataWithContentsOfURL:movieUrl];
if(videoData)
{
   int videoSize = [videoData length];
  NSLog(@"Video path: %d", movieUrl);
  NSLog(@"Video size: %d", videoSize);
}
于 2012-08-15T08:38:22.763 回答