-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDCSoundServices.m
executable file
·46 lines (34 loc) · 1.13 KB
/
DCSoundServices.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Toupoutou Attack !
// Bastien Clément, Sacha Bron, TM 2010, Gymnase du Bugnon - Site de Sévelin
//
//
// DCSoundServices.m
// "An Objective-C wrapper for AudioServicesPlaySystemSound", par Danilo Campos
//
// http://blog.danilocampos.com/2009/12/14/an-objective-c-wrapper-for-audioservicesplaysystemsound/
// Consulté pour la dernière fois le 22 novembre 2010.
//
#import "DCSoundServices.h"
@implementation DCSoundServices
//
// Lecture d'un son court (dans notre cas des .wav)
//
+ (void) playSoundWithName:(NSString *)fileName type:(NSString *)fileExtension {
CFStringRef cfFileName = (CFStringRef) fileName;
CFStringRef cfFileExtension = (CFStringRef) fileExtension;
CFBundleRef mainBundle;
mainBundle = CFBundleGetMainBundle ();
CFURLRef soundURLRef = CFBundleCopyResourceURL (mainBundle, cfFileName, cfFileExtension, NULL);
SystemSoundID soundID;
AudioServicesCreateSystemSoundID (soundURLRef, &soundID);
AudioServicesPlaySystemSound (soundID);
CFRelease(soundURLRef);
}
//
// Pas utilisée dans le cas de Toupoutou Attack.
//
+ (void) vibrateDevice {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
@end