如何放置检查视频文件是否大于2MB? [英] How to place check whether Video file is greater than 2MB?

查看:59
本文介绍了如何放置检查视频文件是否大于2MB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我从iphone库中获取了一个视频文件.我想检查一下视频文件不应大于2MB.

Suppose I have taken a video file from iphone library. I want to put a check that Video file shouldn't be greater than 2MB.

我不能使用videoMaximumDuration方法.因为如果任何视频都是高清质量的,那么即使是1分钟长的视频也可能会很大.

I cant use videoMaximumDuration method. Because if any video is hd quality even 1 min duration video could be huge in size.

任何意见?

推荐答案

urlvideo包含所选视频文件的网址

            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");
    }

这篇关于如何放置检查视频文件是否大于2MB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆