我正试图找到一种从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 添加正确的参数是什么?
感谢
答案 0 :(得分: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);
}