2010-11-06 4 views
3

J'essaie de jouer un alertSound, mais j'ai 4 erreur, ceci est ma fonction:Comment puis-je planifier un son d'alerte?

#import "AudioToolbox/AudioServices.h" 
+(void)jouerSon:(NSString *)fichierSon:(NSString *) extensionFichier 
{ 

NSString* soundPath = [[NSBundle mainBundle] pathForResource:fichierSon ofType:extensionFichier]; 
CFURLRef baseURL = (CFURLRef) [NSURL fileURLWithPath:soundPath]; 
SystemSoundID mysound; 

AudioServicesCreateSystemSoundID(baseURL,&mysound); 
AudioServicesPropertyID flag = 0; 
AudioServicesSetProperty(kAudioServicesPropertyIsUISound,sizeof(SystemSoundID), &mysound, sizeof(AudioServicesPropertyID), &flag); 

AudioServicesPlayAlertSound(mysound); 

//AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); 

AudioServicesDisposeSystemSoundID(mysound); 
} 

et ceci est l'erreur du journal:

Ld build/Debug-iphonesimulator/ProjetMission.app/ProjetMission normal i386 
cd /Users/sylvainlaroche/iPhone/ProjetMission 
setenv MACOSX_DEPLOYMENT_TARGET 10.6 
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" 
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk -L/Users/sylvainlaroche/iPhone/ProjetMission/build/Debug-iphonesimulator -F/Users/sylvainlaroche/iPhone/ProjetMission/build/Debug-iphonesimulator -filelist /Users/sylvainlaroche/iPhone/ProjetMission/build/ProjetMission.build/Debug-iphonesimulator/ProjetMission.build/Objects-normal/i386/ProjetMission.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/sylvainlaroche/iPhone/ProjetMission/build/Debug-iphonesimulator/ProjetMission.app/ProjetMission 

Undefined symbols: 
    "_AudioServicesDisposeSystemSoundID", referenced from: 
     +[FonctionUtile jouerSon::] in FonctionUtile.o 
    "_AudioServicesPlayAlertSound", referenced from: 
     +[FonctionUtile jouerSon::] in FonctionUtile.o 
    "_AudioServicesSetProperty", referenced from: 
     +[FonctionUtile jouerSon::] in FonctionUtile.o 
    "_AudioServicesCreateSystemSoundID", referenced from: 
     +[FonctionUtile jouerSon::] in FonctionUtile.o 
ld: symbol(s) not found 
collect2: ld returned 1 exit status 

Répondre

5

Vous devez ajouter le cadre de AudioToolbox au projet.
L'importation seule n'est pas suffisante.

Questions connexes