标签:
1.
#import <AudioToolbox/AudioToolbox.h>
2.聲明 成員变量
SystemSoundID soundID;
3.播放
- (void)playSoundWith:(int)index
{
if (soundID ) {
AudioServicesDisposeSystemSoundID(soundID);
}
NSString *path = [[NSBundlemainBundle] pathForResource:[NSStringstringWithFormat:@"ring%d",index] ofType:@"wav"];
AudioServicesCreateSystemSoundID((__bridgeCFURLRef)[NSURLfileURLWithPath:path], &soundID);
AudioServicesPlaySystemSound(soundID);
}
标签:
原文地址:http://www.cnblogs.com/zhujin/p/4907290.html