Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get video full duration and current playing time?

Tags:

ios

swift

video

I need to create a custom video plugin using swift. But I don't know how to get video full duration and current playing time. In my console just appeared this output, C.CMTime. I'm not sure what wrong with my code.

My code

let url = NSBundle.mainBundle().URLForResource("Video", withExtension:"mp4")
let asset = AVURLAsset(URL:url, options:nil)
let duration: CMTime = asset.duration

println(duration)
like image 282
Nurdin Avatar asked Jul 01 '15 09:07

Nurdin


1 Answers

You can use CMTimeGetSeconds to converts a CMTime to seconds.

let durationTime = CMTimeGetSeconds(duration)
like image 177
NSDeveloper Avatar answered Oct 25 '22 09:10

NSDeveloper