priore

CMTime extension to retrieve Seconds and time in String format (HH:mm:ss)

Oct 8th, 2020
997
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extension CMTime {
  2.    
  3.     var seconds: Int {
  4.         return Int(CMTimeGetSeconds(self))
  5.     }
  6.  
  7.     var string: String {
  8.         let value = self.seconds
  9.         let hours = (value % 86400) / 3600
  10.         let minutes = (value % 3600) / 60
  11.         let seconds = (value % 3600) % 60
  12.         return String(format: "%02d:%02d:%02d", hours, minutes, seconds)
  13.     }
  14. }
RAW Paste Data