CMTime秒输出
这可能看起来很荒谬,但是我怎么能把CMTime的秒数输出到Objective-C的控制台? 我只需要按时间分割的值,然后以某种方式在控制台中看到它。
NSLog(@"seconds = %f", CMTimeGetSeconds(cmTime));
简单:
NSLog(@"%lld", time.value/time.timescale);
如果你想以hh:mm:ss
格式转换,那么你可以使用这个
NSUInteger durationSeconds = (long)CMTimeGetSeconds(audioDuration); NSUInteger hours = floor(dTotalSeconds / 3600); NSUInteger minutes = floor(durationSeconds % 3600 / 60); NSUInteger seconds = floor(durationSeconds % 3600 % 60); NSString *time = [NSString stringWithFormat:@"%02ld:%02ld:%02ld", hours, minutes, seconds]; NSLog(@"Time|%@", time);
CMTime currentTime = audioPlayer.currentItem.currentTime; float videoDurationSeconds = CMTimeGetSeconds(currentTime);