AudioQueueStart is not the function that will help you to do that. The time there is like a delay, if you pass NULL then it means that the queue will start ASAP.
You have to pass the frame you want to play and enqueue it, to calculate that you have to know the number of frames your file has and the (relative) position you want to play.
This is an example how to do it in SpeakHere:
In AudioPlayer.h add an instance variable:
UInt64 totalFrames;
AudioPlayer.m inside
- (void) openPlaybackFile: (CFURLRef) soundFile
add:
UInt32 sizeOfTotalFrames = sizeof(UInt64);
AudioFileGetProperty (
[self audioFileID],
kAudioFilePropertyAudioDataPacketCount,
&sizeOfTotalFrames,
&totalFrames
);
Then add a method to AudioPlayer.h and .m
- (void) setRelativePlaybackPosition: (float) position
{
startingPacketNumber = totalFrames * position;
}
Now you have to use it (In AudioViewController add this and link it to a UIslider for example):
- (IBAction) setPlaybackPosition: (UISlider *) sender
{
float value = [sender value];
if (audioPlayer){
[audioPlayer setRelativePlaybackPosition: value];
}
}
When value is 0 you will play from the beggining, 0.5 from the middle, etc.
What happened? well, when you play files you need a callback function that is supposed to feed/fill the queue. In SpeakHere: this is inside AudioPlayer.m
static void playbackCallback (
void *inUserData,
AudioQueueRef inAudioQueue,
AudioQueueBufferRef bufferReference
)
Here you will use AudioFileReadPackets to read the part of the file you want to play. So calling [player startingPacketNumber] you will get the relative position (0 ~ 1) , hence that part of the file will be read and enqueued ready to be dequeued and played.
Hope this helps.