在解雇UIImagePicker后获取视频长度?

时间:2011-11-06 06:32:49

标签: iphone objective-c ios nsdata

我想获得用户选择的视频的长度。我正在使用苹果UIImagePicker,

到目前为止,这是我的代码:

    [self dismissModalViewControllerAnimated:YES];
//assign the mediatype to a string 
//check the media type string so we can determine if its a video
    NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
    webData = [[NSData alloc]init];
    webData = [NSData dataWithContentsOfURL:videoURL];
    //[self post:webData];
    video = 1;
    upload.hidden = NO;

    ImagesCopy = [[NSMutableArray alloc]initWithObjects:@"1", nil];
[tableview reloadData];

谢谢:D

1 个答案:

答案 0 :(得分:6)

你可以这样做

AVAsset *movie = [AVAsset assetWithURL:[info objectForKey:UIImagePickerControllerMediaURL]];
CMTime movieLength = movie.duration;