AUFilePlayer, checking when its finished playing
AUFilePlayer, checking when its finished playing
- Subject: AUFilePlayer, checking when its finished playing
- From: GW Rodriguez <email@hidden>
- Date: Tue, 26 Oct 2010 22:02:40 -0400
Hi everyone, quick question regarding the AUFilePlayer. I want to know if there is a better way to determine when a region of audio is complete then the way I'm doing it. Here's my method:
-(void) fileHasEnded:(NSTimer *) timer {
if (fileIsPlaying) {
Float64 endTime = audioRegion.mStartFrame + audioRegion.mFramesToPlay;
UInt32 size = sizeof(currentTime);
CheckError(AudioUnitGetProperty(fileAU,
kAudioUnitProperty_CurrentPlayTime,
kAudioUnitScope_Global,
0,
¤tTime,
&size),
"Getting fileAU current playtime for fileHasEnded failed", kLine);
if (currentTime.mSampleTime >= endTime)
[self stop];
}
}
Basically I have added this method to the current run loop. It calculates the end time in frames and then gets the property kAudioUnitProperty_CurrentPlayTime. I then check that value with the known end time, once the current time is >= to the end time then i call my stop method.
Any better, or should I say more efficient, ways to accomplish this query?
- GW
_______________________________________________
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