简体   繁体   中英

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

You can do this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM