码迷,mamicode.com
首页 > 移动开发 > 详细

ios开发——实用技术篇Swift篇&系统声音

时间:2015-06-07 23:24:15      阅读:332      评论:0      收藏:0      [点我收藏+]

标签:

系统声音

 

 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     }

 

 

ios开发——实用技术篇Swift篇&系统声音

标签:

原文地址:http://www.cnblogs.com/iCocos/p/4559591.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!