当我尝试使用Finch library for iPhone SDK播放声音时,为什么我的应用程序会崩溃?

当我尝试使用Finch library for iPhone SDK播放声音时,为什么我的应用程序会崩溃?,iphone,cocoa-touch,audio,openal,finch,Iphone,Cocoa Touch,Audio,Openal,Finch,我严格按照read me文件中的说明进行操作,但出于某种原因,在我的应用程序中,每次我按代码对应的UIButton播放声音“[soundA play];应用程序只是崩溃了,除了lldb之外,没有任何详细的错误描述。我使用Finch是因为它使用OpenAL播放音频,我需要使用OpenAL作为我正在制作的应用程序类型,因为AVAudioPlayer或系统声音无法用于我正在制作的应用程序。下面是我正在使用的代码 主文件: #import "ViewController.h" @interface V

我严格按照read me文件中的说明进行操作,但出于某种原因,在我的应用程序中,每次我按代码对应的UIButton播放声音“[soundA play];应用程序只是崩溃了,除了lldb之外,没有任何详细的错误描述。我使用Finch是因为它使用OpenAL播放音频,我需要使用OpenAL作为我正在制作的应用程序类型,因为AVAudioPlayer或系统声音无法用于我正在制作的应用程序。下面是我正在使用的代码

主文件:

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
soundFactory = [[FIFactory alloc] init];
engine = [soundFactory buildSoundEngine];
[engine activateAudioSessionWithCategory:AVAudioSessionCategoryPlayback];
[engine openAudioDevice];
soundA = [soundFactory loadSoundNamed:@"1.caf" maxPolyphony:16 error:NULL];
soundB = [soundFactory loadSoundNamed:@"2.caf" maxPolyphony:16 error:NULL];
soundC = [soundFactory loadSoundNamed:@"3.caf" maxPolyphony:16 error:NULL];
soundD = [soundFactory loadSoundNamed:@"4.caf" maxPolyphony:16 error:NULL];
}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
    return YES;
}
}
- (IBAction) PlaySoundA {[soundA play];}
- (IBAction) PlaySoundB {[soundB play];}
- (IBAction) PlaySoundC {[soundC play];}
- (IBAction) PlaySoundD {[soundD play];}

@end
头文件:

#import <UIKit/UIKit.h>
#import "FISoundEngine.h"
#import "FIFactory.h"
#import "FISound.h"

@interface ViewController : UIViewController {
FIFactory* soundFactory;
FISoundEngine* engine;
FISound* soundA;
FISound* soundB;
FISound* soundC;
FISound* soundD;
}

@end
#导入
#导入“FISoundEngine.h”
#导入“FIFactory.h”
#导入“FISound.h”
@界面ViewController:UIViewController{
五厂*音响厂;
FISoundEngine*引擎;
F声音*声音;
FISound*soundB;
FISound*soundC;
FISound*soundD;
}
@结束

任何帮助都将不胜感激!谢谢!

很可能声音播放器找不到您的声音文件。请尝试右键单击音频文件并选择“在finder中查看”。确保该文件实际位于您的项目目录中,而不是

该文件已添加到项目中,复制到项目资源文件夹中,并添加到目标中。I also运行了一些代码来搜索文件,因为我认为这也是问题所在,但应用程序可以定位文件并与其他音频框架一起播放,但我需要使用OpenAL和Finch来播放这些文件。您是否通过interface builder中的connections inspector将UIButton链接到XIB文件中的按钮?是的,如果不是linked、 这样它就不会崩溃,因为它不会调用导致应用程序崩溃的方法