daily pastebin goal
83%
SHARE
TWEET

Untitled

a guest Jan 14th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   func timeObserver() {
  2.  let interval = CMTimeMake(1, 2)
  3.          let timeObserverToken = avPlayer?.addPeriodicTimeObserver(forInterval: interval, queue: DispatchQueue.main) { [weak self] time in
  4.   let seconds = CMTimeGetSeconds(time)
  5.             let secondsTime = Int(seconds.truncatingRemainder(dividingBy: 60.0))
  6.            
  7.             let MinutesTime =  Int(seconds/60)
  8.  
  9.             if let duration = self?.avPlayer?.currentItem?.duration {
  10.                     let durationTime = CMTimeGetSeconds(duration)
  11.                      let AllTime = self?.avPlayer?.currentItem?.duration.seconds
  12.                         var min = "0:00"
  13.                          var startTimeHere = "0:00"
  14.      
  15.                if ((AllTime?.isNaN)!) {
  16.                     print("is nan")
  17.                } else {
  18.                     let durationMin = (Int(AllTime!) % 3600) / 60
  19.                         let durationSec = (Int(AllTime!) % 3600) % 60
  20.                              min = "\(durationMin):\(durationSec)"
  21.                                  startTimeHere = "\(MinutesTime):\(secondsTime)"
  22.                 }
  23.                
  24.                  print("time observ " + String(describing: time))
  25.                  self?.timeDelegate?.changeTimeSlider(time: Float(seconds / durationTime), start: startTimeHere, duration: String(min))
  26.  
  27.             }
  28.         }
  29.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top