Skip to content

Instantly share code, notes, and snippets.

@cacheleocode
Last active December 10, 2018 13:40
Show Gist options
  • Save cacheleocode/001877922a3e75825aa3e77bb776b678 to your computer and use it in GitHub Desktop.
Save cacheleocode/001877922a3e75825aa3e77bb776b678 to your computer and use it in GitHub Desktop.
self.randomNum = arc4random_uniform(15) // range
self.someInt = Int(self.randomNum!)
self.someDouble = Double(self.someInt!) / 10
self.someCMTime = CMTime(seconds: someDouble!, preferredTimescale: 90000)
debugPrint(self.player.currentItem!.asset.duration)
if ((self.someCMTime?.seconds)! > self.player.currentItem!.asset.duration.seconds) {
debugPrint("too much!")
} else {
debugPrint(self.someCMTime!.seconds)
}
self.player.seek(to: self.someCMTime!)
print("duration in seconds = \(self.player.currentItem!.asset.duration.seconds)")
// print("timescale = \(self.player.currentItem!.asset.duration.timescale)")
self.someCMTime = self.player.currentItem!.asset.duration
self.someCMTime = CMTimeMakeWithSeconds(self.getRandomDouble(limit: self.player.currentItem!.asset.duration.seconds), preferredTimescale: self.player.currentItem!.asset.duration.timescale)
// self.someCMTime = CMTime(seconds: self.getRandomDouble(limit: self.player.currentItem!.asset.duration.seconds), preferredTimescale: self.player.currentItem!.asset.duration.timescale)
print("random time = \(Double((self.someCMTime?.seconds)!))")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment