标签:
系统声音
1 // MARK: - 系统声音 2 /*----- 系统声音 ------*/ 3 @IBAction func systemSound() 4 { 5 //建立的SystemSoundID对象 6 var soundID: SystemSoundID = 0 7 8 //获取声音文件地址 9 var path = NSBundle.mainBundle().pathForResource("SaoMa", ofType: "wav") 10 11 //地址转换 12 var baseURL = NSURL(fileURLWithPath: path!) 13 14 //赋值 15 AudioServicesCreateSystemSoundID(baseURL , &soundID) 16 17 //使用AudioServicesPlaySystemSound播放 18 AudioServicesPlaySystemSound(soundID) 19 } 20 21 /*----- 系统提醒 ------*/ 22 @IBAction func systemAlert() 23 { 24 //建立的SystemSoundID对象 25 var soundID: SystemSoundID = 0 26 27 //获取声音文件地址 28 var path = NSBundle.mainBundle().pathForResource("SaoMa", ofType: "wav") 29 30 //地址转换 31 var baseURL = NSURL(fileURLWithPath: path!) 32 33 //赋值 34 AudioServicesCreateSystemSoundID(baseURL , &soundID) 35 36 //使用AudioServicesPlayAlertSound播放 37 AudioServicesPlayAlertSound(soundID) 38 39 } 40 41 /*----- 系统震动 ------*/ 42 @IBAction func systemVibration() 43 { 44 //建立的SystemSoundID对象 45 var soundID = SystemSoundID(kSystemSoundID_Vibrate) 46 47 //使用AudioServicesPlaySystemSound播放 48 AudioServicesPlaySystemSound(soundID) 49 }
标签:
原文地址:http://www.cnblogs.com/iCocos/p/4559591.html