Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. let interval = CMTime(value: 1, timescale: 1)
  2. self.audioPlayer?.addPeriodicTimeObserver(forInterval: interval, queue: DispatchQueue.main, using: { (progressTime) in
  3.  
  4. let secondsProgress = CMTimeGetSeconds(progressTime)
  5.  
  6. let secondsStringProgress = String(format: "%02d", Int((secondsProgress.truncatingRemainder(dividingBy: 60))))
  7. let minuitesStringProgress = String(format: "%02d", Int(secondsProgress) / 60)
  8. //self.countDownLabel.text = "(minuitesStringProgress):(secondsStringProgress)"
  9.  
  10. if let duration = self.audioPlayer?.currentItem!.asset.duration {
  11.  
  12. let secondsDuration = CMTimeGetSeconds(duration)
  13.  
  14. let secondsStringDuration = String(format: "%02d", Int((secondsDuration.truncatingRemainder(dividingBy: 60))))
  15. let minuitesStringDuration = String(format: "%02d", Int(secondsDuration) / 60)
  16.  
  17. let secondsString = String(format: "%02d", Int(secondsStringDuration)! - Int(secondsStringProgress)!)
  18. let minuitesString = String(format: "%02d", Int(minuitesStringDuration)! - Int(minuitesStringProgress)!)
  19.  
  20. self.countDownLabel.isHidden = false
  21. self.countDownLabel.text = "(minuitesString):(secondsString)"
  22.  
  23. self.horizontalSlider.value = Float(secondsProgress / secondsDuration)
  24. self.circleSlider.value = Float(secondsProgress / secondsDuration)
  25.  
  26. }
  27. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement