I have the following code to attempt to show the time elapsed of my audio file:
func updateTime() {
let currentTime = Int(player!.currentTime().value)
let minutes = currentTime/60
print(minutes)
let seconds = currentTime - minutes * 60
print(seconds)
time.text = NSString(format: "%02d:%02d", minutes,seconds) as String
}
The timer is set in this code in view did load:
play.play()
timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(.updateTime), userInfo: nil, repeats: true)
There are numbers displayed in the lable but they are completely random, so no display of seconds and minutes. What am I doing wrong here? Is it the way I am getting the current Time?