VideoData为空
我试图从UIImagePickerController上找到上传视频的方法。 下面的代码,它返回一个0长度的视频数据,但我肯定的是,视频路径是正确的,因为它返回类似于VideoData为空
/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?
感谢
回答:
这样做:
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);
}
以上是 VideoData为空 的全部内容, 来源链接: utcz.com/qa/260275.html