0

I have a presentation audio track playing in an iPhone app for which I want to show specific interactive "slides" at specific playback times. The reason why I cannot use video is that the slides are interactive (not just photos).

A developer recently said that you can't trust start playing an audio track and then display content triggered by a timer. The longer the track the more the timer will fire aside because media playback varies in real played length.

Are there callbacks which I can receive such as "arrived at playing time X:Y" or a callback that fires every played second?

Proud Member
  • 40,078
  • 47
  • 146
  • 231
  • @estobbart is on the money with this. You have to synchronize with callbacks from AudioUnit. Maintaining an NSTimer on a separate thread would never work reliably. – Max MacLeod Nov 15 '12 at 14:12

1 Answers1

2

An AudioUnit has a callback property you can set which you pass in an AURenderCallbackStruct. That callback will have a timestamp.

OSStatus YourAURenderCallack (
   void                        *inRefCon,
   AudioUnitRenderActionFlags  *ioActionFlags,
   const AudioTimeStamp        *inTimeStamp,
   UInt32                      inBusNumber,
   UInt32                      inNumberFrames,
   AudioBufferList             *ioData
);
estobbart
  • 1,137
  • 12
  • 28