Jacob
Jacob

Reputation: 1459

Get length of video after dismissing UIImagePicker?

i want to get the length of a video that the user picks. Im using apples UIImagePicker,

here is my code so far:

    [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];

Thanks :D

Upvotes: 2

Views: 1580

Answers (1)

Rich86man
Rich86man

Reputation: 6557

You can do this

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

Upvotes: 7

Related Questions