1
votes

In my app I have a timer that counts down, and when it stops an image is displayed and a sound is played.

The sound is loaded like this:

NSString *path = [[NSBundle mainBundle] pathForResource:@"scream" ofType:@"wav"]; AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);

And Played like this on timer end:

AudioServicesPlaySystemSound(soundID);

My problem is that the sound doesn't get played on time. Even though the sound instance is called before the image, the image appears before the sound. This only occurs the first time the sound is played. The sound is loaded in the viewDidLoad method.

Is there a better way to do it, or what am I doing wrong?

Thanks...

1
maybe because I am running 3.0 Beta 2? Because after a fresh restart it runs fine...CC.
For timing issues like this, I prefer device testing. The simulator isn't always accurate in cases like these.Jab
yes it is device testing with Beta 2... I agree on the simulator part..CC.

1 Answers

1
votes

Maybe the sound is delayed while the speaker is powered up (for the first sound). If so, maybe you can work around it by playing a different, unnoticeable sound earlier so that the speaker is ready to go when you request the "real" sound.