假设我从 iPhone 库中获取了一个视频文件。我想检查视频文件不应大于 2MB。
我无法使用 videoMaximumDuration 方法。因为如果任何视频是高清质量的,即使是 1 分钟持续时间的视频也可能会很大。
有什么意见吗?
urlvideo 包含所选视频文件的 url
NSString *strurl=[urlvideo path];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:strurl error:nil];
if(fileAttributes != nil)
{
NSString *fileSize = [fileAttributes objectForKey:NSFileSize];
//NSLog(@"File size: %@ kb", fileSize);
if ([fileSize intValue] > 2000000) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"File size greater than 2MB.Please select another video file." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
else {
NSLog(@"video size less than 2 mb");
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)