MPMusicPlayerController Track Length

2.6k Views Asked by At

Using an MPMusicPlayerController is there a way to query the tracks length?

Using .currentPlaybackTime I can figure out how far I am into the track but I have no way of knowing how long the track is.

My [MPMediaItem valueForProperty:MPMediaItemPropertyAssetURL] returns null for some tracks so using the AVAsset won't work for me.

1

There are 1 best solutions below

0
On BEST ANSWER

Easy just use

   NSNumber *duration=[item valueForProperty:MPMediaItemPropertyPlaybackDuration];