zoukankan      html  css  js  c++  java
  • 获取本地视频的时间IOS

    //获取本地视频的时间
        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];
  • 相关阅读:
    初试 Elastic Search
    索引分类
    Nginx
    LINQ入门
    CSS学习
    Keras 安装
    火车进站
    2016年网易笔试编程题2
    Java GC
    linux 安装 mysql
  • 原文地址:https://www.cnblogs.com/jiackyan/p/3110077.html
Copyright © 2011-2022 走看看