I have a simple mp3 playing through AVAudioPlayer and I want to be able to display how much time is left.
I know the answer includes subtracting AVAudioPlayer.dur
I use it in swift and it work:
// this for show remain time
let duration = Int((player1?.duration - (player1?.currentTime))!)
let minutes2 = duration/60
let seconds2 = duration - minutes2 * 60
durLabel.text = NSString(format: "%02d:%02d", minutes2,seconds2) as String
//this for current time
let currentTime1 = Int((player1?.currentTime)!)
let minutes = currentTime1/60
let seconds = currentTime1 - minutes * 60
curLabel.text = NSString(format: "%02d:%02d", minutes,seconds) as String