I'm attempting to play a sound using AVAudioPlayer. Should be simple, but I'm seeing some odd results.
Code:
NSString *path = [[NSBundle mainBundle] pathForResource:@"pop" ofType:@"wav"];
NSURL *url = [NSURL fileURLWithPath:path];
AVAudioPlayer *sound = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
[sound play];
[sound release];
What I'm seeing is that the sound doesn't play when using the app normally.
It plays only if I step through the code using the debugger, it doesn't play when executing any other way...
I'm not creating any new threads or run loops within my app, so this should all be running on the main thread, at least [NSThread isMainThread]
returns true.
Anyone got any ideas as to what is going on here?