Voloda2 Voloda2 - 3 months ago 46
iOS Question

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

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

Answer

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