#import <AudioToolbox/AudioToolbox.h>
....
@property (assign,nonatomic)SystemSoundID soundId;
...
-(IBAction)testSound:(id)sender {
if (_soundId == 0 ) {
NSString *path = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"wav"];
NSURL *soundUrl= [NSURL fileURLWithPath:path];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)soundUrl, &_soundID);
}
AudioServicesPlaySystemSound(soundID);
}
上面相同的代码适用于iphone6 plus,对于模拟器(iphone5,..)但不能用于iphone 5设备,有谁能说出原因? 感谢