#import<AVFoundation>
// 1.获取音效资源的路径
NSString *path = [[NSBundle mainBundle]pathForResource:@"音乐名" ofType:@" mp3"];
// 2.将路径转化为url
NSURL *tempUrl = [NSURL fileURLWithPath:path];
// 3.用转化成的url创建一个播放器
NSError *error = nil;
AVAudioPlayer *play = [[AVAudioPlayer alloc]initWithContentsOfURL:tempUrl error:&error];
self.player = play;
// 4.播放
[play play];