ios 개발-실용기술편 Swift편 & 시스템 사운드

5827 단어 swift
시스템 사운드
 
 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     }

 

좋은 웹페이지 즐겨찾기