如何获得第二个 mov 播放时间

Posted

技术标签:

【中文标题】如何获得第二个 mov 播放时间【英文标题】:How can I get the mov play time second 【发布时间】:2012-08-17 04:13:31 【问题描述】:

为什么第二个 num 是 0.00000 和底部进程

 NSURL    *movieURL = [NSURL URLWithString:@"s26a.mov"];

NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]
                                                                   forKey:AVURLAssetPreferPreciseDurationAndTimingKey];                    
 AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:movieURL options:opts]; 
 float minute = 0;
 float second = 0; 
 second = urlAsset.duration.value / urlAsset.duration.timescale; 
 NSLog(@"movie duration : %f", second);                    

【问题讨论】:

【参考方案1】:

您可以像这样获得电影时长:

 Float64 durationSeconds = CMTimeGetSeconds([urlAsset duration]); // any AVURLAsset 

【讨论】:

你的意思是这样吗? NSURL *movieURL = [NSURL URLWithString:@"s26a.mov"]; NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:AVURLAssetPreferPreciseDurationAndTimingKey]; AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:movieURL options:opts]; Float64 durationSeconds = CMTimeGetSeconds([urlAsset duration] // 任何 AVURLAsset 是这样的。完美,除非您创建了 urlAsset 参考

以上是关于如何获得第二个 mov 播放时间的主要内容,如果未能解决你的问题,请参考以下文章