Re: Callback when AUFilePlayer is finished?
Re: Callback when AUFilePlayer is finished?
- Subject: Re: Callback when AUFilePlayer is finished?
- From: David Duncan <email@hidden>
- Date: Tue, 17 Oct 2006 06:21:28 -0700
On Oct 17, 2006, at 04:32 AM, M. Uli Kusterer wrote:
I've managed to find the FilePlayer sample code I can use to
achieve nice playing of raw sound data. Now, I have a few things
even repeated Googles couldn't solve for me, so I hope someone here
can help me:
Is there any way I can get an AUFilePlayer (or the output unit in
my graph, or whatever) to notify me when it's finished playing
sound? I've found that the current play time will be -1 when it's
finished playing, so I could poll, but certainly there's a callback
somewhere I can register for to get that information?
Most code on the web assumes I'm feeding data into the Audio Units
myself, so I'll know when I'm at the end, but of course when I go
through FilePlayer that isn't the case.
Anyone know an alternative to polling the current play time?
Checkout the Audio Unit Events APIs. They are discussed in TechNote
2104 here: <http://developer.apple.com/technotes/tn2002/tn2104.html>
The basic jist of it is that you setup an audio event callback on
your file player to watch the kAudioUnitProperty_CurrentPlayTime
property on your file player, and it will notify you as the property
changes with time.
If you just care about knowing when it ends, you can set the
Notification Interval and Value Change Granularity exceptionally high
(on the order of the length of the file). If you have some UI to
update as well, I would probably set both to be half a second. Either
way it should reduce the amount of time you spend asking about the
property value.
--
Reality is what, when you stop believing in it, doesn't go away.
Failure is not an option. It is a privilege reserved for those who try.
David Duncan
_______________________________________________
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