I am trying to play a sound when a button it tapped and am using the iOS 5 file player audio unit.
The file player plays audio using the ScheduledAudioFileRegion and can be scheduled to play as many frames as needed
ScheduledAudioFileRegion rgn;
memset (&rgn.mTimeStamp, 0, sizeof(rgn.mTimeStamp));
rgn.mTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
rgn.mTimeStamp.mSampleTime = 0;
rgn.mCompletionProc = NULL;
rgn.mCompletionProcUserData = NULL;
rgn.mAudioFile = audioFile;
rgn.mLoopCount = INT_MAX;
rgn.mStartFrame = 0;
rgn.mFramesToPlay = nPackets * fileASBD.mFramesPerPacket; // plays entire file.
How can I tell this file player to play the sound from the start whenever a button is pressed, or do I have to create a new region and memset it each time? I would like the sound to play when the button is pressed from start to finish but when the button is tapped again, it should start from the beginning even if the file is currently playing. Is this possible with the fileplayer audio unit?