我知道有很多主题,但我找不到解决问题的方法 .
我有一个AVPlayerItem,我希望currentTime属性(CMTime)转换为我的音乐播放器的可读格式 .
这是我的代码:
NSDate *seconds = [[NSDate alloc] initWithTimeIntervalSinceNow:CMTimeGetSeconds(self.playerItem.currentTime)];
NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
[timeFormatter setDateFormat:@"HH:mm:ss"];
self.currentTimeLabel.text = [NSString stringWithFormat:@"%@", [timeFormatter stringFromDate:seconds]];
它有效,但它增加了1小时的播放时间 . 我怎么能减去那个小时?
谢谢!
2 回答
试试这段代码,
SWIFT代码:
delclare
然后在你想要的地方调用以下方法,
objective-C代码:
delclare
然后在你想要的地方调用以下方法,
它为我工作,希望它有所帮助
thx,我稍微改进了一下:
作品!