0
votes

I have an image animation with total duration of 2 seconds and in total 6 images. It's a blinking button. I want to play a sound every time that button blink, so in interval of 0.66 seconds by 3 times. I tried do this but the last sound play its a microsecond delay that i dont want..What i can do to play the sound right?

I'm doing this:

-(void)playAnswerAnimSound
{
    if(audioActive)
    {
        if(answerAnimCounter <3)
        {
            //AudioServicesDisposeSystemSoundID(answerAnimSound);
        AudioServicesPlaySystemSound(answerAnimSound);
            [answerAnimTimer invalidate];
        answerAnimTimer = [NSTimer scheduledTimerWithTimeInterval:0.6666 target:self selector:@selector(playAnswerAnimSound) userInfo:nil repeats:NO];
            answerAnimCounter++;
        }
        else if(answerAnimCounter == 3)
        {
            answerAnimCounter =0;
            [answerAnimTimer invalidate];
        }
    }
}

The sound duration is 1 second.

Regards

1
have a look at the linked answer, maybe can help: stackoverflow.com/questions/13765341/…rosco
Thank u for your help. i've read this answer before but not help me too much.mistic

1 Answers

0
votes

You cannot sync audio by just generating calls to audio services at time intervals, you need to actually render out a .wav or .m4a file with all the audio clips already spaced out in time. Then, playback the generated audio as 1 longer clip and sync the video to the audio. See the linked answer for more details about the implementation.