问题
I run the following code on simulator and I don't get any sound:
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"pageflip" ofType:@"mp3"];
NSURL *soundUrl = [NSURL fileURLWithPath:soundPath];
AudioServicesCreateSystemSoundID((__bridge CFURLRef) soundUrl, &_soundEffect);
AudioServicesPlaySystemSound(_soundEffect);
The code has been successfully tested on xCode 5 and iOS 7. Libraries imported as required.
I've logged the soundPath and it returns the correct location on the filesystem.
Has anyone experienced a similar issue?
回答1:
This is an issue with the simulator. On a device it'll work as expected.
回答2:
I have a similar issue now. My AudioServicesPlaySystemSound was working until the XCode update to 6.0.1. One could assume that there is something broken in the update.
来源:https://stackoverflow.com/questions/25859337/audioservicesplaysystemsound-muted-on-simulator-xcode-6-gm