Re: How do you pause, stop and reset an AUFilePlayer in IOS5?
Re: How do you pause, stop and reset an AUFilePlayer in IOS5?
- Subject: Re: How do you pause, stop and reset an AUFilePlayer in IOS5?
- From: Aran Mulholland <email@hidden>
- Date: Thu, 19 Jul 2012 09:36:10 +1000
You can't pause the AUFilePlayer. What you can do is call something like
AudioTimeStamp ts;
UInt32 size = sizeof(ts);
AudioUnitGetProperty(filePlayerUnit_,
kAudioUnitProperty_CurrentPlayTime, kAudioUnitScope_Global, 0, &ts,
&size);
Float64 sampleFrame = ts.mSampleTime;
to get the currently playing sample frame, then call
AudioUnitReset(filePlayerUnit_, kAudioUnitScope_Global, 0);
To stop it and if you want to resume playback (from pause), schedule a
new region with the sample time you had before you called
AudioUnitReset. Be nice if it had a pause, but not hard to implement
yourself.
Aran
On Thu, Jul 19, 2012 at 7:06 AM, Beleg Da'Bear <email@hidden> wrote:
> I am working with core audio using an AUFilePlayer to load a few mp3s into a
> mixer unit, everything plays great however I am unable to pause the music or
> rewind the music back to the start. I tried Starting and stopping the
> AudioGraph, but once the playback is stopped, I can't get it to restart. I
> also tried using AudioUnitSetProperty to set the file playback to 0
> i.e something along these lines:
>
> 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 = inputFile;
> rgn.mLoopCount = 1;
> rgn.mStartFrame = 0;
>
> rgn.mFramesToPlay = nPackets * inputFormat.mFramesPerPacket;
>
> AudioUnitSetProperty(fileUnit,
> kAudioUnitProperty_ScheduledFileRegion,
> kAudioUnitScope_Global, 0,&rgn, sizeof(rgn));
>
> Any suggestions?
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden