我有一個iPhone應用程序將通過按按鈕播放幾個奇怪的聲音,但不是所有的聲音都在工作。AVAudioPlayer不適用於所有聲音
這是我的.h文件的一部分:
{
AVAudioPlayer *hurl;
AVAudioPlayer *fart;
AVAudioPlayer *fart2;
AVAudioPlayer *evillaugh;
AVAudioPlayer *evillaugh2;
AVAudioPlayer *ghost;
AVAudioPlayer *guyhello;
AVAudioPlayer *wetfart;
}
這是我的.m文件的一部分:
- (IBAction)hurlButtonPressed:(id)sender
{
[hurl play];
}
- (IBAction)FartButtonPressed:(id)sender
{
[fart play];
}
- (IBAction)Fart2ButtonPressed:(id)sender
{
[fart2 play];
}
- (IBAction)EvilLaughButtonPressed:(id)sender
{
[evillaugh play];
}
- (IBAction)EvilLaugh2ButtonPressed:(id)sender
{
[evillaugh2 play];
}
- (IBAction)GhostButtonPressed:(id)sender
{
[ghost play];
}
- (IBAction)helloButtonPressed:(id)sender
{
[guyhello play];
}
- (IBAction)WetFartButtonPressed:(id)sender
{
[wetfart play];
}
- (void)viewDidLoad
{
NSURL *url = [[NSBundle mainBundle] URLForResource:@"Hurl" withExtension:@"wav"];
NSError *error;
hurl = [[AVAudioPlayer alloc] initWithContentsOfURL:url error: &error];
if(error != nil)
{
//This happens when the sound cannot be loaded
NSLog(@"Hurl could not be loaded!");
}
url = [[NSBundle mainBundle] URLForResource:@"Fart" withExtension:@"wav"];
fart = [[AVAudioPlayer alloc] initWithContentsOfURL:url error: &error];
if(error != nil)
{
//This happens when the sound cannot be loaded
NSLog(@"Fart could not be loaded!");
}
url = [[NSBundle mainBundle] URLForResource:@"fart_2" withExtension:@"wav"];
fart2 = [[AVAudioPlayer alloc] initWithContentsOfURL:url error: &error];
if(error != nil)
{
//This happens when the sound cannot be loaded
NSLog(@"Fart 2 could not be loaded!");
}
url = [[NSBundle mainBundle] URLForResource:@"evil_laugh" withExtension:@"wav"];
evillaugh = [[AVAudioPlayer alloc] initWithContentsOfURL:url error: &error];
if(error != nil)
{
//This happens when the sound cannot be loaded
NSLog(@"Evil Laugh could not be loaded!");
}
url = [[NSBundle mainBundle] URLForResource:@"evil_laugh_2" withExtension:@"wav"];
evillaugh2 = [[AVAudioPlayer alloc] initWithContentsOfURL:url error: &error];
if(error != nil)
{
//This happens when the sound cannot be loaded
NSLog(@"Evil Laugh 2 could not be loaded!");
}
url = [[NSBundle mainBundle] URLForResource:@"ghost" withExtension:@"wav"];
ghost = [[AVAudioPlayer alloc] initWithContentsOfURL:url error: &error];
if(error != nil)
{
//This happens when the sound cannot be loaded
NSLog(@"Ghost could not be loaded!");
}
url = [[NSBundle mainBundle] URLForResource:@"hello" withExtension:@"wav"];
guyhello = [[AVAudioPlayer alloc] initWithContentsOfURL:url error: &error];
if(error != nil)
{
//This happens when the sound cannot be loaded
NSLog(@"Guy Hello could not be loaded!");
}
url = [[NSBundle mainBundle] URLForResource:@"wet_fart02" withExtension:@"wav"];
wetfart = [[AVAudioPlayer alloc] initWithContentsOfURL:url error: &error];
if(error != nil)
{
//This happens when the sound cannot be loaded
NSLog(@"Wet Fart could not be loaded!");
}
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
然後,當我嘗試在模擬器上播放它們,我得到的錯誤我爲其中一些人設立的代碼,他們不玩。
"2012-08-05 22:02:24.392 Bathroom Noise Prank[8747:c07] Fart 2 could not be loaded!
2012-08-05 22:02:24.395 Bathroom Noise Prank[8747:c07] Evil Laugh could not be loaded!
2012-08-05 22:02:24.396 Bathroom Noise Prank[8747:c07] Evil Laugh 2 could not be loaded!
2012-08-05 22:02:24.418 Bathroom Noise Prank[8747:c07] Ghost could not be loaded!
2012-08-05 22:02:24.420 Bathroom Noise Prank[8747:c07] Wet Fart could not be loaded!
2012-08-05 22:02:26.774 Bathroom Noise Prank[8747:c07] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-08-05 22:02:26.784 Bathroom Noise Prank[8747:c07] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-08-05 22:02:26.798 Bathroom Noise Prank[8747:c07] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-08-05 22:02:26.805 Bathroom Noise Prank[8747:c07] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-08-05 22:02:26.819 Bathroom Noise Prank[8747:c07] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-08-05 22:02:26.826 Bathroom Noise Prank[8747:c07] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security"
它會更有記憶效率,更少的內部程序設計令人頭疼,無法設置一個玩家並擁有一個玩家管理的聲音庫。只是一個提示:) – achi 2012-08-06 04:53:39
您在控制檯中看到的錯誤與模擬器不是純粹的iOS或OS X有關,它們與您所看到的問題無關。 – 2012-08-06 05:12:16