How do I get current playing time and total play time in AVPlayer?

Voloda2 picture Voloda2 · Nov 18, 2011 · Viewed 55.2k times · Source

Is it possible get playing time and total play time in AVPlayer? If yes, how can I do this?

Answer

Bartosz Ciechanowski picture Bartosz Ciechanowski · Nov 21, 2011

You can access currently played item by using currentItem property:

AVPlayerItem *currentItem = yourAVPlayer.currentItem;

Then you can easily get the requested time values

CMTime duration = currentItem.duration; //total time
CMTime currentTime = currentItem.currentTime; //playing time