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.
精彩评论