views:

232

answers:

1

Using CoreAudio, I am able to get the sampleRate (frames per second) and the file size, but in order to get the "total" time of the song, I need to know the Real file size of that compressed mp3.

  AudioStreamBasicDescription asbd;
  UInt32 asbdSize = sizeof(asbd);

  // get the stream format.
  err = AudioFileStreamGetProperty(inAudioFileStream, kAudioFileStreamProperty_DataFormat, &asbdSize, &asbd);
  if (err)
  {
   [self failWithErrorCode:AS_FILE_STREAM_GET_PROPERTY_FAILED];
   return;
  }

  sampleRate = asbd.mSampleRate;

Is there any way I can know the real size of the song using Objective-C?

Thanks in advance.

+1  A: 

See the answer to this question

There's a property you can ask in AudioFileGetProperty called kAudioFilePropertyEstimatedDuration that should do the trick.

pgb
hi pgb, I looked at your answer on the other post u linked to, but I always got the outDataSize to be 0 every time. Can you help me with this? thanks
SimpleCode
Can you post more code? How do you open the file, etc.?
pgb