In order stream/parse M4A with AudioFileStream
, the m4a file needs to be optimized for streaming.
That means the header needs to be in the front of the file and has the correct information that will let your parser to do its job.
Some encoders will optimize the m4a for you, but some encoders wont. For example If you create an m4a file with itunes player, by simply right clicking and choosing "Create AAC Version", that will create an m4a file that is optimized for streaming.
You can check it by using http://ridiculousfish.com/hexfiend/
but if you use lets say encoding.com to encode your m4a files, you will get a different type of encoding.
they will both work when playing the whole file from disk but optimized version will be parsed/streamed correctly.
Now the error you are getting tells you that parser couldnt get the correct AudioStreamBasicDescription
from the file you are parsing, file probably refuse to give the bitrate info...
Try to take a look at this code for better understanding handling m4a types http://www.cocoawithlove.com/2010/03/streaming-mp3aac-audio-again.html