gpt4 book ai didi

iphone - 我如何规划警报声音?

转载 作者:搜寻专家 更新时间:2023-10-30 20:04:22 24 4
gpt4 key购买 nike

我尝试播放 alertSound,但我有 4 个错误,这是我的功能:

#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);
}

这是日志错误:

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

最佳答案

需要在项目中添加AudioToolbox框架。
仅导入是不够的。

关于iphone - 我如何规划警报声音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4115751/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com