• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Detecting file completion of AUAudioFilePlayer playback
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting file completion of AUAudioFilePlayer playback


  • Subject: Re: Detecting file completion of AUAudioFilePlayer playback
  • From: Doug Wyatt <email@hidden>
  • Date: Tue, 1 Dec 2009 18:55:22 -0800

On Dec 1, 2009, at 0:59 , Björn Kempen wrote:

> Hi, I'm working on an app which uses an AUAudioFilePlayer audio unit
> and I just can't seem to find a way to get a callback once the file
> has finished playing.
>
> Looking through the docs in AudioUnitProperties.h revealed something a
> bit weird.
>
> The docs first claim "The unit is a subclass of AUScheduledSoundPlayer
> and inherits all of its "behavior.".
> However, in the Completion Callbacks section, it seems like
> mCompletionProc does something completely different.

I guess that could be described as an "override" to the inherited behavior :-/

> In other words, it seems like the callback is called when the
> scheduled sound of an AUScheduledSoundPlayer has finished playing, but
> it will be called prior to that (since the scheduling will be
> completed before the playback) for AUAudioFilePlayer.
>
> My usage of mCompletionProc on an AUAudioFilePlayer confirms this,
> which is sortof bad since I'd rather not have to resort to polling the
> player to find out when the sound has finished playing.
>
> Anyone has any ideas how to detect when playback has finished?

As a general approach, you can keep track of how many sample frames you schedule for playback (plus any gaps between regions), and the device sample time at which the AU starts. When the current playback sample time (on the device timeline) reaches start_time + frames_scheduled, or if it simply reaches frames_scheduled on the playback timeline, then you've reached the end.

Doug

 _______________________________________________
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

References: 
 >Detecting file completion of AUAudioFilePlayer playback (From: Björn Kempen <email@hidden>)

  • Prev by Date: Re: Notification of Audio Queue playback
  • Next by Date: Re: Audio recording bitdepth
  • Previous by thread: Detecting file completion of AUAudioFilePlayer playback
  • Next by thread: how to set inputs and outputs in the AUmixer?
  • Index(es):
    • Date
    • Thread