【问题标题】:How can I get the mov play time second如何获得第二个 mov 播放时间
【发布时间】: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);                    

【问题讨论】:

    标签: iphone ios cocos2d-iphone


    【解决方案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 参考
    猜你喜欢
    • 2021-06-18
    • 2015-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-23
    • 1970-01-01
    相关资源
    最近更新 更多