【问题标题】:Get length of video after dismissing UIImagePicker?关闭 UIImagePicker 后获取视频长度?
【发布时间】:2011-12-22 23:01:42
【问题描述】:

我想获取用户选择的视频的长度。我正在使用苹果 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

【问题讨论】:

标签: iphone objective-c ios nsdata


【解决方案1】:

你可以这样做

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

【讨论】:

  • 好的,我将如何处理 NSLogging 呢? i NSLogged 为 %i 并为 19 秒的视频获得 600。我也尝试 NSLogging 它作为 %@ 并崩溃了。我希望能够将其转换为秒。顺便说一句,谢谢您的回答。
猜你喜欢
  • 2011-09-07
  • 2011-09-07
  • 1970-01-01
  • 2016-07-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-17
相关资源
最近更新 更多