Hello, I have set up part of my app to play a sound. Simple - but only is working in Simulator.
Initing audio session this way:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
}
AudioSessionInitialize(NULL,NULL,NULL,NULL);
AudioSessionSetActive(YES);
return self;
}
Playing sound, setting completion calback, and checking for file this way:
NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:@"mp3"];
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
AudioServicesAddSystemSoundCompletion (soundID,NULL,NULL,
completionCallback,
(void*) self);
if([[NSFileManager defaultManager] fileExistsAtPath:path])
{
NSLog(@"Playing Sound" );
AudioServicesPlaySystemSound(soundID);
}
else {
NSLog(@"NO SOUND");
}
In Simulator, the file is found, sound plays, and completion happens. In device, file is found, sound does not play, and completion is never called.
Any ideas? Thank you very much, both my forehead and my desk appreciate any replies...:)