0

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

What i have tried so far :

CMTime currentTime = [self.myAVQueuePlayerObject currentTime];

But it is returning the currently played duration of the currentItem located in the Queue.

What i want to achieve ?

I want to get the currentTime Played with respect to all the items present in the AVQueue Player , how can i do that ?

Any Help is Highly Appreciated.

Salman Khakwani
  • 6,684
  • 7
  • 33
  • 58

1 Answers1

1

Since AVQueuePlayer is inherited by AVPlayer...

Playing Time:

float currentTime = queuePlayer.currentTime;

Total Play Time:

Use KVO to observe the events of AVQueuePlayer (similar to this), and calculate the total play time of your queue yourself.

For total time of current playing song, you can use:

float duration = queuePlayer.duration;
Community
  • 1
  • 1
Raptor
  • 53,206
  • 45
  • 230
  • 366
  • Thanks for your quick response, `float currentTime = queuePlayer.currentTime;` will this line return the currentTime of the track that is being played currently or will this return the currentTime as comparison with all the items present in the Queue ? – Salman Khakwani Mar 05 '15 at 08:47
  • `currentTime` is current time of current playing item (song). – Raptor Mar 05 '15 at 08:52
  • Ok, so if i want to get the current Time with respect to All the items in the AVQueuePlayer then how will i manage to get it ? I am updating the question too – Salman Khakwani Mar 05 '15 at 08:54
  • 1
    You can calculate the played duration with a `float` variable. Just add them up. – Raptor Mar 05 '15 at 08:56