【发布时间】:2013-01-17 09:54:45
【问题描述】:
现在我正在尝试获取 iOS 中歌曲的长度。
- (NSString *)returnofTotalLength
{
float duration = [[self.player.nowPlayingItem valueForProperty:MPMediaItemPropertyPlaybackDuration] floatValue]/60.0f;
NSString *length = [NSString stringWithFormat:@"%.2f",duration];;
NSString *totalLength = [length stringByReplacingOccurrencesOfString:@"." withString:@":"];
return totalLength;
}
上面的代码是显示类似5:90的歌曲的总长度。
你知道5:90 不可能是真的,因为60 秒是1 分钟。
应该是6:30。
所以我想限制 1 minute (60 seconds). 的值
我该怎么做请帮帮我?
谢谢。
【问题讨论】:
标签: ios cocoa-touch mpmediaitem