开发者

Showing duration of a song in uilabel or uitextfield

I am developing a music player application. I have picked music files from the ipod library, and is playing them. I'm using AVAudioPlayer for this. What i need n开发者_如何学Cow is to show the duration of the song on the top of the view. I got the duration as

NSTimeInterval *duration = [musicplayer duration];

But i dont know how to use it to display on the view, on uilabel or uitextfield. Or even using any other value. Pls help..


Assuming label is your UILabel, try this:

label.text = [NSString stringWithFormat:@"%lf", duration];

Or, if you want it in minute:seconds

label.text = [NSString stringWithFormat:@"%d:%d", (int) (x / 60), ((int) x % 60)]

String formatting is your friend here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜