I'm trying to find a suitable technique for scrolling forward or searching the mp4 (or m4a) audio file while playing using the AudioFileStream and AudioQueue APIs on the iPhone.
If I transfer the full mp4 header (up to the mdat field) to an open AudioFileStream, the corresponding type of audio file will be correctly identified (in my case, AAC), and when I transfer the actual part of the data of the mdat file, AudioFileStream will correctly start generating audio packets and they can be sent in AudioQueue, and playback will work.
However, if I try to use the random access method to play the file, I cannot get it to work correctly, unless I send the first frame of the mdat block to AudioFileStream. If instead, after sending the mp4 header to AudioFileStream, I will then try to go to a later frame in mdat first, by calling AudioFileStreamSeek () first and then passing the data for the bundled packets, AudioFileStream seems to generate audio packets, but when I pass them to AudioQueue and I call AudioQueuePrime (), I always get the error "nope".
My question is this: do I always need to at least go through the first package in the mdat field before trying to randomly play other packages in the mp4 file?
I cannot find any documentation on randomly playing sections of the mp4 file when using AudioFileStream and AudioQueue. I found the Apple QuickTime File Format pdf, which describes the random search technique in the mp4 file, but it's just a high-level description and has no mention of using specific APIs (such as AudioFileStream).
Thanks for any ideas.
source
share