Reputation: 40506
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?
Upvotes: 0
Views: 876
Reputation: 1145
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
);
Upvotes: 2