Can anyone answer how to play mp3 files using AudioServicesCreateSystemSoundID()
? I tried but not working.
I have used the following code snippet for playing mp3
NSURL *soundURL = [[NSBundle mainBundle] URLForResource:fileName withExtension:extension];
soundFileURLRef 开发者_StackOverflow中文版= (CFURLRef) [soundURL retain];
// Create a system sound object representing the sound file.
AudioServicesCreateSystemSoundID ( soundFileURLRef,&soundFileObject);
I had the same problem using this example. Maybe your sound sample is to big/long.
NSString *path = [[NSBundle mainBundle] pathForResource:@"tap" ofType:@"aif"];
NSURL *url = [NSURL fileURLWithPath:path];AudioServicesCreateSystemSoundID((__bridge CFURLRef)url, &mBeep);
AudioServicesPlaySystemSound(mBeep);
It was not working because the audio file was to long. I tried with the sound from the apple example http://developer.apple.com/library/ios/#samplecode/SysSound/Introduction/Intro.html "tap.aif" and it worked fine.
精彩评论