#import <AudioToolbox/AudioToolbox.h>
//用系統音量播放
SystemSoundID soundID;
// 加載文件
NSURL *fileURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:soundName ofType:@"wav"]];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)(fileURL), &soundID);
// 播放短頻音效
AudioServicesPlayAlertSound(soundID);
// 增加震動效果,如果手機處于靜音狀態,提醒音將自動觸發震動
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
#import <AVFoundation/AVFoundation.h>
//用媒體音量播放
NSURL *fileURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:soundName ofType:@"wav"]];
self.audioplay = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
[self.audioplay play];