//获取本地视频的时间
    NSFileManager *fm = [[NSFileManager alloc]init];
    NSString *docs = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
    NSString *videofolder = [docs stringByAppendingPathComponent:[NSString stringWithFormat:@"VideoFolder/%@",self.foldername]];
    NSString *moviepath = [NSString stringWithFormat:@"%@/%@",videofolder,[movieArray objectAtIndex:indexPath.row]];
     int minute = 0, second = 0;
    if ([fm fileExistsAtPath:moviepath]) {
        AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:moviepath] options:nil];
       
        second = urlAsset.duration.value / urlAsset.duration.timescale; // 获取视频总时长,单位秒
        if (second >= 60) {
            int index = second / 60;
            minute = index;
            second = second - index*60;
        }
    }
    [fm release];

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-11
  • 2021-07-19
  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-19
相关资源
相似解决方案