objective-cioscocoa-touchavfoundationipod

AVAssetReader samplerate


How do I calculate the samplerate of a song obtained from the iPod Library using AVAssetReader. I think I can pretty easily get the amount of samples, ( I am already successfully reading the samples anyways.. ), but I do not know where I can obtain the length ( in seconds ) of the song.

Note that MPMediaItem has no property for the length of the Media Item, maybe there is another way through this API to get the length of the item?


Solution

  • You can use MPMediaItem to get the length. Have a look at the MPMediaItemPropertyPlaybackDuration property key. The docs state:

    The playback duration of the media item. Value is an NSNumber object representing a duration in seconds as an NSTimeInterval.