I have a very specific issue and I have not yet found a solution. I have an IBAction for a button press. What I want to happen when this button is pressed is:
play a sound file (this is about 5 seconds long sound)
flash words on the screen (this is also about 5 seconds long)
I want this to happen concurrently so total time is about 5 seconds (words flashing while sound is playing).
What I end up with is that the words flash first, then the sound plays. I can never get them to go concurrently. Interestingly also I can never get the sound to play first even when placed at the very start of the action.
I've tried NSThread the sound, exec, CATransaction flush, but nothing can get them concurrent.
any ideas, btw I am total beginner programmer so sorry if not described the proper way.
-(IBAction) playButtonClick:(id)sender {
int i;
[_audioPlayer play];
for (i=0; i<10; i++){
[self.model getNextWord];
[self displayWord];
[CATransaction flush];
usleep(550000); // word on screen for 0.55 seconds
}
}
[CATransaction flush] is required else all I would see would be the very last word.