今天看啥
热点:

ios 获取视频的总时长,ios获取视频


NSURL    *movieURL = [NSURL URLWithString:movieStr];
                    NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]
                                                                     forKey:AVURLAssetPreferPreciseDurationAndTimingKey];                    
                    AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:movieURL options:opts];  // 初始化视频媒体文件
                    int minute = 0, second = 0; 
                    second = urlAsset.duration.value / urlAsset.duration.timescale; // 获取视频总时长,单位秒
                    //NSLog(@"movie duration : %d", second);                    
                    if (second >= 60) {
                        int index = second / 60;
                        minute = index;
                        second = second - index*60;                        
                    }    

注意添加AVFoundation框架


www.bkjia.comtruehttp://www.bkjia.com/Androidjc/986898.htmlTechArticleios 获取视频的总时长,ios获取视频 NSURL*movieURL = [NSURL URLWithString:movieStr]; NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]...

相关文章

相关搜索: 苹果电脑

帮客评论

视觉看点